* [CHECKER] race in 2.5.62/fs/exec.c?
@ 2003-03-22 19:40 Dawson Engler
2003-03-22 21:45 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Dawson Engler @ 2003-03-22 19:40 UTC (permalink / raw)
To: linux-kernel; +Cc: Dawson Engler
I'm not sure if I'm missing something --- is the following a race?
2.5.62/fs/exec.c:1013:search_binary_handler:
read_unlock(&binfmt_lock);
retval = fn(bprm, regs);
if (retval >= 0) {
put_binfmt(fmt);
binfmt_lock is released and then put_binfmt is called. put_binfmt
seems to need locking:
fs/exec.c:1022:search_binary_handle
read_lock(&binfmt_lock);
put_binfmt(fmt);
if (retval != -ENOEXEC)
break;
if (!bprm->file) {
read_unlock(&binfmt_lock);
return retval;
}
2.5.62/fs/exec.c:151:sys_uselib:
error = fmt->load_shlib(file);
read_lock(&binfmt_lock);
put_binfmt(fmt);
if (error != -ENOEXEC)
break;
}
Are these other locks redundant? Or does put_binfmt need protection?
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [CHECKER] race in 2.5.62/fs/exec.c?
2003-03-22 19:40 [CHECKER] race in 2.5.62/fs/exec.c? Dawson Engler
@ 2003-03-22 21:45 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2003-03-22 21:45 UTC (permalink / raw)
To: Dawson Engler; +Cc: linux-kernel
Dawson Engler <engler@csl.stanford.edu> wrote:
>
> I'm not sure if I'm missing something --- is the following a race?
>
> 2.5.62/fs/exec.c:1013:search_binary_handler:
> read_unlock(&binfmt_lock);
> retval = fn(bprm, regs);
> if (retval >= 0) {
> put_binfmt(fmt);
Don't think so.
That lock protects the global list of registered formats only. Because we
have a ref against the format's underlying module when that lock is dropped,
the module cannot be unloaded and nobody can unregister the format. Hence
the thing at *fmt is stable, and reading fmt->next after retaking the lock is
safe.
The particular piece of code you quote would be buggy if it continued
to go around the loop and again used fmt->next. But it will unconditionally
return after performing the put_binfmt() call.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2003-03-22 21:34 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-03-22 19:40 [CHECKER] race in 2.5.62/fs/exec.c? Dawson Engler
2003-03-22 21:45 ` Andrew Morton
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®