linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW
@ 2019-04-16 20:31 Arnd Bergmann
  2019-04-16 23:04 ` Deepa Dinamani
  2019-04-17  4:52 ` David Miller
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2019-04-16 20:31 UTC (permalink / raw)
  To: David S. Miller, Eric Dumazet, Willem de Bruijn, Deepa Dinamani,
	Arnd Bergmann
  Cc: Yafang Shao, netdev, linux-kernel

It looks like the new socket options only work correctly
for native execution, but in case of compat mode fall back
to the old behavior as we ignore the 'old_timeval' flag.

Rework so we treat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW the
same way in compat and native 32-bit mode.

Cc: Deepa Dinamani <deepa.kernel@gmail.com>
Fixes: a9beb86ae6e5 ("sock: Add SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---

 net/core/sock.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/core/sock.c b/net/core/sock.c
index dc7c31d66200..1e418c0b3b73 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -348,7 +348,7 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval)
 		tv.tv_usec = ((timeo % HZ) * USEC_PER_SEC) / HZ;
 	}
 
-	if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
+	if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
 		struct old_timeval32 tv32 = { tv.tv_sec, tv.tv_usec };
 		*(struct old_timeval32 *)optval = tv32;
 		return sizeof(tv32);
@@ -372,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool
 {
 	struct __kernel_sock_timeval tv;
 
-	if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
+	if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
 		struct old_timeval32 tv32;
 
 		if (optlen < sizeof(tv32))
-- 
2.20.0


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

* Re: [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW
  2019-04-16 20:31 [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW Arnd Bergmann
@ 2019-04-16 23:04 ` Deepa Dinamani
  2019-04-17  4:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: Deepa Dinamani @ 2019-04-16 23:04 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: David S. Miller, Eric Dumazet, Willem de Bruijn, Yafang Shao,
	Linux Network Devel Mailing List, Linux Kernel Mailing List

Acked-by: Deepa Dinamani <deepa.kernel@gmail.com>

Thanks,
-Deepa

On Tue, Apr 16, 2019 at 1:31 PM Arnd Bergmann <arnd@arndb.de> wrote:
>
> It looks like the new socket options only work correctly
> for native execution, but in case of compat mode fall back
> to the old behavior as we ignore the 'old_timeval' flag.
>
> Rework so we treat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW the
> same way in compat and native 32-bit mode.
>
> Cc: Deepa Dinamani <deepa.kernel@gmail.com>
> Fixes: a9beb86ae6e5 ("sock: Add SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>
>  net/core/sock.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/core/sock.c b/net/core/sock.c
> index dc7c31d66200..1e418c0b3b73 100644
> --- a/net/core/sock.c
> +++ b/net/core/sock.c
> @@ -348,7 +348,7 @@ static int sock_get_timeout(long timeo, void *optval, bool old_timeval)
>                 tv.tv_usec = ((timeo % HZ) * USEC_PER_SEC) / HZ;
>         }
>
> -       if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
> +       if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
>                 struct old_timeval32 tv32 = { tv.tv_sec, tv.tv_usec };
>                 *(struct old_timeval32 *)optval = tv32;
>                 return sizeof(tv32);
> @@ -372,7 +372,7 @@ static int sock_set_timeout(long *timeo_p, char __user *optval, int optlen, bool
>  {
>         struct __kernel_sock_timeval tv;
>
> -       if (in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
> +       if (old_timeval && in_compat_syscall() && !COMPAT_USE_64BIT_TIME) {
>                 struct old_timeval32 tv32;
>
>                 if (optlen < sizeof(tv32))
> --
> 2.20.0
>

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

* Re: [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW
  2019-04-16 20:31 [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW Arnd Bergmann
  2019-04-16 23:04 ` Deepa Dinamani
@ 2019-04-17  4:52 ` David Miller
  1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2019-04-17  4:52 UTC (permalink / raw)
  To: arnd; +Cc: edumazet, willemb, deepa.kernel, laoar.shao, netdev, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>
Date: Tue, 16 Apr 2019 22:31:14 +0200

> It looks like the new socket options only work correctly
> for native execution, but in case of compat mode fall back
> to the old behavior as we ignore the 'old_timeval' flag.
> 
> Rework so we treat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW the
> same way in compat and native 32-bit mode.
> 
> Cc: Deepa Dinamani <deepa.kernel@gmail.com>
> Fixes: a9beb86ae6e5 ("sock: Add SO_RCVTIMEO_NEW and SO_SNDTIMEO_NEW")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Applied, thanks Arnd.

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

end of thread, other threads:[~2019-04-17  4:52 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 20:31 [PATCH net] socket: fix compat SO_RCVTIMEO_NEW/SO_SNDTIMEO_NEW Arnd Bergmann
2019-04-16 23:04 ` Deepa Dinamani
2019-04-17  4:52 ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).