aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2012-10-30 06:08:25 -0400
committerTakashi Iwai <tiwai@suse.de>2012-10-30 06:08:25 -0400
commita5d00dc3a4b65ed38249f3225e453944c633747b (patch)
tree6249ca5a5f13059f42890525a9ea7133778f3891 /kernel
parent1a8506d4402b6e96c2ed778dc7ccbb48d1e02fce (diff)
parent0914f7961babbf28aaa2f19b453951fb4841c03f (diff)
Merge branch 'for-linus' into for-next
... for migrating the core changes for USB-audio disconnection fixes
Diffstat (limited to 'kernel')
-rw-r--r--kernel/module-internal.h3
-rw-r--r--kernel/module.c26
-rw-r--r--kernel/module_signing.c24
-rw-r--r--kernel/pid_namespace.c21
-rw-r--r--kernel/printk.c1
-rw-r--r--kernel/sys.c12
6 files changed, 46 insertions, 41 deletions
diff --git a/kernel/module-internal.h b/kernel/module-internal.h
index 6114a13419bd..24f9247b7d02 100644
--- a/kernel/module-internal.h
+++ b/kernel/module-internal.h
@@ -11,5 +11,4 @@
11 11
12extern struct key *modsign_keyring; 12extern struct key *modsign_keyring;
13 13
14extern int mod_verify_sig(const void *mod, unsigned long modlen, 14extern int mod_verify_sig(const void *mod, unsigned long *_modlen);
15 const void *sig, unsigned long siglen);
diff --git a/kernel/module.c b/kernel/module.c
index 0e2da8695f8e..6085f5ef88ea 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -2421,25 +2421,17 @@ static inline void kmemleak_load_module(const struct module *mod,
2421 2421
2422#ifdef CONFIG_MODULE_SIG 2422#ifdef CONFIG_MODULE_SIG
2423static int module_sig_check(struct load_info *info, 2423static int module_sig_check(struct load_info *info,
2424 const void *mod, unsigned long *len) 2424 const void *mod, unsigned long *_len)
2425{ 2425{
2426 int err = -ENOKEY; 2426 int err = -ENOKEY;
2427 const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; 2427 unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1;
2428 const void *p = mod, *end = mod + *len; 2428 unsigned long len = *_len;
2429 2429
2430 /* Poor man's memmem. */ 2430 if (len > markerlen &&
2431 while ((p = memchr(p, MODULE_SIG_STRING[0], end - p))) { 2431 memcmp(mod + len - markerlen, MODULE_SIG_STRING, markerlen) == 0) {
2432 if (p + markerlen > end) 2432 /* We truncate the module to discard the signature */
2433 break; 2433 *_len -= markerlen;
2434 2434 err = mod_verify_sig(mod, _len);
2435 if (memcmp(p, MODULE_SIG_STRING, markerlen) == 0) {
2436 const void *sig = p + markerlen;
2437 /* Truncate module up to signature. */
2438 *len = p - mod;
2439 err = mod_verify_sig(mod, *len, sig, end - sig);
2440 break;
2441 }
2442 p++;
2443 } 2435 }
2444 2436
2445 if (!err) { 2437 if (!err) {
diff --git a/kernel/module_signing.c b/kernel/module_signing.c
index 6b09f6983ac0..d492a23df99c 100644
--- a/kernel/module_signing.c
+++ b/kernel/module_signing.c
@@ -183,27 +183,33 @@ static struct key *request_asymmetric_key(const char *signer, size_t signer_len,
183/* 183/*
184 * Verify the signature on a module. 184 * Verify the signature on a module.
185 */ 185 */
186int mod_verify_sig(const void *mod, unsigned long modlen, 186int mod_verify_sig(const void *mod, unsigned long *_modlen)
187 const void *sig, unsigned long siglen)
188{ 187{
189 struct public_key_signature *pks; 188 struct public_key_signature *pks;
190 struct module_signature ms; 189 struct module_signature ms;
191 struct key *key; 190 struct key *key;
192 size_t sig_len; 191 const void *sig;
192 size_t modlen = *_modlen, sig_len;
193 int ret; 193 int ret;
194 194
195 pr_devel("==>%s(,%lu,,%lu,)\n", __func__, modlen, siglen); 195 pr_devel("==>%s(,%lu)\n", __func__, modlen);
196 196
197 if (siglen <= sizeof(ms)) 197 if (modlen <= sizeof(ms))
198 return -EBADMSG; 198 return -EBADMSG;
199 199
200 memcpy(&ms, sig + (siglen - sizeof(ms)), sizeof(ms)); 200 memcpy(&ms, mod + (modlen - sizeof(ms)), sizeof(ms));
201 siglen -= sizeof(ms); 201 modlen -= sizeof(ms);
202 202
203 sig_len = be32_to_cpu(ms.sig_len); 203 sig_len = be32_to_cpu(ms.sig_len);
204 if (sig_len >= siglen || 204 if (sig_len >= modlen)
205 siglen - sig_len != (size_t)ms.signer_len + ms.key_id_len)
206 return -EBADMSG; 205 return -EBADMSG;
206 modlen -= sig_len;
207 if ((size_t)ms.signer_len + ms.key_id_len >= modlen)
208 return -EBADMSG;
209 modlen -= (size_t)ms.signer_len + ms.key_id_len;
210
211 *_modlen = modlen;
212 sig = mod + modlen;
207 213
208 /* For the moment, only support RSA and X.509 identifiers */ 214 /* For the moment, only support RSA and X.509 identifiers */
209 if (ms.algo != PKEY_ALGO_RSA || 215 if (ms.algo != PKEY_ALGO_RSA ||
diff --git a/kernel/pid_namespace.c b/kernel/pid_namespace.c
index 478bad2745e3..eb00be205811 100644
--- a/kernel/pid_namespace.c
+++ b/kernel/pid_namespace.c
@@ -133,19 +133,26 @@ struct pid_namespace *copy_pid_ns(unsigned long flags, struct pid_namespace *old
133 return create_pid_namespace(old_ns); 133 return create_pid_namespace(old_ns);
134} 134}
135 135
136void free_pid_ns(struct kref *kref) 136static void free_pid_ns(struct kref *kref)
137{ 137{
138 struct pid_namespace *ns, *parent; 138 struct pid_namespace *ns;
139 139
140 ns = container_of(kref, struct pid_namespace, kref); 140 ns = container_of(kref, struct pid_namespace, kref);
141
142 parent = ns->parent;
143 destroy_pid_namespace(ns); 141 destroy_pid_namespace(ns);
142}
144 143
145 if (parent != NULL) 144void put_pid_ns(struct pid_namespace *ns)
146 put_pid_ns(parent); 145{
146 struct pid_namespace *parent;
147
148 while (ns != &init_pid_ns) {
149 parent = ns->parent;
150 if (!kref_put(&ns->kref, free_pid_ns))
151 break;
152 ns = parent;
153 }
147} 154}
148EXPORT_SYMBOL_GPL(free_pid_ns); 155EXPORT_SYMBOL_GPL(put_pid_ns);
149 156
150void zap_pid_ns_processes(struct pid_namespace *pid_ns) 157void zap_pid_ns_processes(struct pid_namespace *pid_ns)
151{ 158{
diff --git a/kernel/printk.c b/kernel/printk.c
index 66a2ea37b576..2d607f4d1797 100644
--- a/kernel/printk.c
+++ b/kernel/printk.c
@@ -1890,7 +1890,6 @@ static int __cpuinit console_cpu_notify(struct notifier_block *self,
1890 switch (action) { 1890 switch (action) {
1891 case CPU_ONLINE: 1891 case CPU_ONLINE:
1892 case CPU_DEAD: 1892 case CPU_DEAD:
1893 case CPU_DYING:
1894 case CPU_DOWN_FAILED: 1893 case CPU_DOWN_FAILED:
1895 case CPU_UP_CANCELED: 1894 case CPU_UP_CANCELED:
1896 console_lock(); 1895 console_lock();
diff --git a/kernel/sys.c b/kernel/sys.c
index c5cb5b99cb81..e6e0ece5f6a0 100644
--- a/kernel/sys.c
+++ b/kernel/sys.c
@@ -1265,15 +1265,16 @@ DECLARE_RWSEM(uts_sem);
1265 * Work around broken programs that cannot handle "Linux 3.0". 1265 * Work around broken programs that cannot handle "Linux 3.0".
1266 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40 1266 * Instead we map 3.x to 2.6.40+x, so e.g. 3.0 would be 2.6.40
1267 */ 1267 */
1268static int override_release(char __user *release, int len) 1268static int override_release(char __user *release, size_t len)
1269{ 1269{
1270 int ret = 0; 1270 int ret = 0;
1271 char buf[65];
1272 1271
1273 if (current->personality & UNAME26) { 1272 if (current->personality & UNAME26) {
1274 char *rest = UTS_RELEASE; 1273 const char *rest = UTS_RELEASE;
1274 char buf[65] = { 0 };
1275 int ndots = 0; 1275 int ndots = 0;
1276 unsigned v; 1276 unsigned v;
1277 size_t copy;
1277 1278
1278 while (*rest) { 1279 while (*rest) {
1279 if (*rest == '.' && ++ndots >= 3) 1280 if (*rest == '.' && ++ndots >= 3)
@@ -1283,8 +1284,9 @@ static int override_release(char __user *release, int len)
1283 rest++; 1284 rest++;
1284 } 1285 }
1285 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40; 1286 v = ((LINUX_VERSION_CODE >> 8) & 0xff) + 40;
1286 snprintf(buf, len, "2.6.%u%s", v, rest); 1287 copy = clamp_t(size_t, len, 1, sizeof(buf));
1287 ret = copy_to_user(release, buf, len); 1288 copy = scnprintf(buf, copy, "2.6.%u%s", v, rest);
1289 ret = copy_to_user(release, buf, copy + 1);
1288 } 1290 }
1289 return ret; 1291 return ret;
1290} 1292}