@@ -50,7 +50,7 @@ struct fou_net {
50
50
51
51
static inline struct fou * fou_from_sock (struct sock * sk )
52
52
{
53
- return sk -> sk_user_data ;
53
+ return rcu_dereference_sk_user_data ( sk ) ;
54
54
}
55
55
56
56
static 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,
233
233
struct sk_buff * skb )
234
234
{
235
235
const struct net_offload __rcu * * offloads ;
236
- u8 proto = fou_from_sock (sk )-> protocol ;
236
+ struct fou * fou = fou_from_sock (sk );
237
237
const struct net_offload * ops ;
238
238
struct sk_buff * pp = NULL ;
239
+ u8 proto ;
240
+
241
+ if (!fou )
242
+ goto out ;
243
+
244
+ proto = fou -> protocol ;
239
245
240
246
/* We can clear the encap_mark for FOU as we are essentially doing
241
247
* 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,
263
269
int nhoff )
264
270
{
265
271
const struct net_offload __rcu * * offloads ;
266
- u8 proto = fou_from_sock (sk )-> protocol ;
272
+ struct fou * fou = fou_from_sock (sk );
267
273
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 ;
269
283
270
284
offloads = NAPI_GRO_CB (skb )-> is_ipv6 ? inet6_offloads : inet_offloads ;
271
285
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 ;
273
288
goto out ;
289
+ }
274
290
275
291
err = ops -> callbacks .gro_complete (skb , nhoff );
276
292
@@ -320,6 +336,9 @@ static struct sk_buff *gue_gro_receive(struct sock *sk,
320
336
struct gro_remcsum grc ;
321
337
u8 proto ;
322
338
339
+ if (!fou )
340
+ goto out ;
341
+
323
342
skb_gro_remcsum_init (& grc );
324
343
325
344
off = skb_gro_offset (skb );
0 commit comments