public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sys_poll: Fix negative timeout values for x86 userland on x86_64 kernels
@ 2011-09-17 12:30 Thomas Meyer
  2011-09-17 14:29 ` Eric Dumazet
  2011-09-17 16:49 ` Andi Kleen
  0 siblings, 2 replies; 4+ messages in thread
From: Thomas Meyer @ 2011-09-17 12:30 UTC (permalink / raw)
  To: Andi Kleen, Linux Kernel Mailing List, Eric Dumazet

sizeof(int/long) differs on x86 and x86_64, so provide a compat_sys_poll().

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/x86/ia32/ia32entry.S |    2 +-
 fs/compat.c               |    6 ++++++
 include/linux/compat.h    |    2 ++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 54edb207..30f4116 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -671,7 +671,7 @@ ia32_sys_call_table:
 	.quad sys_getresuid16	/* 165 */
 	.quad sys32_vm86_warning	/* vm86 */ 
 	.quad quiet_ni_syscall	/* query_module */
-	.quad sys_poll
+	.quad compat_sys_poll
 	.quad quiet_ni_syscall /* old nfsservctl */
 	.quad sys_setresgid16	/* 170 */
 	.quad sys_getresgid16
diff --git a/fs/compat.c b/fs/compat.c
index 58b1da4..f176fda 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1621,6 +1621,12 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
 				 sigsetsize);
 }
 
+asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
+				int timeout)
+{
+	return sys_poll(ufds, nfds, timeout);
+}
+
 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
 	unsigned int nfds, struct compat_timespec __user *tsp,
 	const compat_sigset_t __user *sigmask, compat_size_t sigsetsize)
diff --git a/include/linux/compat.h b/include/linux/compat.h
index c6e7523..3bfb30a 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -433,6 +433,8 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
 				    compat_ulong_t __user *exp,
 				    struct compat_timespec __user *tsp,
 				    void __user *sig);
+asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
+				int timeout);
 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
 				 unsigned int nfds,
 				 struct compat_timespec __user *tsp,
-- 
1.7.6



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] sys_poll: Fix negative timeout values for x86 userland on x86_64 kernels
  2011-09-17 12:30 Thomas Meyer
@ 2011-09-17 14:29 ` Eric Dumazet
  2011-09-17 16:49 ` Andi Kleen
  1 sibling, 0 replies; 4+ messages in thread
From: Eric Dumazet @ 2011-09-17 14:29 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: Andi Kleen, Linux Kernel Mailing List

Le samedi 17 septembre 2011 à 14:30 +0200, Thomas Meyer a écrit :
> sizeof(int/long) differs on x86 and x86_64, so provide a compat_sys_poll().
> 

Please provide a more descriptive Changelog, since this is a stable
candidate patch.



> Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
> ---
>  arch/x86/ia32/ia32entry.S |    2 +-
>  fs/compat.c               |    6 ++++++
>  include/linux/compat.h    |    2 ++
>  3 files changed, 9 insertions(+), 1 deletions(-)
> 
> diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
> index 54edb207..30f4116 100644
> --- a/arch/x86/ia32/ia32entry.S
> +++ b/arch/x86/ia32/ia32entry.S
> @@ -671,7 +671,7 @@ ia32_sys_call_table:
>  	.quad sys_getresuid16	/* 165 */
>  	.quad sys32_vm86_warning	/* vm86 */ 
>  	.quad quiet_ni_syscall	/* query_module */
> -	.quad sys_poll
> +	.quad compat_sys_poll
>  	.quad quiet_ni_syscall /* old nfsservctl */
>  	.quad sys_setresgid16	/* 170 */
>  	.quad sys_getresgid16
> diff --git a/fs/compat.c b/fs/compat.c
> index 58b1da4..f176fda 100644
> --- a/fs/compat.c
> +++ b/fs/compat.c
> @@ -1621,6 +1621,12 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
>  				 sigsetsize);
>  }
>  
> +asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
> +				int timeout)
> +{
> +	return sys_poll(ufds, nfds, timeout);
> +}
> +
>  asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
>  	unsigned int nfds, struct compat_timespec __user *tsp,
>  	const compat_sigset_t __user *sigmask, compat_size_t sigsetsize)
> diff --git a/include/linux/compat.h b/include/linux/compat.h
> index c6e7523..3bfb30a 100644
> --- a/include/linux/compat.h
> +++ b/include/linux/compat.h
> @@ -433,6 +433,8 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
>  				    compat_ulong_t __user *exp,
>  				    struct compat_timespec __user *tsp,
>  				    void __user *sig);
> +asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
> +				int timeout);
>  asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
>  				 unsigned int nfds,
>  				 struct compat_timespec __user *tsp,



