Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp37097795rwd; Tue, 11 Jul 2023 09:22:30 -0700 (PDT) X-Google-Smtp-Source: APBJJlHYDRnRJkT+G8cPQTJxdb2COZqv7b8xAl83Pwmg6/Xe3lT9N4lPjKooeQofv0d8A/Mgxmgn X-Received: by 2002:a05:6808:1448:b0:39e:a606:544e with SMTP id x8-20020a056808144800b0039ea606544emr17930275oiv.32.1689092550162; Tue, 11 Jul 2023 09:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689092550; cv=none; d=google.com; s=arc-20160816; b=jSs/TWNN4SnIJuXIKoUGey2xPIDjTNw2yPAGehI2bj05w3KevmltmL8LNG8BOxckqb BoCNcKnEeFzA2nDv9zsC5yu6drRegeoJ1c2jNDS7BnRB3Q3nA08jgStfABaCO1Pf9dtI EzBcWsqVcWbXr8+8PB6aFCwNS3BGqS/cGuzLky+g0YipBiZWfLklG89nw0DKXiB3KdAj hLMiQiXu+WwJFpVjEteQbBFml1ZGc/FhojREK+XiajvnTUxgh/flWOKL6K9mCqoubA33 wL3Bng4J3JL97en+Xs20bgR4sHgNj3amRfjxXRK77eqZuwD3rEu8UyRdbfeoJep58SqN XzSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :to:content-language:subject:cc:user-agent:mime-version:date :message-id:from:dkim-signature; bh=IHgmi2wwFrPjMP5Rxs8KSVDqK1J+qf75UCdExpa0HJo=; fh=KNFGnxgGfLSRtp/Vrd+tXMnB4/SpI4PjIfb7mQMQ84E=; b=odjq1mgPah9Rh14djG+/Kk4/tCGxvS/8XyzXz/vnUe4V+MtobPuSJiXxuWU8qjltIT 2zbfh3W06VDLtFpKSUKK3BBp8BCTB7nruIsM5nUNBk7V+DWDqVX0qhZpIST6CwW5C+zF 2k6lBPRQAJEWnL5J+W0G80A3PEHHiA0cw44PUSjsHYpPt2XCpxtSPLq4m6Ojn1w1a+nx Nbhor5NUG9baU8ylePdMRYa0KfYGEYOu4ar2fvsleKEpdLmCTubF+wBLjbNv4nZFhJPQ 5kcYwohDww+D7tlRwrJr4wcp+tn+6RAGcdNg6E9i2y0NmFHOqmUWawedTolDwGS40c0r ySew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ENDaHJ/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e5-20020a63db05000000b00543c8ad57f1si1600278pgg.67.2023.07.11.09.22.17; Tue, 11 Jul 2023 09:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="ENDaHJ/V"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231537AbjGKQHa (ORCPT + 99 others); Tue, 11 Jul 2023 12:07:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229714AbjGKQH2 (ORCPT ); Tue, 11 Jul 2023 12:07:28 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B418218D for ; Tue, 11 Jul 2023 09:06:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1689091598; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=IHgmi2wwFrPjMP5Rxs8KSVDqK1J+qf75UCdExpa0HJo=; b=ENDaHJ/Vv8mI7uMgKK3FkLa7QEI3A5wQWLon3XqttdV42wVrb9YeO4sR8fMctVSW7c0a+o EqnawonnmLC4jJMKMohvtw9kw8v9BBCivORrOJlQ1nuVPNQ48PByZwdKG6k7CPxKAu99GK GBgTgMokpS/khyRLq6nF70NNf/YffWs= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-308-IciLerx8OkWjHuRDRssX-A-1; Tue, 11 Jul 2023 12:06:37 -0400 X-MC-Unique: IciLerx8OkWjHuRDRssX-A-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-98843cc8980so395445666b.1 for ; Tue, 11 Jul 2023 09:06:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689091596; x=1691683596; h=content-transfer-encoding:in-reply-to:references:to :content-language:subject:cc:user-agent:mime-version:date:message-id :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=IHgmi2wwFrPjMP5Rxs8KSVDqK1J+qf75UCdExpa0HJo=; b=CWV3fgsOH+kzwX8KKtfXgdNIgL27dMA6NjaRyU3GeBddbldUHa0qI79HZTnTmrRx6X y/kqthQ6fy7T2Udo2CNsmlekDgzi488dBbM42hM9NnJGy4OhIstBPGHMsEsaXNof1vkT zAhE8gAYfYUzL2QdoRxyIPwPz/M6gO/AV4gB/TYzV02ODDFg90Jf7/yETdyn6PYYK9Tn +Rlgpup3NibOJjyyOZhkhXv8ibCi4lOaNxpVvYi+peMda5XKMvGgVV4CLuyy160Ljs4s R85RRgn6GgJ0XKmMdLwBnprJ9gXB7+fCobTrZTwC3cKj3O77wvEQwL6LC3BnOWLKJKzb ADvQ== X-Gm-Message-State: ABy/qLYNyIgTlYxS9KFQIk1TBhYUR6ovd1wwzHI4AgcF04FFJEfm875W hvUOOGtFNSfORkVLMPDgUoTMJgBe1OmWdzH3mMN9ePo9Idrp/iuT6DGn1hyhDS8rWdO1IJbwrNL BPI262WsrCwYDOJI1nTtCut4x X-Received: by 2002:a17:906:73d5:b0:994:577:f9df with SMTP id n21-20020a17090673d500b009940577f9dfmr7195370ejl.4.1689091596090; Tue, 11 Jul 2023 09:06:36 -0700 (PDT) X-Received: by 2002:a17:906:73d5:b0:994:577:f9df with SMTP id n21-20020a17090673d500b009940577f9dfmr7195342ejl.4.1689091595649; Tue, 11 Jul 2023 09:06:35 -0700 (PDT) Received: from [192.168.42.100] (194-45-78-10.static.kviknet.net. [194.45.78.10]) by smtp.gmail.com with ESMTPSA id z19-20020a1709060ad300b009934b1eb577sm1340404ejf.77.2023.07.11.09.06.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 11 Jul 2023 09:06:35 -0700 (PDT) From: Jesper Dangaard Brouer X-Google-Original-From: Jesper Dangaard Brouer Message-ID: Date: Tue, 11 Jul 2023 18:06:34 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Cc: brouer@redhat.com, Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , "David S. Miller" , Jakub Kicinski , Jesper Dangaard Brouer , John Fastabend , Martin KaFai Lau , Song Liu , Yonghong Song , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , Xu Kuohai , Pu Lehui Subject: Re: [PATCH bpf] bpf: cpumap: Fix memory leak in cpu_map_update_elem Content-Language: en-US To: Pu Lehui , bpf@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org References: <20230711115848.2701559-1-pulehui@huaweicloud.com> In-Reply-To: <20230711115848.2701559-1-pulehui@huaweicloud.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.2 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_BLOCKED,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 11/07/2023 13.58, Pu Lehui wrote: > From: Pu Lehui > > 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 LGTM, thanks for fixing this. Acked-by: Jesper Dangaard Brouer