All of lore.kernel.org
 help / color / mirror / Atom feed
* [MPTCP] Re: [PATCH net] mptcp: explicitly zeros msk fields on clone
@ 2020-07-17 15:30 Paolo Abeni
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2020-07-17 15:30 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 833 bytes --]

On Fri, 2020-07-17 at 17:12 +0200, Paolo Abeni wrote:
> sk_clone_lock() does not set the __GFP_ZERO flag on the
> internal socket allocation, so we must explicitly zero
> all the relevant msk fields, or we could see inconsitent
> socket status leading to unexpected fallback or data
> corruption.

I noticed only after sending this that sk_clone_lock() calls
sock_copy() which in turn copies everything up to prot->obj_size - that
is sizeof(struct mptcp_sock) or sizeof(struct mptcp6_sock) in our
case).

Since the listening socket should always have the relevant fields
cleared this patch is not needed.

There is a caveat: a socket could go through:

 connect(); shutdown(); listen(); 

but I think the correct way to handle the above is clearing properly
the status in listen(), will look at that later

/P

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

* [MPTCP] Re: [PATCH net] mptcp: explicitly zeros msk fields on clone
@ 2020-07-17 16:56 Christoph Paasch
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Paasch @ 2020-07-17 16:56 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1246 bytes --]

On 07/17/20 - 18:19, Paolo Abeni wrote:
> On Fri, 2020-07-17 at 09:11 -0700, Christoph Paasch wrote:
> > On 07/17/20 - 17:30, Paolo Abeni wrote:
> > > On Fri, 2020-07-17 at 17:12 +0200, Paolo Abeni wrote:
> > > > sk_clone_lock() does not set the __GFP_ZERO flag on the
> > > > internal socket allocation, so we must explicitly zero
> > > > all the relevant msk fields, or we could see inconsitent
> > > > socket status leading to unexpected fallback or data
> > > > corruption.
> > > 
> > > I noticed only after sending this that sk_clone_lock() calls
> > > sock_copy() which in turn copies everything up to prot->obj_size - that
> > > is sizeof(struct mptcp_sock) or sizeof(struct mptcp6_sock) in our
> > > case).
> > > 
> > > Since the listening socket should always have the relevant fields
> > > cleared this patch is not needed.
> > > 
> > > There is a caveat: a socket could go through:
> > > 
> > >  connect(); shutdown(); listen(); 
> > 
> > Wouldn't that then go through mptcp_disconnect()? Thus, in the same style as
> > for TCP (tcp_disconnect()), the zeroing can happen in mptcp_disconnect().
> 
> mptcp_disconnect() is never invoked, see comments in protocol.c ;)

I see! Sounds good then.


Christoph

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

* [MPTCP] Re: [PATCH net] mptcp: explicitly zeros msk fields on clone
@ 2020-07-17 16:19 Paolo Abeni
  0 siblings, 0 replies; 4+ messages in thread
From: Paolo Abeni @ 2020-07-17 16:19 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1118 bytes --]

On Fri, 2020-07-17 at 09:11 -0700, Christoph Paasch wrote:
> On 07/17/20 - 17:30, Paolo Abeni wrote:
> > On Fri, 2020-07-17 at 17:12 +0200, Paolo Abeni wrote:
> > > sk_clone_lock() does not set the __GFP_ZERO flag on the
> > > internal socket allocation, so we must explicitly zero
> > > all the relevant msk fields, or we could see inconsitent
> > > socket status leading to unexpected fallback or data
> > > corruption.
> > 
> > I noticed only after sending this that sk_clone_lock() calls
> > sock_copy() which in turn copies everything up to prot->obj_size - that
> > is sizeof(struct mptcp_sock) or sizeof(struct mptcp6_sock) in our
> > case).
> > 
> > Since the listening socket should always have the relevant fields
> > cleared this patch is not needed.
> > 
> > There is a caveat: a socket could go through:
> > 
> >  connect(); shutdown(); listen(); 
> 
> Wouldn't that then go through mptcp_disconnect()? Thus, in the same style as
> for TCP (tcp_disconnect()), the zeroing can happen in mptcp_disconnect().

mptcp_disconnect() is never invoked, see comments in protocol.c ;)

/P

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

* [MPTCP] Re: [PATCH net] mptcp: explicitly zeros msk fields on clone
@ 2020-07-17 16:11 Christoph Paasch
  0 siblings, 0 replies; 4+ messages in thread
From: Christoph Paasch @ 2020-07-17 16:11 UTC (permalink / raw)
  To: mptcp

[-- Attachment #1: Type: text/plain, Size: 1249 bytes --]

On 07/17/20 - 17:30, Paolo Abeni wrote:
> On Fri, 2020-07-17 at 17:12 +0200, Paolo Abeni wrote:
> > sk_clone_lock() does not set the __GFP_ZERO flag on the
> > internal socket allocation, so we must explicitly zero
> > all the relevant msk fields, or we could see inconsitent
> > socket status leading to unexpected fallback or data
> > corruption.
> 
> I noticed only after sending this that sk_clone_lock() calls
> sock_copy() which in turn copies everything up to prot->obj_size - that
> is sizeof(struct mptcp_sock) or sizeof(struct mptcp6_sock) in our
> case).
> 
> Since the listening socket should always have the relevant fields
> cleared this patch is not needed.
> 
> There is a caveat: a socket could go through:
> 
>  connect(); shutdown(); listen(); 

Wouldn't that then go through mptcp_disconnect()? Thus, in the same style as
for TCP (tcp_disconnect()), the zeroing can happen in mptcp_disconnect().


Christoph

> 
> but I think the correct way to handle the above is clearing properly
> the status in listen(), will look at that later
> 
> /P
> _______________________________________________
> mptcp mailing list -- mptcp(a)lists.01.org
> To unsubscribe send an email to mptcp-leave(a)lists.01.org

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

end of thread, other threads:[~2020-07-17 16:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-17 15:30 [MPTCP] Re: [PATCH net] mptcp: explicitly zeros msk fields on clone Paolo Abeni
2020-07-17 16:11 Christoph Paasch
2020-07-17 16:19 Paolo Abeni
2020-07-17 16:56 Christoph Paasch

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.