^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] sys_poll: Fix negative timeout values for x86 userland on x86_64 kernels
  2011-09-17 12:30 Thomas Meyer
  2011-09-17 14:29 ` Eric Dumazet
@ 2011-09-17 16:49 ` Andi Kleen
  1 sibling, 0 replies; 4+ messages in thread
From: Andi Kleen @ 2011-09-17 16:49 UTC (permalink / raw)
  To: Thomas Meyer; +Cc: Andi Kleen, Linux Kernel Mailing List, Eric Dumazet

On Sat, Sep 17, 2011 at 02:30:25PM +0200, Thomas Meyer wrote:
> sizeof(int/long) differs on x86 and x86_64, so provide a compat_sys_poll().

Thanks. Looks good now.

I suspect other architectures using the compat layer need the same change
though. Perhaps send a note to linux-arch@vger.kernel.org

-Andi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] sys_poll: Fix negative timeout values for x86 userland on x86_64 kernels
@ 2011-09-24  8:31 Thomas Meyer
  0 siblings, 0 replies; 4+ messages in thread
From: Thomas Meyer @ 2011-09-24  8:31 UTC (permalink / raw)
  To: Linux Kernel Mailing List, linux-arch, stable

size of 'long' differs on x86 and x86_64. the ia32 emulation calls
directly into the sys_poll() function. when the timeout is set to a negative
value the test for sign will fail in sys_poll as the 64bit register is tested.
the timeout timer will be set to very high value, because of the sign bit.
this is an error as the timer shouldn't get set at all for negative timeout values.

Signed-off-by: Thomas Meyer <thomas@m3y3r.de>
---
 arch/x86/ia32/ia32entry.S |    2 +-
 fs/compat.c               |    6 ++++++
 include/linux/compat.h    |    2 ++
 3 files changed, 9 insertions(+), 1 deletions(-)

diff --git a/arch/x86/ia32/ia32entry.S b/arch/x86/ia32/ia32entry.S
index 54edb207..30f4116 100644
--- a/arch/x86/ia32/ia32entry.S
+++ b/arch/x86/ia32/ia32entry.S
@@ -671,7 +671,7 @@ ia32_sys_call_table:
 	.quad sys_getresuid16	/* 165 */
 	.quad sys32_vm86_warning	/* vm86 */ 
 	.quad quiet_ni_syscall	/* query_module */
-	.quad sys_poll
+	.quad compat_sys_poll
 	.quad quiet_ni_syscall /* old nfsservctl */
 	.quad sys_setresgid16	/* 170 */
 	.quad sys_getresgid16
diff --git a/fs/compat.c b/fs/compat.c
index 58b1da4..232675e 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1550,6 +1550,12 @@ asmlinkage long compat_sys_old_select(struct compat_sel_arg_struct __user *arg)
 				 compat_ptr(a.exp), compat_ptr(a.tvp));
 }
 
+asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
+				int timeout)
+{
+	return sys_poll(ufds, nfds, timeout);
+}
+
 #ifdef HAVE_SET_RESTORE_SIGMASK
 static long do_compat_pselect(int n, compat_ulong_t __user *inp,
 	compat_ulong_t __user *outp, compat_ulong_t __user *exp,
diff --git a/include/linux/compat.h b/include/linux/compat.h
index c6e7523..3bfb30a 100644
--- a/include/linux/compat.h
+++ b/include/linux/compat.h
@@ -433,6 +433,8 @@ asmlinkage long compat_sys_pselect6(int n, compat_ulong_t __user *inp,
 				    compat_ulong_t __user *exp,
 				    struct compat_timespec __user *tsp,
 				    void __user *sig);
+asmlinkage long compat_sys_poll(struct pollfd __user *ufds, unsigned int nfds,
+				int timeout);
 asmlinkage long compat_sys_ppoll(struct pollfd __user *ufds,
 				 unsigned int nfds,
 				 struct compat_timespec __user *tsp,
-- 
1.7.6.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-09-24  8:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-24  8:31 [PATCH] sys_poll: Fix negative timeout values for x86 userland on x86_64 kernels Thomas Meyer
  -- strict thread matches above, loose matches on Subject: below --
2011-09-17 12:30 Thomas Meyer
2011-09-17 14:29 ` Eric Dumazet
2011-09-17 16:49 ` Andi Kleen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox