Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp366879pxf; Thu, 11 Mar 2021 06:00:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJyFdN4qbTjPh9h0sOTapALT15o6TOGFoUd4l8WWFjV2LX9L3wbn7feH5IcnDnmV44hUsFH0 X-Received: by 2002:a17:907:3e8b:: with SMTP id hs11mr3169114ejc.117.1615471212793; Thu, 11 Mar 2021 06:00:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615471212; cv=none; d=google.com; s=arc-20160816; b=P99h7LVtRFF2THQ4drDnweY1vbit9oj+9rxyAsBynHRtj/R9dU4hiw8CCzTLQOkY7d K/5lJ6WF+2MN8Gs+Iu3BlXSPYeVy4cJlJUnm2tAtaSGquw+zyVHP/7wl7diygl3pKR+v J7vLXstfC6/zyuKaK7kDvHBSZO4yLLOoHytDfPB0U0f7uXuPvpkCCKMzhGvRqanagOaG drf+bbVEwwkdrKRLe96t6H4Nyz/7gGPud8Z7lnyb70wnNTwB5R7dOVtL3t5nyw2F5dm/ NY65CW8kV8RFhksk79C+uq+POxffIEF9jYH2OJfmmS4RmwH/6SehF3jGYtqD8uq0AGTM tKmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=IwVA9MD69i7zzeIVaDA8v+fpntKkKR+e2DISxwYyVTA=; b=FlWUnthjP6cCnySshGE/I0fMeIjch6wB1SyAOq6Z+Uz3wL/9sg/ezoofhJUeg7Xmyq 4UaA69t4lX264CWBz5VN4PWElTxumua5u3k2lhxUxuYhxNFeGorXpspJbIMCA9ScvnkB 806vCaTFr85nJsf5pI+X+2eyrdvNIx1JG3kAdQ10vHTdtbNMvNEi5AdQCaL4p0kpgl01 /1/SHanmwVjiSWiriKJGyiuW9TxTyLmm2f8HEitaLByp+8wm1/IleMVBEIm9fQWyuhH6 Qqj3kNBHTZN/Iom9QzrKASpJR4+zlldI+DkmclpvGslH8FA33hcuePIXdB1LNXxQSM8S KHng== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g2si1926314edb.398.2021.03.11.05.59.48; Thu, 11 Mar 2021 06:00:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233784AbhCKN6q (ORCPT + 99 others); Thu, 11 Mar 2021 08:58:46 -0500 Received: from mail-pj1-f42.google.com ([209.85.216.42]:40477 "EHLO mail-pj1-f42.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233729AbhCKN6f (ORCPT ); Thu, 11 Mar 2021 08:58:35 -0500 Received: by mail-pj1-f42.google.com with SMTP id a22-20020a17090aa516b02900c1215e9b33so9108305pjq.5 for ; Thu, 11 Mar 2021 05:58:35 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=IwVA9MD69i7zzeIVaDA8v+fpntKkKR+e2DISxwYyVTA=; b=tvu+paATl9o6NpAH07tZ2zZbzn6hny/rCAnK7ZlQMO3FRfHIj1+2eGffa7MtciNxyO M9gxB6FqOS9KSmKUNLCfhQJvE/ZndIFbh6eDTG563sPgrxQylOQGQihHGXSEPugw3B0e RPx+7MkCZHbt7v2McjSU3JqArgGFCEFRRgClt6D5IB7Q5FhyoMnhZYHced1NDAmZ6Tfe RdmDrnBNlmqY/7LfNxx26y32cZqTzZerd0PjJVYVM6/s5jREUsN1GSCMAnGzBy7YMJum Y6vENHV4XO/9aC1jqTbU0I648LQzNnEnjTssxoiLTPJubYwvI9RBB48qJw9R/BBBMIMT h7BQ== X-Gm-Message-State: AOAM5328x/pMeKP5JS4JhZm9pWdjLgA6skywGC9zZsTW4tonE0Ji+2ZN VRk8AoGcpTq56+sEVBUqi5g= X-Received: by 2002:a17:90a:e60b:: with SMTP id j11mr8760472pjy.42.1615471115495; Thu, 11 Mar 2021 05:58:35 -0800 (PST) Received: from 42.do-not-panic.com (42.do-not-panic.com. [157.230.128.187]) by smtp.gmail.com with ESMTPSA id d22sm2207485pfn.25.2021.03.11.05.58.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Mar 2021 05:58:34 -0800 (PST) Received: by 42.do-not-panic.com (Postfix, from userid 1000) id 2D87B4024E; Thu, 11 Mar 2021 13:58:33 +0000 (UTC) Date: Thu, 11 Mar 2021 13:58:33 +0000 From: Luis Chamberlain To: lyl2019@mail.ustc.edu.cn Cc: linux-kernel@vger.kernel.org Subject: Re: Re: [PATCH] lib/test_kmod: Fix a use after free in register_test_dev_kmod Message-ID: <20210311135833.GT4332@42.do-not-panic.com> References: <20210311080246.11635-1-lyl2019@mail.ustc.edu.cn> <20210311130108.GS4332@42.do-not-panic.com> <17bb31cd.cc46.178217c9344.Coremail.lyl2019@mail.ustc.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <17bb31cd.cc46.178217c9344.Coremail.lyl2019@mail.ustc.edu.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 11, 2021 at 09:31:55PM +0800, lyl2019@mail.ustc.edu.cn wrote: > > > > > -----原始邮件----- > > 发件人: "Luis Chamberlain" > > 发送时间: 2021-03-11 21:01:08 (星期四) > > 收件人: "Lv Yunlong" > > 抄送: linux-kernel@vger.kernel.org > > 主题: Re: [PATCH] lib/test_kmod: Fix a use after free in register_test_dev_kmod > > > > On Thu, Mar 11, 2021 at 12:02:46AM -0800, Lv Yunlong wrote: > > > In register_test_dev_kmod, it calls free_test_dev_kmod() to free > > > test_dev. But free_test_dev_kmod() can't set the original pointer > > > test_dev to NULL, because the test_dev was passed by it's value > > > not reference. > > > > Did you actually get a crash or something? If so can you supply the > > actual log? If this is just an observation and you think this is an > > issue, specifying that would help during patch review. > > > > Luis > > > > > Signed-off-by: Lv Yunlong > > > --- > > > lib/test_kmod.c | 2 +- > > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > > > diff --git a/lib/test_kmod.c b/lib/test_kmod.c > > > index 38c250fbace3..aa8a2a563d7e 100644 > > > --- a/lib/test_kmod.c > > > +++ b/lib/test_kmod.c > > > @@ -1124,7 +1124,6 @@ static void free_test_dev_kmod(struct kmod_test_device *test_dev) > > > free_test_dev_info(test_dev); > > > kmod_config_free(test_dev); > > > vfree(test_dev); > > > - test_dev = NULL; > > > } > > > } > > > > > > @@ -1149,6 +1148,7 @@ static struct kmod_test_device *register_test_dev_kmod(void) > > > if (ret) { > > > pr_err("could not register misc device: %d\n", ret); > > > free_test_dev_kmod(test_dev); > > > + test_dev = NULL; > > > goto out; > > > } > > > > > > -- > > > 2.25.1 > > > > > > > > This problem was reported by source code analyzers developed by our Security Lab(Loccs). This should be included in the commit log, please. > We have confirmed this issue before submiting the patch. How was this confirmed exactly. Luis