Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

flag parameters: paccept w/out set_restore_sigmask

Some platforms do not have support to restore the signal mask in the
return path from a syscall. For those platforms syscalls like pselect are
not defined at all. This is, I think, not a good choice for paccept()
since paccept() adds more value on top of accept() than just the signal
mask handling.

Therefore this patch defines a scaled down version of the sys_paccept
function for those platforms. It returns -EINVAL in case the signal mask
is non-NULL but behaves the same otherwise.

Note that I explicitly included <linux/thread_info.h>. I saw that it is
currently included but indirectly two levels down. There is too much risk
in relying on this. The header might change and then suddenly the
function definition would change without anyone immediately noticing.

Signed-off-by: Ulrich Drepper <drepper@redhat.com>
Cc: Davide Libenzi <davidel@xmailserver.org>
Cc: Michael Kerrisk <mtk.manpages@googlemail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Ulrich Drepper and committed by
Linus Torvalds
c019bbc6 aaca0bdc

+20
+3
include/linux/net.h
··· 102 102 103 103 /* Flags for socket, socketpair, paccept */ 104 104 #define SOCK_CLOEXEC O_CLOEXEC 105 + #ifndef SOCK_NONBLOCK 106 + #define SOCK_NONBLOCK O_NONBLOCK 107 + #endif 105 108 106 109 #endif /* ARCH_HAS_SOCKET_TYPES */ 107 110
+17
net/socket.c
··· 69 69 #include <linux/proc_fs.h> 70 70 #include <linux/seq_file.h> 71 71 #include <linux/mutex.h> 72 + #include <linux/thread_info.h> 72 73 #include <linux/wanrouter.h> 73 74 #include <linux/if_bridge.h> 74 75 #include <linux/if_frad.h> ··· 1505 1504 goto out_put; 1506 1505 } 1507 1506 1507 + #ifdef HAVE_SET_RESTORE_SIGMASK 1508 1508 asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, 1509 1509 int __user *upeer_addrlen, 1510 1510 const sigset_t __user *sigmask, ··· 1543 1541 1544 1542 return ret; 1545 1543 } 1544 + #else 1545 + asmlinkage long sys_paccept(int fd, struct sockaddr __user *upeer_sockaddr, 1546 + int __user *upeer_addrlen, 1547 + const sigset_t __user *sigmask, 1548 + size_t sigsetsize, int flags) 1549 + { 1550 + /* The platform does not support restoring the signal mask in the 1551 + * return path. So we do not allow using paccept() with a signal 1552 + * mask. */ 1553 + if (sigmask) 1554 + return -EINVAL; 1555 + 1556 + return do_accept(fd, upeer_sockaddr, upeer_addrlen, flags); 1557 + } 1558 + #endif 1546 1559 1547 1560 asmlinkage long sys_accept(int fd, struct sockaddr __user *upeer_sockaddr, 1548 1561 int __user *upeer_addrlen)