From: Jean Delvare <jdelvare@suse.de>
To: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Andrew Morton <akpm@osdl.org>, Oleg Nesterov <oleg@tv-sign.ru>,
KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>,
linux-kernel@vger.kernel.org, ak@suse.de
Subject: Re: [PATCH] proc: readdir race fix (take 3)
Date: Thu, 7 Sep 2006 10:31:33 +0200 [thread overview]
Message-ID: <200609071031.33855.jdelvare@suse.de> (raw)
In-Reply-To: <m1zmdcty4i.fsf@ebiederm.dsl.xmission.com>
[-- Attachment #1: Type: text/plain, Size: 1041 bytes --]
On Thursday 7 September 2006 00:43, Eric W. Biederman wrote:
> Have you tested 2.6.18-rc6 without my patch?
Yes I did, it didn't crash after a couple hours. Of course it doesn't
prove anything as the crash appears to be the result of a race.
I'll now apply Oleg's fix and see if things get better.
> I guess the practical question is what was your test methodology to
> reproduce this problem? A couple of more people running the same
> test on a few more machines might at least give us confidence in what
> is going on.
"My" test program forks 1000 children who sleep for 1 second then look for
themselves in /proc, warn if they can't find themselves, and exit. So
basically the idea is that the process list will shrink very rapidly at
the same moment every child does readdir(/proc).
I attached the test program, I take no credit (nor shame) for it, it was
provided to me by IBM (possibly on behalf of one of their own customers)
as a way to demonstrate and reproduce the original readdir(/proc) race
bug.
--
Jean Delvare
[-- Attachment #2: test.c --]
[-- Type: text/x-csrc, Size: 1151 bytes --]
#include <stdlib.h>
#include <stdio.h>
#include <dirent.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/wait.h>
#include <sys/param.h>
#include <utmp.h>
#include <pwd.h>
#include <string.h>
#include <unistd.h>
#include <fcntl.h>
#include <signal.h>
#include <syslog.h>
#include <errno.h>
#include <stdarg.h>
#include <ctype.h>
#define NUM_CHILDREN 1000
findme(i)
int i;
{
DIR * dir = NULL;
struct dirent *d;
int pid;
int mypid;
mypid = getpid();
if ((dir = opendir("/proc")) == (DIR *)0)
{
perror("failed to open /proc\n");
exit(1);
}
while((d = readdir(dir)) != (struct dirent *)0) {
if ((pid = (pid_t)atoi(d->d_name)) == 0) continue;
if (pid==mypid) return(1);
}
printf("\nfailed to find myself: pid %d, iteration %d\n",mypid,i);
return(0);
}
fork_child(i)
int i;
{
int pid;
switch ((pid = fork())) {
case 0: /* child */
sleep(1);
findme(i);
exit(0);
;;
case -1: /* error */
perror("failed to fork\n");
exit(1);
;;
default: /* parent */
;;
}
}
main()
{
int i;
(void)signal(SIGCHLD, SIG_IGN);
for (i=0; i<NUM_CHILDREN; i++)
{
fork_child(i);
}
}
next prev parent reply other threads:[~2006-09-07 8:30 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-08-25 9:29 [RFC][PATCH] ps command race fix take 4 [4/4] proc root open/release/llseek KAMEZAWA Hiroyuki
2006-09-04 23:13 ` [PATCH] proc: readdir race fix Eric W. Biederman
2006-09-05 1:30 ` KAMEZAWA Hiroyuki
2006-09-05 2:30 ` Eric W. Biederman
2006-09-05 2:41 ` KAMEZAWA Hiroyuki
2006-09-05 2:26 ` KAMEZAWA Hiroyuki
2006-09-05 2:54 ` Eric W. Biederman
2006-09-05 3:07 ` Eric W. Biederman
2006-09-05 5:39 ` KAMEZAWA Hiroyuki
2006-09-05 10:10 ` Oleg Nesterov
2006-09-05 11:36 ` Eric W. Biederman
2006-09-05 14:52 ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-06 9:01 ` Jean Delvare
2006-09-06 21:12 ` Jean Delvare
2006-09-06 22:25 ` Oleg Nesterov
2006-09-06 22:38 ` [PATCH] proc-readdir-race-fix-take-3-fix-3 Oleg Nesterov
2006-09-06 22:59 ` Eric W. Biederman
2006-09-08 6:38 ` Eric W. Biederman
2006-09-06 22:43 ` [PATCH] proc: readdir race fix (take 3) Eric W. Biederman
2006-09-07 8:31 ` Jean Delvare [this message]
2006-09-07 13:57 ` Eric W. Biederman
2006-09-07 18:07 ` Jean Delvare
2006-09-07 18:40 ` Eric W. Biederman
2006-09-05 5:26 ` [PATCH] proc: readdir race fix KAMEZAWA Hiroyuki
2006-09-05 5:41 ` KAMEZAWA Hiroyuki
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=200609071031.33855.jdelvare@suse.de \
--to=jdelvare@suse.de \
--cc=ak@suse.de \
--cc=akpm@osdl.org \
--cc=ebiederm@xmission.com \
--cc=kamezawa.hiroyu@jp.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=oleg@tv-sign.ru \
/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
Powered by JetHome