@@ -50,7 +50,7 @@ struct fou_net {
5050
5151static inline struct fou * fou_from_sock (struct sock * sk )
5252{
53- return sk -> sk_user_data ;
53+ return rcu_dereference_sk_user_data ( sk ) ;
5454}
5555
5656static int fou_recv_pull (struct sk_buff * skb , struct fou * fou , size_t len )
@@ -233,9 +233,15 @@ static struct sk_buff *fou_gro_receive(struct sock *sk,
233233 struct sk_buff * skb )
234234{
235235 const struct net_offload __rcu * * offloads ;
236- u8 proto = fou_from_sock (sk )-> protocol ;
236+ struct fou * fou = fou_from_sock (sk );
237237 const struct net_offload * ops ;
238238 struct sk_buff * pp = NULL ;
239+ u8 proto ;
240+
241+ if (!fou )
242+ goto out ;
243+
244+ proto = fou -> protocol ;
239245
240246 /* We can clear the encap_mark for FOU as we are essentially doing
241247 * one of two possible things. We are either adding an L4 tunnel
@@ -263,14 +269,24 @@ static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
263269 int nhoff )
264270{
265271 const struct net_offload __rcu * * offloads ;
266- u8 proto = fou_from_sock (sk )-> protocol ;
272+ struct fou * fou = fou_from_sock (sk );
267273 const struct net_offload * ops ;
268- int err = - ENOSYS ;
274+ u8 proto ;
275+ int err ;
276+
277+ if (!fou ) {
278+ err = - ENOENT ;
279+ goto out ;
280+ }
281+
282+ proto = fou -> protocol ;
269283
270284 offloads = NAPI_GRO_CB (skb )-> is_ipv6 ? inet6_offloads : inet_offloads ;
271285 ops = rcu_dereference (offloads [proto ]);
272- if (WARN_ON (!ops || !ops -> callbacks .gro_complete ))
286+ if (WARN_ON (!ops || !ops -> callbacks .gro_complete )) {
287+ err = - ENOSYS ;
273288 goto out ;
289+ }
274290
275291 err = ops -> callbacks .gro_complete (skb , nhoff );
276292
@@ -320,6 +336,9 @@ static struct sk_buff *gue_gro_receive(struct sock *sk,
320336 struct gro_remcsum grc ;
321337 u8 proto ;
322338
339+ if (!fou )
340+ goto out ;
341+
323342 skb_gro_remcsum_init (& grc );
324343
325344 off = skb_gro_offset (skb );
0 commit comments