lkml.org 
[lkml]   [2001]   [May]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] max_fds race in select().


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
>

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 12:52    [W:0.042 / U:0.164 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site