/[linux-patches]/genpatches-2.6/tags/2.6.20-9/4405_alpha-sysctl-uac.patch
Gentoo

Contents of /genpatches-2.6/tags/2.6.20-9/4405_alpha-sysctl-uac.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 927 - (show annotations) (download)
Thu Apr 26 15:33:43 2007 UTC (7 years, 4 months ago) by phreak
File size: 5775 byte(s)
2.6.20-9 release
1 Index: linux-2.6.20/arch/alpha/Kconfig
2 ===================================================================
3 --- linux-2.6.20.orig/arch/alpha/Kconfig
4 +++ linux-2.6.20/arch/alpha/Kconfig
5 @@ -598,6 +598,32 @@ config VERBOSE_MCHECK_ON
6
7 Take the default (1) unless you want more control or more info.
8
9 +config ALPHA_UAC_SYSCTL
10 + bool "Configure UAC policy via sysctl"
11 + depends on SYSCTL
12 + default y
13 + ---help---
14 + Configuring the UAC (unaligned access control) policy on a Linux
15 + system usually involves setting a compile time define. If you say
16 + Y here, you will be able to modify the UAC policy at runtime using
17 + the /proc interface.
18 +
19 + The UAC policy defines the action Linux should take when an
20 + unaligned memory access occurs. The action can include printing a
21 + warning message (NOPRINT), sending a signal to the offending
22 + program to help developers debug their applications (SIGBUS), or
23 + disabling the transparent fixing (NOFIX).
24 +
25 + The sysctls will be initialized to the compile-time defined UAC
26 + policy. You can change these manually, or with the sysctl(8)
27 + userspace utility.
28 +
29 + To disable the warning messages at runtime, you would use
30 +
31 + echo 1 > /proc/sys/kernel/uac/noprint
32 +
33 + This is pretty harmless. Say Y if you're not sure.
34 +
35 source "drivers/pci/Kconfig"
36 source "drivers/eisa/Kconfig"
37
38 Index: linux-2.6.20/arch/alpha/kernel/traps.c
39 ===================================================================
40 --- linux-2.6.20.orig/arch/alpha/kernel/traps.c
41 +++ linux-2.6.20/arch/alpha/kernel/traps.c
42 @@ -14,6 +14,7 @@
43 #include <linux/delay.h>
44 #include <linux/smp_lock.h>
45 #include <linux/module.h>
46 +#include <linux/sysctl.h>
47 #include <linux/init.h>
48 #include <linux/kallsyms.h>
49
50 @@ -102,6 +103,38 @@ static char * ireg_name[] = {"v0", "t0",
51 "t10", "t11", "ra", "pv", "at", "gp", "sp", "zero"};
52 #endif
53
54 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
55 +static struct ctl_table_header *uac_sysctl_header;
56 +
57 +static int enabled_noprint = 0;
58 +static int enabled_sigbus = 0;
59 +static int enabled_nofix = 0;
60 +
61 +ctl_table uac_table[] = {
62 + {KERN_UAC_NOPRINT, "noprint", &enabled_noprint, sizeof (int), 0644, NULL, &proc_dointvec},
63 + {KERN_UAC_SIGBUS, "sigbus", &enabled_sigbus, sizeof (int), 0644, NULL, &proc_dointvec},
64 + {KERN_UAC_NOFIX, "nofix", &enabled_nofix, sizeof (int), 0644, NULL, &proc_dointvec},
65 + {0}
66 +};
67 +
68 +static int __init init_uac_sysctl(void)
69 +{
70 + /* Initialize sysctls with the #defined UAC policy */
71 + enabled_noprint = (test_thread_flag (TIF_UAC_NOPRINT)) ? 1 : 0;
72 + enabled_sigbus = (test_thread_flag (TIF_UAC_SIGBUS)) ? 1 : 0;
73 + enabled_nofix = (test_thread_flag (TIF_UAC_NOFIX)) ? 1 : 0;
74 +
75 + /* save this for later so we can clean up */
76 + uac_sysctl_header = register_sysctl_table(uac_table, 0);
77 + return 0;
78 +}
79 +
80 +static void __exit exit_uac_sysctl(void)
81 +{
82 + unregister_sysctl_table(uac_sysctl_header);
83 +}
84 +#endif
85 +
86 static void
87 dik_show_code(unsigned int *pc)
88 {
89 @@ -779,7 +812,11 @@ do_entUnaUser(void __user * va, unsigned
90 /* Check the UAC bits to decide what the user wants us to do
91 with the unaliged access. */
92
93 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
94 if (!test_thread_flag (TIF_UAC_NOPRINT)) {
95 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
96 + if (!(enabled_noprint)) {
97 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
98 if (cnt >= 5 && jiffies - last_time > 5*HZ) {
99 cnt = 0;
100 }
101 @@ -790,10 +827,18 @@ do_entUnaUser(void __user * va, unsigned
102 }
103 last_time = jiffies;
104 }
105 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
106 if (test_thread_flag (TIF_UAC_SIGBUS))
107 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
108 + if (enabled_sigbus)
109 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
110 goto give_sigbus;
111 /* Not sure why you'd want to use this, but... */
112 +#ifndef CONFIG_ALPHA_UAC_SYSCTL
113 if (test_thread_flag (TIF_UAC_NOFIX))
114 +#else /* CONFIG_ALPHA_UAC_SYSCTL */
115 + if (enabled_nofix)
116 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
117 return;
118
119 /* Don't bother reading ds in the access check since we already
120 @@ -1088,3 +1133,5 @@ trap_init(void)
121 wrent(entSys, 5);
122 wrent(entDbg, 6);
123 }
124 +
125 +__initcall(init_uac_sysctl);
126 Index: linux-2.6.20/include/linux/sysctl.h
127 ===================================================================
128 --- linux-2.6.20.orig/include/linux/sysctl.h
129 +++ linux-2.6.20/include/linux/sysctl.h
130 @@ -161,6 +161,9 @@ enum
131 KERN_NMI_WATCHDOG=75, /* int: enable/disable nmi watchdog */
132 KERN_PANIC_ON_NMI=76, /* int: whether we will panic on an unrecovered */
133 KERN_FBSPLASH=77, /* string: path to fbsplash helper */
134 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
135 + KERN_UAC_POLICY=78, /* int: Alpha unaligned access control policy flags */
136 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
137 };
138
139
140 @@ -249,6 +252,17 @@ enum
141 PTY_NR=2
142 };
143
144 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
145 +/* /proc/sys/kernel/uac */
146 +enum
147 +{
148 + /* UAC policy on Alpha */
149 + KERN_UAC_NOPRINT=1, /* int: printk() on unaligned access */
150 + KERN_UAC_SIGBUS=2, /* int: send SIGBUS on unaligned access */
151 + KERN_UAC_NOFIX=3, /* int: don't fix the unaligned access */
152 +};
153 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
154 +
155 /* /proc/sys/bus/isa */
156 enum
157 {
158 Index: linux-2.6.20/kernel/sysctl.c
159 ===================================================================
160 --- linux-2.6.20.orig/kernel/sysctl.c
161 +++ linux-2.6.20/kernel/sysctl.c
162 @@ -172,6 +172,9 @@ extern ctl_table pty_table[];
163 #ifdef CONFIG_INOTIFY_USER
164 extern ctl_table inotify_table[];
165 #endif
166 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
167 +extern ctl_table uac_table[];
168 +#endif
169
170 #ifdef HAVE_ARCH_PICK_MMAP_LAYOUT
171 int sysctl_legacy_va_layout;
172 @@ -272,7 +275,14 @@ static ctl_table root_table[] = {
173 .mode = 0555,
174 .child = dev_table,
175 },
176 -
177 +#ifdef CONFIG_ALPHA_UAC_SYSCTL
178 + {
179 + .ctl_name = KERN_UAC_POLICY,
180 + .procname = "uac",
181 + .mode = 0555,
182 + .child = uac_table,
183 + },
184 +#endif /* CONFIG_ALPHA_UAC_SYSCTL */
185 { .ctl_name = 0 }
186 };
187

  ViewVC Help
Powered by ViewVC 1.1.20