|
1 From 4700df7fad5064696c6bb5809fe01067966543ad Mon Sep 17 00:00:00 2001 |
|
2 From: Florian Westphal <fw@strlen.de> |
|
3 Date: Sun, 22 Mar 2009 15:12:05 +0100 |
|
4 Subject: [PATCH] Disable range checks; we're running in userspace |
|
5 |
|
6 The get_user macro calls |
|
7 __get_user_{1,2,4} |
|
8 depending on sizeof(*ptr). |
|
9 Unfortunately, these functions are assembler routines that have |
|
10 protoype void fun(void), yet they they will modifiy arguments and |
|
11 return a value, so they cannot be implemented easily in the cradle code. |
|
12 |
|
13 The most simple method to work around it is to remove that macro |
|
14 if CONFIG_NSC is defined. |
|
15 |
|
16 --- a/linux-2.6.28/arch/x86/include/asm/uaccess.h 2008-10-26 11:41:31.000000000 +0100 |
|
17 +++ b/linux-2.6.28/arch/x86/include/asm/uaccess.h 2008-10-24 12:43:01.000000000 +0200 |
|
18 @@ -77,11 +77,8 @@ |
|
19 * checks that the pointer is in the user space range - after calling |
|
20 * this function, memory access functions may still return -EFAULT. |
|
21 */ |
|
22 +#ifdef CONFIG_NSC |
|
23 +#define access_ok(type, addr, size) (1) |
|
24 +#else |
|
25 #define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0)) |
|
26 +#endif |
|
27 - |
|
28 /* |
|
29 * The exception table consists of pairs of addresses: the first is the |
|
30 * address of an instruction that is allowed to fault, and the second is |
|
31 @@ -155,9 +152,6 @@ |
|
32 __get_user_x(8, __ret_gu, __val_gu, ptr) |
|
33 #endif |
|
34 |
|
35 +#ifdef CONFIG_NSC |
|
36 +#define get_user(x,ptr) ({ (x) = *ptr; 0; }) |
|
37 +#else |
|
38 #define get_user(x, ptr) \ |
|
39 ({ \ |
|
40 int __ret_gu; \ |
|
41 @@ -183,7 +177,6 @@ |
|
42 (x) = (__typeof__(*(ptr)))__val_gu; \ |
|
43 __ret_gu; \ |
|
44 }) |
|
45 +#endif |
|
46 |
|
47 #define __put_user_x(size, x, ptr, __ret_pu) \ |
|
48 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \ |
|
49 @@ -243,10 +236,6 @@ |
|
50 * |
|
51 * Returns zero on success, or -EFAULT on error. |
|
52 */ |
|
53 + |
|
54 +#ifdef CONFIG_NSC |
|
55 +#define put_user(x,ptr) ({ *(ptr) = x; 0;}) |
|
56 +#else |
|
57 #define put_user(x, ptr) \ |
|
58 ({ \ |
|
59 int __ret_pu; \ |
|
60 @@ -272,7 +261,6 @@ |
|
61 } \ |
|
62 __ret_pu; \ |
|
63 }) |
|
64 +#endif |
|
65 |
|
66 #define __put_user_size(x, ptr, size, retval, errret) \ |
|
67 do { \ |
|
68 --- |
|
69 arch/x86/include/asm/uaccess.h | 12 ++++++++++ |
|
70 patches/random-driver-no-entropy-accounting.patch | 25 --------------------- |
|
71 2 files changed, 12 insertions(+), 25 deletions(-) |
|
72 delete mode 100644 patches/random-driver-no-entropy-accounting.patch |
|
73 |
|
74 diff --git a/arch/x86/include/asm/uaccess.h b/arch/x86/include/asm/uaccess.h |
|
75 index 4340055..b443339 100644 |
|
76 --- a/arch/x86/include/asm/uaccess.h |
|
77 +++ b/arch/x86/include/asm/uaccess.h |
|
78 @@ -77,7 +77,11 @@ |
|
79 * checks that the pointer is in the user space range - after calling |
|
80 * this function, memory access functions may still return -EFAULT. |
|
81 */ |
|
82 +#ifdef CONFIG_NSC |
|
83 +#define access_ok(type, addr, size) (1) |
|
84 +#else |
|
85 #define access_ok(type, addr, size) (likely(__range_not_ok(addr, size) == 0)) |
|
86 +#endif |
|
87 |
|
88 /* |
|
89 * The exception table consists of pairs of addresses: the first is the |
|
90 @@ -152,6 +156,9 @@ extern int __get_user_bad(void); |
|
91 __get_user_x(8, __ret_gu, __val_gu, ptr) |
|
92 #endif |
|
93 |
|
94 +#ifdef CONFIG_NSC |
|
95 +#define get_user(x,ptr) ({ (x) = *ptr; 0; }) |
|
96 +#else |
|
97 #define get_user(x, ptr) \ |
|
98 ({ \ |
|
99 int __ret_gu; \ |
|
100 @@ -178,6 +185,7 @@ extern int __get_user_bad(void); |
|
101 (x) = (__typeof__(*(ptr)))__val_gu; \ |
|
102 __ret_gu; \ |
|
103 }) |
|
104 +#endif /* NSC */ |
|
105 |
|
106 #define __put_user_x(size, x, ptr, __ret_pu) \ |
|
107 asm volatile("call __put_user_" #size : "=a" (__ret_pu) \ |
|
108 @@ -237,6 +245,9 @@ extern void __put_user_8(void); |
|
109 * |
|
110 * Returns zero on success, or -EFAULT on error. |
|
111 */ |
|
112 +#ifdef CONFIG_NSC |
|
113 +#define put_user(x,ptr) ({ *(ptr) = x; 0;}) |
|
114 +#else |
|
115 #define put_user(x, ptr) \ |
|
116 ({ \ |
|
117 int __ret_pu; \ |
|
118 @@ -263,6 +274,7 @@ extern void __put_user_8(void); |
|
119 } \ |
|
120 __ret_pu; \ |
|
121 }) |
|
122 +#endif /* NSC */ |
|
123 |
|
124 #define __put_user_size(x, ptr, size, retval, errret) \ |
|
125 do { \ |
|
126 diff --git a/patches/random-driver-no-entropy-accounting.patch b/patches/random-driver-no-entropy-accounting.patch |
|
127 deleted file mode 100644 |
|
128 index 7e9a4ca..0000000 |
|
129 --- a/patches/random-driver-no-entropy-accounting.patch |
|
130 +++ /dev/null |
|
131 @@ -1,25 +0,0 @@ |
|
132 -This disables entropy accounting in the PRNG. |
|
133 - |
|
134 -The real fix is to either completely replace random.c, |
|
135 -providing our own implementation using ns-3 rng infrastructure, |
|
136 -or feed the prng periodically. |
|
137 - |
|
138 ---- a/drivers/char/random.c 2008-05-02 13:17:31.000000000 +0200 |
|
139 -+++ b/drivers/char/random.c 2008-07-14 03:23:26.000000000 +0200 |
|
140 -@@ -749,15 +749,7 @@ |
|
141 - unsigned long flags; |
|
142 - |
|
143 - BUG_ON(r->entropy_count > r->poolinfo->POOLBITS); |
|
144 -+#ifdef CONFIG_NSC |
|
145 -+ /* |
|
146 -+ * prevent infinite loop: if a code path calls get_random_bytes |
|
147 -+ * and we've run out of entropy, this calls wake_up_interruptible(), |
|
148 -+ * which calls the code path again, which calls get_random_bytes, |
|
149 -+ * which calls wake_up which... |
|
150 -+ */ |
|
151 -+ return nbytes; |
|
152 -+#endif |
|
153 -+ |
|
154 - /* Hold lock while accounting */ |
|
155 - spin_lock_irqsave(&r->lock, flags); |
|
156 - |
|
157 -- |
|
158 1.6.0.6 |
|
159 |