Skip to content

Commit

Permalink
mptcp: kmemleak
Browse files Browse the repository at this point in the history
$ sudo cat /sys/kernel/debug/kmemleak
[sudo] password for tgl:
unreferenced object 0xffff8ea0cc49d7e0 (size 96):
  comm "swapper/0", pid 1, jiffies 4294671728
  hex dump (first 32 bytes):
    20 0f ae a5 ff ff ff ff 00 00 00 00 00 00 00 00   ...............
    01 00 00 00 01 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 8d1cb96a):
    [<ffffffffa04ae03d>] __kmalloc+0x37d/0x4d0
    [<ffffffffa060c64c>] __register_sysctl_table+0x4c/0x7d0
    [<ffffffffa43cd2bd>] fsverity_init+0x2d/0x50
    [<ffffffffa0002c01>] do_one_initcall+0x61/0x390
    [<ffffffffa4368aa4>] kernel_init_freeable+0x3a4/0x5b0
    [<ffffffffa184b2ca>] kernel_init+0x1a/0x1c0
    [<ffffffffa0103ef1>] ret_from_fork+0x31/0x50
    [<ffffffffa000387a>] ret_from_fork_asm+0x1a/0x30

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
  • Loading branch information
Geliang Tang committed May 10, 2024
1 parent 50f6009 commit c3a8ba3
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
1 change: 1 addition & 0 deletions net/ipv4/tcp_input.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ static void tcp_measure_rcv_mss(struct sock *sk, const struct sk_buff *skb)
do_div(val, skb->truesize);
tcp_sk(sk)->scaling_ratio = val ? val : 1;
}
pr_info("sk=%p scaling_ratio=%u\n", sk, tcp_sk(sk)->scaling_ratio);
icsk->icsk_ack.rcv_mss = min_t(unsigned int, len,
tcp_sk(sk)->advmss);
/* Account for possibly-removed options */
Expand Down
14 changes: 12 additions & 2 deletions net/mptcp/protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1891,11 +1891,14 @@ static int mptcp_sendmsg(struct sock *sk, struct msghdr *msg, size_t len)
continue;

wait_for_memory:
pr_info("%s wait_for_memory", __func__);
set_bit(SOCK_NOSPACE, &sk->sk_socket->flags);
__mptcp_push_pending(sk, msg->msg_flags);
ret = sk_stream_wait_memory(sk, &timeo);
if (ret)
if (ret) {
pr_info("%s goto do_error ret=%d\n", __func__, ret);
goto do_error;
}
}

if (copied)
Expand Down Expand Up @@ -1976,9 +1979,9 @@ static int __mptcp_recvmsg_mskq(struct mptcp_sock *msk,
*/
static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
{
u8 scaling_ratio = TCP_DEFAULT_SCALING_RATIO;
struct mptcp_subflow_context *subflow;
struct sock *sk = (struct sock *)msk;
u8 scaling_ratio = U8_MAX;
u32 time, advmss = 1;
u64 rtt_us, mstamp;

Expand All @@ -2002,9 +2005,11 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
rtt_us = 0;
mptcp_for_each_subflow(msk, subflow) {
const struct tcp_sock *tp;
struct sock *ssk;
u64 sf_rtt_us;
u32 sf_advmss;

ssk = mptcp_subflow_tcp_sock(subflow);
tp = tcp_sk(mptcp_subflow_tcp_sock(subflow));

sf_rtt_us = READ_ONCE(tp->rcv_rtt_est.rtt_us);
Expand All @@ -2013,10 +2018,12 @@ static void mptcp_rcv_space_adjust(struct mptcp_sock *msk, int copied)
rtt_us = max(sf_rtt_us, rtt_us);
advmss = max(sf_advmss, advmss);
scaling_ratio = min(tp->scaling_ratio, scaling_ratio);
pr_info("ssk=%p scaling_ratio=%u, tp->scaling_ratio=%u state=%u\n", ssk, scaling_ratio, tp->scaling_ratio, inet_sk_state_load(ssk));
}

msk->rcvq_space.rtt_us = rtt_us;
msk->scaling_ratio = scaling_ratio;
pr_info("msk->scaling_ratio=%u\n", msk->scaling_ratio);
if (time < (rtt_us >> 3) || rtt_us == 0)
return;

Expand Down Expand Up @@ -2231,6 +2238,7 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
}

if (!timeo) {
pr_info("%s EAGAIN", __func__);
copied = -EAGAIN;
break;
}
Expand Down Expand Up @@ -2264,6 +2272,8 @@ static int mptcp_recvmsg(struct sock *sk, struct msghdr *msg, size_t len,
mptcp_rcv_space_adjust(msk, copied);

release_sock(sk);
if (copied == -EAGAIN)
pr_info("%s return EAGAIN", __func__);
return copied;
}

Expand Down

0 comments on commit c3a8ba3

Please sign in to comment.