* [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy.
@ 2021-05-06 18:43 Arjun Roy
2021-05-06 18:50 ` Soheil Hassas Yeganeh
2021-05-06 18:56 ` Eric Dumazet
0 siblings, 2 replies; 4+ messages in thread
From: Arjun Roy @ 2021-05-06 18:43 UTC (permalink / raw)
To: davem, netdev; +Cc: arjunroy, edumazet, soheil
From: Arjun Roy <arjunroy@google.com>
A prior change introduces separate handling for ->msg_control
depending on whether the pointer is a kernel or user pointer. However,
it does not update tcp receive zerocopy (which uses a user pointer),
which can cause faults when the improper mechanism is used.
This patch simply annotates tcp receive zerocopy's use as explicitly
being a user pointer.
Fixes: 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for ->msg_control")
Signed-off-by: Arjun Roy <arjunroy@google.com>
---
net/ipv4/tcp.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
index e14fd0c50c10..f1c1f9e3de72 100644
--- a/net/ipv4/tcp.c
+++ b/net/ipv4/tcp.c
@@ -2039,6 +2039,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk,
(__kernel_size_t)zc->msg_controllen;
cmsg_dummy.msg_flags = in_compat_syscall()
? MSG_CMSG_COMPAT : 0;
+ cmsg_dummy.msg_control_is_user = true;
zc->msg_flags = 0;
if (zc->msg_control == msg_control_addr &&
zc->msg_controllen == cmsg_dummy.msg_controllen) {
--
2.31.1.607.g51e8a6a459-goog
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy.
2021-05-06 18:43 [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy Arjun Roy
@ 2021-05-06 18:50 ` Soheil Hassas Yeganeh
2021-05-06 18:56 ` Eric Dumazet
1 sibling, 0 replies; 4+ messages in thread
From: Soheil Hassas Yeganeh @ 2021-05-06 18:50 UTC (permalink / raw)
To: Arjun Roy; +Cc: David Miller, netdev, Arjun Roy, Eric Dumazet
On Thu, May 6, 2021 at 2:43 PM Arjun Roy <arjunroy.kdev@gmail.com> wrote:
>
> From: Arjun Roy <arjunroy@google.com>
>
> A prior change introduces separate handling for ->msg_control
> depending on whether the pointer is a kernel or user pointer. However,
> it does not update tcp receive zerocopy (which uses a user pointer),
> which can cause faults when the improper mechanism is used.
>
> This patch simply annotates tcp receive zerocopy's use as explicitly
> being a user pointer.
>
> Fixes: 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for ->msg_control")
> Signed-off-by: Arjun Roy <arjunroy@google.com>
Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
Thank you for the fix!
> ---
> net/ipv4/tcp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index e14fd0c50c10..f1c1f9e3de72 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2039,6 +2039,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk,
> (__kernel_size_t)zc->msg_controllen;
> cmsg_dummy.msg_flags = in_compat_syscall()
> ? MSG_CMSG_COMPAT : 0;
> + cmsg_dummy.msg_control_is_user = true;
> zc->msg_flags = 0;
> if (zc->msg_control == msg_control_addr &&
> zc->msg_controllen == cmsg_dummy.msg_controllen) {
> --
> 2.31.1.607.g51e8a6a459-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy.
2021-05-06 18:43 [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy Arjun Roy
2021-05-06 18:50 ` Soheil Hassas Yeganeh
@ 2021-05-06 18:56 ` Eric Dumazet
2021-05-06 19:00 ` Arjun Roy
1 sibling, 1 reply; 4+ messages in thread
From: Eric Dumazet @ 2021-05-06 18:56 UTC (permalink / raw)
To: Arjun Roy; +Cc: David Miller, netdev, Arjun Roy, Soheil Hassas Yeganeh
On Thu, May 6, 2021 at 8:43 PM Arjun Roy <arjunroy.kdev@gmail.com> wrote:
>
> From: Arjun Roy <arjunroy@google.com>
>
> A prior change introduces separate handling for ->msg_control
> depending on whether the pointer is a kernel or user pointer. However,
> it does not update tcp receive zerocopy (which uses a user pointer),
> which can cause faults when the improper mechanism is used.
>
> This patch simply annotates tcp receive zerocopy's use as explicitly
> being a user pointer.
>
> Fixes: 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for ->msg_control")
This Fixes: tag is wrong.
When this commit was merged, tcp_zc_finalize_rx_tstamp() was not yet there.
> Signed-off-by: Arjun Roy <arjunroy@google.com>
> ---
> net/ipv4/tcp.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> index e14fd0c50c10..f1c1f9e3de72 100644
> --- a/net/ipv4/tcp.c
> +++ b/net/ipv4/tcp.c
> @@ -2039,6 +2039,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk,
> (__kernel_size_t)zc->msg_controllen;
> cmsg_dummy.msg_flags = in_compat_syscall()
> ? MSG_CMSG_COMPAT : 0;
> + cmsg_dummy.msg_control_is_user = true;
> zc->msg_flags = 0;
> if (zc->msg_control == msg_control_addr &&
> zc->msg_controllen == cmsg_dummy.msg_controllen) {
> --
> 2.31.1.607.g51e8a6a459-goog
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy.
2021-05-06 18:56 ` Eric Dumazet
@ 2021-05-06 19:00 ` Arjun Roy
0 siblings, 0 replies; 4+ messages in thread
From: Arjun Roy @ 2021-05-06 19:00 UTC (permalink / raw)
To: Eric Dumazet; +Cc: Arjun Roy, David Miller, netdev, Soheil Hassas Yeganeh
On Thu, May 6, 2021 at 11:56 AM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, May 6, 2021 at 8:43 PM Arjun Roy <arjunroy.kdev@gmail.com> wrote:
> >
> > From: Arjun Roy <arjunroy@google.com>
> >
> > A prior change introduces separate handling for ->msg_control
> > depending on whether the pointer is a kernel or user pointer. However,
> > it does not update tcp receive zerocopy (which uses a user pointer),
> > which can cause faults when the improper mechanism is used.
> >
> > This patch simply annotates tcp receive zerocopy's use as explicitly
> > being a user pointer.
> >
> > Fixes: 1f466e1f15cf ("net: cleanly handle kernel vs user buffers for ->msg_control")
>
> This Fixes: tag is wrong.
>
> When this commit was merged, tcp_zc_finalize_rx_tstamp() was not yet there.
>
Makes sense - I'll send out an amended v2 patch that tags
'7eeba1706eba' instead.
-Arjun
> > Signed-off-by: Arjun Roy <arjunroy@google.com>
> > ---
> > net/ipv4/tcp.c | 1 +
> > 1 file changed, 1 insertion(+)
> >
> > diff --git a/net/ipv4/tcp.c b/net/ipv4/tcp.c
> > index e14fd0c50c10..f1c1f9e3de72 100644
> > --- a/net/ipv4/tcp.c
> > +++ b/net/ipv4/tcp.c
> > @@ -2039,6 +2039,7 @@ static void tcp_zc_finalize_rx_tstamp(struct sock *sk,
> > (__kernel_size_t)zc->msg_controllen;
> > cmsg_dummy.msg_flags = in_compat_syscall()
> > ? MSG_CMSG_COMPAT : 0;
> > + cmsg_dummy.msg_control_is_user = true;
> > zc->msg_flags = 0;
> > if (zc->msg_control == msg_control_addr &&
> > zc->msg_controllen == cmsg_dummy.msg_controllen) {
> > --
> > 2.31.1.607.g51e8a6a459-goog
> >
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-05-06 19:00 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-05-06 18:43 [net] tcp: Specify cmsgbuf is user pointer for receive zerocopy Arjun Roy
2021-05-06 18:50 ` Soheil Hassas Yeganeh
2021-05-06 18:56 ` Eric Dumazet
2021-05-06 19:00 ` Arjun Roy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox