Skip to content

Commit

Permalink
Revert "DO-NOT-MERGE: mptcp: use kmalloc on kasan build (net)"
Browse files Browse the repository at this point in the history
This reverts commit 1859939.

This piece of code was causing issues, see:

  #371 (comment)

It sounds safer to revert it then.

Suggested-by: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Matthieu Baerts <matthieu.baerts@tessares.net>
  • Loading branch information
matttbe committed Apr 5, 2023
1 parent cb5b071 commit 09d6ae5
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 20 deletions.
3 changes: 0 additions & 3 deletions net/ipv4/af_inet.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,10 +312,7 @@ static int inet_create(struct net *net, struct socket *sock, int protocol,
answer_flags = answer->flags;
rcu_read_unlock();

#if !IS_ENABLED(CONFIG_KASAN)
/* with kasan we use kmalloc */
WARN_ON(!answer_prot->slab);
#endif

err = -ENOMEM;
sk = sk_alloc(net, PF_INET, GFP_KERNEL, answer_prot, kern);
Expand Down
3 changes: 0 additions & 3 deletions net/ipv6/af_inet6.c
Original file line number Diff line number Diff line change
Expand Up @@ -186,10 +186,7 @@ static int inet6_create(struct net *net, struct socket *sock, int protocol,
answer_flags = answer->flags;
rcu_read_unlock();

#if !IS_ENABLED(CONFIG_KASAN)
/* with kasan we use kmalloc */
WARN_ON(!answer_prot->slab);
#endif

err = -ENOBUFS;
sk = sk_alloc(net, PF_INET6, GFP_KERNEL, answer_prot, kern);
Expand Down
16 changes: 2 additions & 14 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -2692,10 +2692,6 @@ static int __mptcp_init_sock(struct sock *sk)
timer_setup(&msk->sk.icsk_retransmit_timer, mptcp_retransmit_timer, 0);
timer_setup(&sk->sk_timer, mptcp_timeout_timer, 0);

#if IS_ENABLED(CONFIG_KASAN)
sock_set_flag(sk, SOCK_RCU_FREE);
#endif

return 0;
}

Expand Down Expand Up @@ -3113,9 +3109,7 @@ struct sock *mptcp_sk_clone(const struct sock *sk,
msk->wnd_end = msk->snd_nxt + req->rsk_rcv_wnd;
msk->setsockopt_seq = mptcp_sk(sk)->setsockopt_seq;

#if !IS_ENABLED(CONFIG_KASAN)
sock_reset_flag(nsk, SOCK_RCU_FREE);
#endif
/* will be fully established after successful MPC subflow creation */
inet_sk_state_store(nsk, TCP_SYN_RECV);

Expand Down Expand Up @@ -3880,12 +3874,6 @@ static int mptcp_napi_poll(struct napi_struct *napi, int budget)
return work_done;
}

#if IS_ENABLED(CONFIG_KASAN)
#define MPTCP_USE_SLAB 0
#else
#define MPTCP_USE_SLAB 1
#endif

void __init mptcp_proto_init(void)
{
struct mptcp_delegated_action *delegated;
Expand All @@ -3909,7 +3897,7 @@ void __init mptcp_proto_init(void)
mptcp_pm_init();
mptcp_token_init();

if (proto_register(&mptcp_prot, MPTCP_USE_SLAB) != 0)
if (proto_register(&mptcp_prot, 1) != 0)
panic("Failed to register MPTCP proto.\n");

inet_register_protosw(&mptcp_protosw);
Expand Down Expand Up @@ -3962,7 +3950,7 @@ int __init mptcp_proto_v6_init(void)
mptcp_v6_prot.slab = NULL;
mptcp_v6_prot.obj_size = sizeof(struct mptcp6_sock);

err = proto_register(&mptcp_v6_prot, MPTCP_USE_SLAB);
err = proto_register(&mptcp_v6_prot, 1);
if (err)
return err;

Expand Down

0 comments on commit 09d6ae5

Please sign in to comment.