mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jesper Dangaard Brouer <jbrouer@redhat.com>
To: Pu Lehui <pulehui@huaweicloud.com>,
	bpf@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Cc: brouer@redhat.com, Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	Jesper Dangaard Brouer <hawk@kernel.org>,
	John Fastabend <john.fastabend@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>, Yonghong Song <yhs@fb.com>,
	KP Singh <kpsingh@kernel.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Jiri Olsa <jolsa@kernel.org>, Xu Kuohai <xukuohai@huawei.com>,
	Pu Lehui <pulehui@huawei.com>
Subject: Re: [PATCH bpf] bpf: cpumap: Fix memory leak in cpu_map_update_elem
Date: Tue, 11 Jul 2023 18:06:34 +0200	[thread overview]
Message-ID: <da7ac0a1-5f62-bc0e-8954-d3d1e846fb52@redhat.com> (raw)
In-Reply-To: <20230711115848.2701559-1-pulehui@huaweicloud.com>


On 11/07/2023 13.58, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
> 
> Syzkaller reported a memory leak as follows:
> 
[...]>
> In the cpu_map_update_elem flow, when kthread_stop is called before
> calling the threadfn of rcpu->kthread, since the KTHREAD_SHOULD_STOP bit
> of kthread has been set by kthread_stop, the threadfn of rcpu->kthread
> will never be executed, and rcpu->refcnt will never be 0, which will
> lead to the allocated rcpu, rcpu->queue and rcpu->queue->queue cannot be
> released.
> 
> Calling kthread_stop before executing kthread's threadfn will return
> -EINTR. We can complete the release of memory resources in this state.
> 
> Fixes: 6710e1126934 ("bpf: introduce new bpf cpu map type BPF_MAP_TYPE_CPUMAP")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>

LGTM, thanks for fixing this.

Acked-by: Jesper Dangaard Brouer <hawk@kernel.org>


  reply	other threads:[~2023-07-11 16:07 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-11 11:58 Pu Lehui
2023-07-11 16:06 ` Jesper Dangaard Brouer [this message]
2023-07-12  2:12 ` Hou Tao
2023-07-12  3:04   ` Alexei Starovoitov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=da7ac0a1-5f62-bc0e-8954-d3d1e846fb52@redhat.com \
    --to=jbrouer@redhat.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=brouer@redhat.com \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=haoluo@google.com \
    --cc=hawk@kernel.org \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=netdev@vger.kernel.org \
    --cc=pulehui@huawei.com \
    --cc=pulehui@huaweicloud.com \
    --cc=sdf@google.com \
    --cc=song@kernel.org \
    --cc=xukuohai@huawei.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®