Revert "fou: Fix null-ptr-deref in GRO."

This reverts commit 40621108c5.
This commit is contained in:
Ksawlii 2024-11-24 00:23:41 +01:00
parent 7115e305bd
commit 2099e96665

View file

@ -48,7 +48,7 @@ struct fou_net {
static inline struct fou *fou_from_sock(struct sock *sk)
{
return rcu_dereference_sk_user_data(sk);
return sk->sk_user_data;
}
static int fou_recv_pull(struct sk_buff *skb, struct fou *fou, size_t len)
@ -231,15 +231,9 @@ static struct sk_buff *fou_gro_receive(struct sock *sk,
struct sk_buff *skb)
{
const struct net_offload __rcu **offloads;
struct fou *fou = fou_from_sock(sk);
u8 proto = fou_from_sock(sk)->protocol;
const struct net_offload *ops;
struct sk_buff *pp = NULL;
u8 proto;
if (!fou)
goto out;
proto = fou->protocol;
/* We can clear the encap_mark for FOU as we are essentially doing
* one of two possible things. We are either adding an L4 tunnel
@ -267,24 +261,14 @@ static int fou_gro_complete(struct sock *sk, struct sk_buff *skb,
int nhoff)
{
const struct net_offload __rcu **offloads;
struct fou *fou = fou_from_sock(sk);
u8 proto = fou_from_sock(sk)->protocol;
const struct net_offload *ops;
u8 proto;
int err;
if (!fou) {
err = -ENOENT;
goto out;
}
proto = fou->protocol;
int err = -ENOSYS;
offloads = NAPI_GRO_CB(skb)->is_ipv6 ? inet6_offloads : inet_offloads;
ops = rcu_dereference(offloads[proto]);
if (WARN_ON(!ops || !ops->callbacks.gro_complete)) {
err = -ENOSYS;
if (WARN_ON(!ops || !ops->callbacks.gro_complete))
goto out;
}
err = ops->callbacks.gro_complete(skb, nhoff);
@ -334,9 +318,6 @@ static struct sk_buff *gue_gro_receive(struct sock *sk,
struct gro_remcsum grc;
u8 proto;
if (!fou)
goto out;
skb_gro_remcsum_init(&grc);
off = skb_gro_offset(skb);