Skip to content

Commit b8adb69

Browse files
Paolo Abenidavem330
authored andcommitted
mptcp: fix lockless access in subflow ULP diag
Since the introduction of the subflow ULP diag interface, the dump callback accessed all the subflow data with lockless. We need either to annotate all the read and write operation accordingly, or acquire the subflow socket lock. Let's do latter, even if slower, to avoid a diffstat havoc. Fixes: 5147dfb ("mptcp: allow dumping subflow context to userspace") Cc: [email protected] Signed-off-by: Paolo Abeni <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Signed-off-by: Matthieu Baerts (NGI0) <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 584f389 commit b8adb69

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

include/net/tcp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@ struct tcp_ulp_ops {
25062506
/* cleanup ulp */
25072507
void (*release)(struct sock *sk);
25082508
/* diagnostic */
2509-
int (*get_info)(const struct sock *sk, struct sk_buff *skb);
2509+
int (*get_info)(struct sock *sk, struct sk_buff *skb);
25102510
size_t (*get_info_size)(const struct sock *sk);
25112511
/* clone ulp */
25122512
void (*clone)(const struct request_sock *req, struct sock *newsk,

net/mptcp/diag.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,19 @@
1313
#include <uapi/linux/mptcp.h>
1414
#include "protocol.h"
1515

16-
static int subflow_get_info(const struct sock *sk, struct sk_buff *skb)
16+
static int subflow_get_info(struct sock *sk, struct sk_buff *skb)
1717
{
1818
struct mptcp_subflow_context *sf;
1919
struct nlattr *start;
2020
u32 flags = 0;
21+
bool slow;
2122
int err;
2223

2324
start = nla_nest_start_noflag(skb, INET_ULP_INFO_MPTCP);
2425
if (!start)
2526
return -EMSGSIZE;
2627

28+
slow = lock_sock_fast(sk);
2729
rcu_read_lock();
2830
sf = rcu_dereference(inet_csk(sk)->icsk_ulp_data);
2931
if (!sf) {
@@ -69,11 +71,13 @@ static int subflow_get_info(const struct sock *sk, struct sk_buff *skb)
6971
}
7072

7173
rcu_read_unlock();
74+
unlock_sock_fast(sk, slow);
7275
nla_nest_end(skb, start);
7376
return 0;
7477

7578
nla_failure:
7679
rcu_read_unlock();
80+
unlock_sock_fast(sk, slow);
7781
nla_nest_cancel(skb, start);
7882
return err;
7983
}

net/tls/tls_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ static u16 tls_user_config(struct tls_context *ctx, bool tx)
10031003
return 0;
10041004
}
10051005

1006-
static int tls_get_info(const struct sock *sk, struct sk_buff *skb)
1006+
static int tls_get_info(struct sock *sk, struct sk_buff *skb)
10071007
{
10081008
u16 version, cipher_type;
10091009
struct tls_context *ctx;

0 commit comments

Comments
 (0)