From: Kirill Korotaev <dev@sw.ru>
To: Andrew Morton <akpm@osdl.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] sys_getppid oopses on debug kernel
Date: Tue, 08 Aug 2006 14:22:53 +0400 [thread overview]
Message-ID: <44D865FD.1040806@sw.ru> (raw)
[-- Attachment #1: Type: text/plain, Size: 164 bytes --]
sys_getppid() optimization can access a freed memory.
On kernels with DEBUG_SLAB turned ON, this results in
Oops.
Signed-Off-By: Kirill Korotaev <dev@openvz.org>
[-- Attachment #2: diff-get-ppid-with-slab-debug --]
[-- Type: text/plain, Size: 717 bytes --]
--- ./kernel/timer.c.ppiddbg 2006-07-14 19:11:06.000000000 +0400
+++ ./kernel/timer.c 2006-08-08 14:19:24.000000000 +0400
@@ -1342,6 +1342,7 @@ asmlinkage long sys_getpid(void)
asmlinkage long sys_getppid(void)
{
int pid;
+#ifndef CONFIG_DEBUG_SLAB
struct task_struct *me = current;
struct task_struct *parent;
@@ -1364,6 +1365,16 @@ asmlinkage long sys_getppid(void)
#endif
break;
}
+#else
+ /*
+ * ->real_parent could be released before dereference and
+ * we accessed freed kernel memory, which faults with debugging on.
+ * Keep it simple and stupid.
+ */
+ read_lock(&tasklist_lock);
+ pid = current->group_leader->real_parent->tgid;
+ read_unlock(&tasklist_lock);
+#endif
return pid;
}
next reply other threads:[~2006-08-08 10:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-08 10:22 Kirill Korotaev [this message]
2006-08-08 15:26 ` [PATCH] sys_getppid oopses on debug kernel Dave Hansen
2006-08-08 15:34 ` Björn Steinbrink
2006-08-08 15:41 ` Dave Hansen
2006-08-08 15:43 ` Kirill Korotaev
2006-08-08 15:49 ` Dave Hansen
2006-08-08 15:54 ` Kirill Korotaev
2006-08-08 15:58 ` Martin Schwidefsky
2006-08-09 3:09 ` Andi Kleen
2006-08-09 3:31 ` Andrew Morton
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=44D865FD.1040806@sw.ru \
--to=dev@sw.ru \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.