Received: by 2002:a05:7412:40d:b0:e2:908c:2ebd with SMTP id 13csp224924rdf; Tue, 21 Nov 2023 00:17:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IFt2jfsw/OHTzhwjlBZWoJMC5Oo3/wOJepGn7vqH0QF7iwsoW/qCCzWKDKdEg+rGD7KyNiO X-Received: by 2002:a17:902:d4c9:b0:1c6:21b4:30bb with SMTP id o9-20020a170902d4c900b001c621b430bbmr10001092plg.15.1700554657834; Tue, 21 Nov 2023 00:17:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700554657; cv=none; d=google.com; s=arc-20160816; b=qn20vX6Vgkqtx+NMyoULa1VDVQZUaZZvAXWYXGEUMEstkNZf7AdvfFc846I/ZYwWKU gVEZoQg8EwN1kgZ5SYATVtSbVnLWF++xX2Y/xZmorpJ7DiqooCz3PcPmQitaCzaaeqTC EIS7KtScBdV/ZcEcj+bjVZSDSSvex3OU9ej8ovQg3/HXT5DeS3gtLvmSRzRD7OE3EwQ9 x89u0QyEnBcZQxBHp7CMmhYh1IM1iZvcU8ytGi66qLpSZiw1MNxsPmdS8v/iFgGymZQb sD9ISNSnIAQ8lBhDLy8/IjMYB/L/wIlV5osw46wevq6TUbW+5vQMA+m381ewxtzMPTon kDOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:dlp-filter:cms-type :content-transfer-encoding:date:message-id:in-reply-to:cc:to:from :sender:reply-to:subject:mime-version:dkim-signature:dkim-filter; bh=lr6fW94vxYn0ZDsRpc9SHce8t6pGUFIFeLHRkfVVUXY=; fh=ydkTZ18Pfz/w+NiTguVMPf8ONuE0w1xctBCTdEGu+iA=; b=HcegQWK2nqJ2ZfIrqPVeA+vTHKx8C46XCe2l3VrA4Djo9r0NdOudMUPYEoaOe5xTFn vppH9c9eXLFwoKCGoMQ1M0N7OOdSHMJuUw5zm5DTkTQZNSeQEbH4AjdXgdpmWfbMjbBw qy5jhEtU37erJR6dalU+RbxoW8sVp4xbIVvy736APc98k5qaO6UrRi2iqzsP5KjlEZKI IZ7v/RZ6I+/FgJdEeilL4Gdo8gdwQwKITnJZtBmxVoMNco0fei+RiBKEG5+dSRCJP3J9 rsrtbmwWpm/uCa2CLNWVdTUao5w8xiHqxRcEg+WdjSOYz51Lgaq3OMgFR8MKNw0Tbaa+ awOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d0wk8axY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from agentk.vger.email (agentk.vger.email. [23.128.96.32]) by mx.google.com with ESMTPS id m9-20020a170902db0900b001b8b4330585si10234948plx.510.2023.11.21.00.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 Nov 2023 00:17:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) client-ip=23.128.96.32; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=d0wk8axY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.32 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id 2827980BB3F9; Tue, 21 Nov 2023 00:17:23 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229492AbjKUIRP (ORCPT + 99 others); Tue, 21 Nov 2023 03:17:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229457AbjKUIRN (ORCPT ); Tue, 21 Nov 2023 03:17:13 -0500 Received: from mailout4.samsung.com (mailout4.samsung.com [203.254.224.34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85254E3 for ; Tue, 21 Nov 2023 00:17:08 -0800 (PST) Received: from epcas2p1.samsung.com (unknown [182.195.41.53]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20231121081705epoutp0453fdadda4acaaf876143d2f39847070f~ZlWwhOJU42088620886epoutp04I for ; Tue, 21 Nov 2023 08:17:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20231121081705epoutp0453fdadda4acaaf876143d2f39847070f~ZlWwhOJU42088620886epoutp04I DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1700554625; bh=lr6fW94vxYn0ZDsRpc9SHce8t6pGUFIFeLHRkfVVUXY=; h=Subject:Reply-To:From:To:CC:In-Reply-To:Date:References:From; b=d0wk8axYdNk/C8HWvC4uD6DcuHVulzVW2XsUOVk1zx2gk8uABsN5p5tRrzzXEo6j3 W7C3xq7//PwKrTXQLeHQut+f7E/rD3XSAIZrzeJdrOeoaUqT6wb4dpMBkmP3wT+XbL pzwRZZI7Jum8L+jfEiNEp/kkoduiS5iKEDDzTVb8= Received: from epsnrtp2.localdomain (unknown [182.195.42.163]) by epcas2p1.samsung.com (KnoxPortal) with ESMTP id 20231121081705epcas2p1650b71573632f2feb800ca67d331d56c~ZlWwOxhp81304013040epcas2p1d; Tue, 21 Nov 2023 08:17:05 +0000 (GMT) Received: from epsmges2p3.samsung.com (unknown [182.195.36.99]) by epsnrtp2.localdomain (Postfix) with ESMTP id 4SZHKY0tXJz4x9Pt; Tue, 21 Nov 2023 08:17:05 +0000 (GMT) X-AuditID: b6c32a47-9a3ff70000002726-3d-655c677fcb48 Received: from epcas2p3.samsung.com ( [182.195.41.55]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id 31.3C.10022.F776C556; Tue, 21 Nov 2023 17:17:03 +0900 (KST) Mime-Version: 1.0 Subject: Re: [PATCH v2] nfc: virtual_ncidev: Add variable to check if ndev is running Reply-To: bongsu.jeon@samsung.com Sender: Bongsu Jeon From: Bongsu Jeon To: Nguyen Dinh Phi , Bongsu Jeon , Krzysztof Kozlowski CC: "syzbot+6eb09d75211863f15e3e@syzkaller.appspotmail.com" , "netdev@vger.kernel.org" , "linux-kernel@vger.kernel.org" X-Priority: 3 X-Content-Kind-Code: NORMAL In-Reply-To: <20231121075357.344-1-phind.uet@gmail.com> X-CPGS-Detection: blocking_info_exchange X-Drm-Type: N,general X-Msg-Generator: Mail X-Msg-Type: PERSONAL X-Reply-Demand: N Message-ID: <20231121081703epcms2p2d9573fae7782dac583fa061a170e5885@epcms2p2> Date: Tue, 21 Nov 2023 17:17:03 +0900 X-CMS-MailID: 20231121081703epcms2p2d9573fae7782dac583fa061a170e5885 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" X-Sendblock-Type: AUTO_CONFIDENTIAL CMS-TYPE: 102P X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpgk+LIzCtJLcpLzFFi42LZdljTXLc+PSbVYPE8dYstzZPYLfa+3spu cXnXHDaLYwvELOa9eM1ksXnOHSYHNo+ds+6ye9y5tofNo2/LKkaPmW/VPD5vkgtgjcq2yUhN TEktUkjNS85PycxLt1XyDo53jjc1MzDUNbS0MFdSyEvMTbVVcvEJ0HXLzAHar6RQlphTChQK SCwuVtK3synKLy1JVcjILy6xVUotSMkpMC/QK07MLS7NS9fLSy2xMjQwMDIFKkzIzjjf/Z+1 YAdfxZ/nbxkbGM9xdzFyckgImEjc/vCZsYuRi0NIYAejxPU7d9m7GDk4eAUEJf7uEAapERYI l+js+coIYgsJKEr87zjHBhHXlXjx9yiYzSagLbH2aCMTyBwRgS5GiQsXL7OCOMwCrxkldhxt ZofYxisxo/0pC4QtLbF9+VawqZwC5hJt7WugajQkfizrZYawRSVurn7LDmO/PzafEcIWkWi9 dxaqRlDiwc/dUHEpiU8Pz7CCPCAhkC3xvY8N5AYJgQZGiTtv70Lt1ZeYdm8BmM0r4CtxfOF1 MJtFQFXi/5Y3bBA1LhJd79aDxZkF5CW2v53DDDKTWUBTYv0ufYjxyhJHbkFV8El0HP4L9+GO eU+YIGxVid7mL0ww306e3QJ1pYfEq22b2CYwKs5ChPQsJLtmIexawMi8ilEstaA4Nz212KjA GB65yfm5mxjBSVHLfQfjjLcf9A4xMnEwHmKU4GBWEuHdwh6TKsSbklhZlVqUH19UmpNafIjR FOjLicxSosn5wLScVxJvaGJpYGJmZmhuZGpgriTOe691boqQQHpiSWp2ampBahFMHxMHp1QD k/8sWc3zcjfvfro5af2GvOlWYeKVp+2efZ5kXSvq/mNaxK7Ver/vPzfi2ez539BAwXRbhyJ/ /Jl9+sUnPwtsYY3fcNohYw63NYvoQYlZPyfU/tyafe/q3muRkxNP/2NlmiYh2Ho55Lu7os2p g4USPKf37nuuvsBDb9maddUCG0uc565/zmZwhff9go+XV/g2aFlwCfmJXsk3LzYT+zm3WTM7 4NuMklyDN7veKDQqntJgMouYzxS+LSYjsH6Si+g8mXkTXy/aOk141pk1DzduU9X6bdmwXbWP J3+FvlR0nFfA4usN003yN109E6G55UNm/IWmCWLvRfYVHfvOtsvn1td8n139Rj8n+xzZKtQn cUWJpTgj0VCLuag4EQAzMW80EwQAAA== DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20231121075419epcas2p280fa7111de7f37b46f460b6c61ff7175 References: <20231121075357.344-1-phind.uet@gmail.com> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,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 agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Tue, 21 Nov 2023 00:17:23 -0800 (PST) On 21/11/2023 16:54, Nguyen Dinh Phi wrote: > syzbot reported an memory leak that happens when an skb is add to > send_buff after virtual nci closed. > This patch adds a variable to track if the ndev is running before > handling new skb in send function. > > Signed-off-by: Nguyen Dinh Phi > Reported-by: syzbot+6eb09d75211863f15e3e@syzkaller.appspotmail.com > Closes: https://lore.kernel.org/lkml/00000000000075472b06007df4fb@google.com > --- > V2: > - Remove unused macro. > - Re-adding a line that was removed wrongly. > drivers/nfc/virtual_ncidev.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/nfc/virtual_ncidev.c b/drivers/nfc/virtual_ncidev.c > index b027be0b0b6f..590b038e449e 100644 > --- a/drivers/nfc/virtual_ncidev.c > +++ b/drivers/nfc/virtual_ncidev.c > @@ -26,10 +26,14 @@ struct virtual_nci_dev { > struct mutex mtx; > struct sk_buff *send_buff; > struct wait_queue_head wq; > + bool running; > }; > > static int virtual_nci_open(struct nci_dev *ndev) > { > + struct virtual_nci_dev *vdev = nci_get_drvdata(ndev); > + > + vdev->running = true; > return 0; > } > > @@ -40,6 +44,7 @@ static int virtual_nci_close(struct nci_dev *ndev) > mutex_lock(&vdev->mtx); > kfree_skb(vdev->send_buff); > vdev->send_buff = NULL; > + vdev->running = false; > mutex_unlock(&vdev->mtx); > > return 0; > @@ -50,7 +55,7 @@ static int virtual_nci_send(struct nci_dev *ndev, struct sk_buff *skb) > struct virtual_nci_dev *vdev = nci_get_drvdata(ndev); > > mutex_lock(&vdev->mtx); > - if (vdev->send_buff) { > + if (vdev->send_buff || !vdev->running) { > mutex_unlock(&vdev->mtx); > kfree_skb(skb); > return -1; > -- > 2.39.2 Reviewed-by: Bongsu Jeon Best regards, Bongsu