Re: [PATCH 1/2] open: add close_range()

2019-05-24 Thread Michael Tirado
What I do in ring=non-supervisor is close all fd's while checking against an array of exemptions. if /proc is not mounted I close RLIMIT_NOFILE, if that fails I use a dumb loop to close everything(slooow). This new system call could significantly increase the fallback code, but If you use a range t

Re: [PATCH 1/2] open: add close_range()

2019-05-21 Thread David Howells
Al Viro wrote: > Umm... That's going to be very painful if you dup2() something to MAX_INT and > then run that; roughly 2G iterations of bouncing ->file_lock up and down, > without anything that would yield CPU in process. > > If anything, I would suggest something like > > fd = *start_f

Re: [PATCH 1/2] open: add close_range()

2019-05-21 Thread Rasmus Villemoes
On 21/05/2019 13.34, Christian Brauner wrote: > The performance is striking. For good measure, comparing the following > simple close_all_fds() userspace implementation that is essentially just > glibc's version in [6]: > > static int close_all_fds(void) > { > DIR *dir; > struct d

Re: [PATCH 1/2] open: add close_range()

2019-05-21 Thread Florian Weimer
* Christian Brauner: >> Solaris has an fdwalk function: >> >> >> >> So a different way to implement this would expose a nextfd system call > > Meh. If nextfd() then I would like it to be able to: > - get the nextfd(fd) >= fd