sys_poll(): fix function definition/negative timeout values
PATCH 1/1 sys_poll(): fix function definition/negative timeout values
Fix negative timeout values for x86 userland on x86_64 kernels. Align sys_poll() definition to glibc's definition.
--- fs/select.c | 2 +- include/linux/syscalls.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-)
fs/select.c +1 -1
@@ -912,7 +912,7 @@ static long do_restart_poll(struct restart_block *restart_block) } SYSCALL_DEFINE3(poll, struct pollfd __user *, ufds, unsigned int, nfds, - long, timeout_msecs) + int, timeout_msecs) {struct timespec end_time, *to =NULL ;int ret;
include/linux/syscalls.h +1 -1
@@ -624,7 +624,7 @@ asmlinkage long sys_socketpair(int, int, int, int __user *);asmlinkage long sys_socketcall (int call,unsigned long __user *args);asmlinkage long sys_listen (int ,int );asmlinkage long sys_poll (struct pollfd __user *ufds,unsigned int nfds, -long timeout); +int timeout);asmlinkage long sys_select (int n,fd_set __user *inp,fd_set __user *outp,fd_set __user *exp,struct timeval __user *tvp);asmlinkage long sys_old_select (struct sel_arg_struct __user *arg);
Signature · 1 line
1.7.6.2
Quoted 2 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.
Nack. Please write a compat wrapper that sign extends.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only
Quoted 7 lines · Andi Kleen
Quoted 2 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.Nack. Please write a compat wrapper that sign extends.
Why ?
man poll
int poll(struct pollfd *ufds, unsigned int nfds, int delay);
Quoted 10 lines · Eric Dumazet
Quoted 7 lines · Andi Kleen
Quoted 2 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.Nack. Please write a compat wrapper that sign extends.
Why ?
Because we shouldn't change existing interfaces and there could be valid reasons on 64bit for really long delays.
-Andi
Signature · 1 line
[email protected] -- Speaking for myself only.
Quoted 7 lines · Andi Kleen
Quoted 6 lines · Eric Dumazet
Quoted 5 lines · Andi Kleen
Quoted 2 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Nack. Please write a compat wrapper that sign extends.
Why ?
Because we shouldn't change existing interfaces and there could be valid reasons on 64bit for really long delays.
I disagree.
Existing interface and POSIX mandates "int delay"
The kernel part of the contract was fine when we supported 32bit only machines, by chance, because sizeof(int) == sizeof(long).
If you want more than 31 bits delay, then we need a new interface, and this new interface must also work on 32bit arches (sort of poll64())
Quoted 18 lines · On Thu, 15 Sep 2011 20:21:02 +0200 Eric Dumazet <[email protected]> wrote:
Le jeudi 15 septembre 2011 __ 20:12 +0200, Andi Kleen a
__crit:Quoted 7 lines · Eric Dumazet
Quoted 6 lines
Le jeudi 15 septembre 2011 __ 10:47 -0700, Andi Kleen a
__crit:Quoted 5 lines
Quoted 2 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Nack. Please write a compat wrapper that sign extends.
Why ?
Because we shouldn't change existing interfaces and there could be valid reasons on 64bit for really long delays.
I disagree.
Quoted 7 lines
Existing interface and POSIX mandates "int delay"
The kernel part of the contract was fine when we supported 32bit only machines, by chance, because sizeof(int) == sizeof(long).
If you want more than 31 bits delay, then we need a new interface, and this new interface must also work on 32bit arches (sort of
poll64())
So what's happening here?
If the change will break (or alter) existing code which does
poll(..., something_greater_than_2g)
then I don't think we can apply the patch. There may be code out there which breaks, there may not be. We don't know. We screwed up, we get to wear the cost of having done so.
fs/select.c static long do_restart_poll(struct restart_block *restart_block) · line 915
Quoted 5 lines · Thomas Meyer
Fix negative timeout values for x86 userland on
x86_64kernels. Alignsys_poll()definition to glibc's definition.fs/select.c +1
-1- long, timeout_msecs) + int, timeout_msecs)
Is this going to surprise a non-glibc userspace on any platforms?