[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.64.0706070842010.6059@alien.or.mcafeemobile.com>
Date: Thu, 7 Jun 2007 08:42:29 -0700 (PDT)
From: Davide Libenzi <davidel@...ilserver.org>
To: Eric Dumazet <dada1@...mosbay.com>
cc: Linux Kernel Mailing List <linux-kernel@...r.kernel.org>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Andrew Morton <akpm@...ux-foundation.org>,
Ulrich Drepper <drepper@...hat.com>,
Ingo Molnar <mingo@...e.hu>
Subject: Re: [patch 7/8] fdmap v2 - implement sys_socket2
On Thu, 7 Jun 2007, Eric Dumazet wrote:
> Davide Libenzi <davidel@...ilserver.org> wrote:
>
> > The sys_accept() system call has been modified to return a file
> > descriptor inside the non-sequential area, if the listening fd is.
>
> > - newfd = sock_alloc_fd(&newfile);
> > + newfd = sock_alloc_fd(&newfile,
> > + fd > current->signal->rlim[RLIMIT_NOFILE].rlim_cur ? O_NONSEQFD: 0);
>
> This will break apps that change/downgrade their rlimit (after getting a high fd listen socket)
> Yes probably insane, but who knows...
>
> sock = socket(...);
> bind(...);
> listen(sock, backlog); ...
> fd = dup2(sock, 1023);
> close(sock);
>
> setrlimit( RLIMIT_NOFILE, rlim.rlim_cur = 256);
> ...
> while ((newsock = accept(fd, ...)) != -1) {
> fork();...
> Plain legacy code, expecting newsock being *small*
> FD_SET(newsock , &rd_set);
> ...oops... fd is too large to fit in fd_set
> select(newsock + 1, &rd_set, ...);
> }
>
>
> So you might change logic to straight :
>
> newfd = sock_alloc_fd(&newfile, (fd >= FDMAP_NONSEQ_BASE) ? O_NONSEQFD: 0);
Yes, that makes perfectly sense to me.
- Davide
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists