mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Martin J. Bligh" <mbligh@aracnet.com>
To: Linus Torvalds <torvalds@transmeta.com>, Andrew Morton <akpm@digeo.com>
Cc: Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: Fw: 2.5.61 oops running SDET
Date: Sat, 15 Feb 2003 18:09:56 -0800	[thread overview]
Message-ID: <67320000.1045361394@[10.10.2.4]> (raw)
In-Reply-To: <Pine.LNX.4.44.0302151723560.23951-100000@home.transmeta.com>

> Yeah, but I think the bug has existed for much longer. 
> 
> It looks like "proc_pid_status()" doesn't actually lock the task at all, 
> nor even bother to test whether the task has signal state. Which has 
> _always_ been a bug. I don't know why it would start happening now, but
> it  might just be unlucky timing.
> 
> I think the proper fix is to put a 
> 
> 	task_lock()
> 	..
> 	task_unlock()
> 
> around the whole proc_pid_status() function, _and_ then verify that 
> "tsk->sighand" is non-NULL.
> 
> (Oh, careful, that's already what "get_task_mm()" does internally, so
> look  out for deadlocks - you'd need to open-code the get_task_mm() in
> there  too, so the end result is something like
> 
> 	task_lock(task)
> 	if (task->mm) {
> 		.. mm state
> 	}
> 	if (task->sighand) {
> 		.. signal state
> 	}
> 	..
> 	task_unlock(task);
> 
> instead).

Something like this? Compiles, but not tested yet ...

diff -urpN -X /home/fletch/.diff.exclude virgin/fs/proc/array.c
proc/fs/proc/array.c
--- virgin/fs/proc/array.c	Sat Feb 15 16:11:45 2003
+++ proc/fs/proc/array.c	Sat Feb 15 18:05:10 2003
@@ -243,8 +243,10 @@ extern char *task_mem(struct mm_struct *
 int proc_pid_status(struct task_struct *task, char * buffer)
 {
 	char * orig = buffer;
-	struct mm_struct *mm = get_task_mm(task);
+	struct mm_struct *mm;
 
+	task_lock(task);
+	mm = __get_task_mm(task);
 	buffer = task_name(task, buffer);
 	buffer = task_state(task, buffer);
  
@@ -257,6 +259,7 @@ int proc_pid_status(struct task_struct *
 #if defined(CONFIG_ARCH_S390)
 	buffer = task_show_regs(task, buffer);
 #endif
+	task_unlock(task);
 	return buffer - orig;
 }
 
diff -urpN -X /home/fletch/.diff.exclude virgin/include/linux/sched.h
proc/include/linux/sched.h
--- virgin/include/linux/sched.h	Sat Feb 15 16:11:47 2003
+++ proc/include/linux/sched.h	Sat Feb 15 18:04:42 2003
@@ -706,6 +706,18 @@ static inline struct mm_struct * get_tas
 
 	return mm;
 }
+
+/* lockless version of get_task_mm */
+static inline struct mm_struct * __get_task_mm(struct task_struct * task)
+{
+	struct mm_struct * mm;
+ 
+	mm = task->mm;
+	if (mm)
+		atomic_inc(&mm->mm_users);
+
+	return mm;
+}
  
  
 /* set thread flags in other task's structures


  reply	other threads:[~2003-02-16  2:00 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20030215172407.1fdd41fd.akpm@digeo.com>
2003-02-16  1:35 ` Linus Torvalds
2003-02-16  2:09   ` Martin J. Bligh [this message]
2003-02-16  2:27     ` Linus Torvalds
2003-02-16  4:00       ` Martin J. Bligh
2003-02-16 13:05         ` Anton Blanchard
2003-02-16 16:39           ` Martin J. Bligh
2003-02-16 18:21             ` Linus Torvalds
2003-02-16 19:06               ` Martin J. Bligh
2003-02-16 19:17                 ` Linus Torvalds
2003-02-16 21:15                   ` Martin J. Bligh
2003-02-16 21:21                     ` Manfred Spraul
2003-02-16 22:34                       ` Linus Torvalds
2003-02-16 23:08                         ` Martin J. Bligh
2003-02-16 23:32                           ` Linus Torvalds
2003-02-16 19:18                 ` Manfred Spraul
2003-02-16 19:19                 ` more signal locking bugs? Martin J. Bligh
2003-02-16 19:24                   ` Linus Torvalds
2003-02-16 19:37                     ` Manfred Spraul
2003-02-16 19:42                       ` Linus Torvalds
2003-02-16 20:01                         ` Linus Torvalds
2003-02-16 20:07                         ` Manfred Spraul
2003-02-16 20:10                           ` Linus Torvalds
2003-02-16 20:23                             ` Manfred Spraul
2003-02-17  0:23                           ` Linus Torvalds
2003-02-17  2:05                             ` Martin J. Bligh
2003-02-17  2:39                               ` Martin J. Bligh
2003-02-17  3:53                                 ` Linus Torvalds
2003-02-17  5:07                                   ` Martin J. Bligh
2003-02-17  6:17                                   ` Martin J. Bligh
2003-02-17 17:09                                   ` Magnus Naeslund(f)
2003-02-17  3:54                                 ` [PATCH] fix secondary oops in sighand locking Martin J. Bligh
2003-02-17  6:36                             ` more signal locking bugs? Manfred Spraul
2003-02-17 19:06                               ` Linus Torvalds
2003-02-16 18:07         ` Fw: 2.5.61 oops running SDET Linus Torvalds
2003-02-16 18:26           ` Martin J. Bligh
2003-02-16 18:36             ` Martin J. Bligh
2003-02-16  2:48     ` Zwane Mwaikambo
2003-02-16 17:41 Manfred Spraul
2003-02-16 18:15 ` Linus Torvalds
2003-02-16 18:45   ` Manfred Spraul
2003-02-16 18:56     ` Linus Torvalds

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='67320000.1045361394@[10.10.2.4]' \
    --to=mbligh@aracnet.com \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@transmeta.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®