/[linux-patches]/hardened/2.6/trunk/2.6.23/4405_alpha-sysctl-uac.patch
Gentoo

Contents of /hardened/2.6/trunk/2.6.23/4405_alpha-sysctl-uac.patch

Parent Directory Parent Directory | Revision Log Revision Log


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