diff options
author | Nobuo Iwata <nobuo.iwata@fujixerox.co.jp> | 2016-09-30 01:44:04 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2016-11-07 04:19:49 -0500 |
commit | 220c61b6f73a1d6f28591aeedff51a668068361b (patch) | |
tree | 259dcc6ecf4483505e17dda462f154ecb2a99125 | |
parent | cbfff98a623df8d4e7c02d63d6448220cf0aec7c (diff) |
usbip: deletion of incorrect socket descriptor checking
This patch removes checking of socket descriptor value in daemons.
It was checked to be less than FD_SETSIZE(1024 usually) but it's not
correct.
To be exact, the maximum value of descriptor comes from
rlimit(RLIMIT_NOFILE).
Following kernel code determines the value :
get_unused_fd_flags() : fs/files.c
__alloc_fd() : fs/files.c
expand_files() : fs/files.c
The defalut (soft limit) is defines as INR_OPEN_CUR(1024) in
include/linux/fs.h which is referenced form INIT_RLIMS in
include/asm-generic/resource.h. The value may be modified with ulimt,
sysctl, security configuration and etc.
With the kernel code above, when socket() system call returns positive
value, the value must be within rlimit(RLIMIT_NOFILE). No extra
checking is needed when socket() returns positive.
Without 'usbip: vhci number of ports extension' patch set, there's no
practical problem because of number of USB port restriction. With the
patch set, the value of socket descriptor can exceed FD_SETSIZE(1024
usually) if the rlimit is changed.
Signed-off-by: Nobuo Iwata <nobuo.iwata@fujixerox.co.jp>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | tools/usb/usbip/src/usbipd.c | 7 |
1 files changed, 0 insertions, 7 deletions
diff --git a/tools/usb/usbip/src/usbipd.c b/tools/usb/usbip/src/usbipd.c index a0972dea9e6c..009afb4a3aae 100644 --- a/tools/usb/usbip/src/usbipd.c +++ b/tools/usb/usbip/src/usbipd.c | |||
@@ -398,13 +398,6 @@ static int listen_all_addrinfo(struct addrinfo *ai_head, int sockfdlist[], | |||
398 | * (see do_standalone_mode()) */ | 398 | * (see do_standalone_mode()) */ |
399 | usbip_net_set_v6only(sock); | 399 | usbip_net_set_v6only(sock); |
400 | 400 | ||
401 | if (sock >= FD_SETSIZE) { | ||
402 | err("FD_SETSIZE: %s: sock=%d, max=%d", | ||
403 | ai_buf, sock, FD_SETSIZE); | ||
404 | close(sock); | ||
405 | continue; | ||
406 | } | ||
407 | |||
408 | ret = bind(sock, ai->ai_addr, ai->ai_addrlen); | 401 | ret = bind(sock, ai->ai_addr, ai->ai_addrlen); |
409 | if (ret < 0) { | 402 | if (ret < 0) { |
410 | err("bind: %s: %d (%s)", | 403 | err("bind: %s: %d (%s)", |