* [PATCH] max_fds race in select().
@ 2001-05-04 4:10 Rusty Russell
2001-05-04 4:10 ` Alexander Viro
0 siblings, 1 reply; 2+ messages in thread
From: Rusty Russell @ 2001-05-04 4:10 UTC (permalink / raw)
To: torvalds, Alexander Viro; +Cc: linux-kernel
We can end up with the user getting more fds tban they asked for...
Unlikely, but possible,
Rusty.
--- linux-2.4.4-official/fs/select.c Thu Feb 22 14:25:36 2001
+++ working-2.4.4-rcu/fs/select.c Fri May 4 14:06:39 2001
@@ -260,7 +260,7 @@
fd_set_bits fds;
char *bits;
long timeout;
- int ret, size;
+ int ret, size, max_fdset;
timeout = MAX_SCHEDULE_TIMEOUT;
if (tvp) {
@@ -285,8 +285,10 @@
if (n < 0)
goto out_nofds;
- if (n > current->files->max_fdset)
- n = current->files->max_fdset;
+ /* max_fdset can increase, so grab it once to avoid race */
+ max_fdset = current->files->max_fdset;
+ if (n > max_fdset)
+ n = max_fdset;
/*
* We need 6 bitmaps (in/out/ex for both incoming and outgoing),
--
Premature optmztion is rt of all evl. --DK
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [PATCH] max_fds race in select().
2001-05-04 4:10 [PATCH] max_fds race in select() Rusty Russell
@ 2001-05-04 4:10 ` Alexander Viro
0 siblings, 0 replies; 2+ messages in thread
From: Alexander Viro @ 2001-05-04 4:10 UTC (permalink / raw)
To: Rusty Russell; +Cc: torvalds, linux-kernel
On Fri, 4 May 2001, Rusty Russell wrote:
> We can end up with the user getting more fds tban they asked for...
>
> Unlikely, but possible,
True. If n is originally greater than ->max_fdset and ->max_fdset
grows between the comparison and assignment. Yuck.
Linus, please apply it - race is narrow, but...
Al
> --- linux-2.4.4-official/fs/select.c Thu Feb 22 14:25:36 2001
> +++ working-2.4.4-rcu/fs/select.c Fri May 4 14:06:39 2001
> @@ -260,7 +260,7 @@
> fd_set_bits fds;
> char *bits;
> long timeout;
> - int ret, size;
> + int ret, size, max_fdset;
>
> timeout = MAX_SCHEDULE_TIMEOUT;
> if (tvp) {
> @@ -285,8 +285,10 @@
> if (n < 0)
> goto out_nofds;
>
> - if (n > current->files->max_fdset)
> - n = current->files->max_fdset;
> + /* max_fdset can increase, so grab it once to avoid race */
> + max_fdset = current->files->max_fdset;
> + if (n > max_fdset)
> + n = max_fdset;
>
> /*
> * We need 6 bitmaps (in/out/ex for both incoming and outgoing),
>
> --
> Premature optmztion is rt of all evl. --DK
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2001-05-04 4:10 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-05-04 4:10 [PATCH] max_fds race in select() Rusty Russell
2001-05-04 4:10 ` Alexander Viro
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®