Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-24 Thread Guillaume Nault
On Wed, Apr 24, 2019 at 11:29:25AM -0700, Eric Dumazet wrote: > On Wed, Apr 24, 2019 at 11:21 AM Guillaume Nault wrote: > > > > > And then, we'd need to make sure that ->sk_user_data is in sync with > > the encap_rcv() callback (or whatever actually uses the data pointed > > to). Otherwise a modu

Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-24 Thread Eric Dumazet
On Wed, Apr 24, 2019 at 11:21 AM Guillaume Nault wrote: > It seems that callers of rcu_assign_sk_user_data() can indeed sleep. > > But I think we have more problems. Not all code paths treat > ->sk_user_data as RCU pointers (IIUC that's why we created the > __sk_user_data() macro, instead of just

Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-24 Thread Guillaume Nault
On Wed, Apr 24, 2019 at 04:33:47AM -0700, Eric Dumazet wrote: > On Wed, Apr 24, 2019 at 2:58 AM Guillaume Nault wrote: > > > > On Tue, Apr 23, 2019 at 09:43:26AM -0700, Eric Dumazet wrote: > > > Canonical way to fetch sk_user_data from an encap_rcv() handler called > > > from UDP stack in rcu prot

Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-24 Thread Eric Dumazet
On Wed, Apr 24, 2019 at 2:58 AM Guillaume Nault wrote: > > On Tue, Apr 23, 2019 at 09:43:26AM -0700, Eric Dumazet wrote: > > Canonical way to fetch sk_user_data from an encap_rcv() handler called > > from UDP stack in rcu protected section is to use > > rcu_dereference_sk_user_data(), > > otherwi

Re: [PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-24 Thread Guillaume Nault
On Tue, Apr 23, 2019 at 09:43:26AM -0700, Eric Dumazet wrote: > Canonical way to fetch sk_user_data from an encap_rcv() handler called > from UDP stack in rcu protected section is to use > rcu_dereference_sk_user_data(), > otherwise compiler might read it multiple times. > That reminds me the mor

[PATCH net] l2tp: use rcu_dereference_sk_user_data() in l2tp_udp_encap_recv()

2019-04-23 Thread Eric Dumazet
Canonical way to fetch sk_user_data from an encap_rcv() handler called from UDP stack in rcu protected section is to use rcu_dereference_sk_user_data(), otherwise compiler might read it multiple times. Fixes: d00fa9adc528 ("il2tp: fix races with tunnel socket close") Signed-off-by: Eric Dumazet