Received: by 2002:ab2:1689:0:b0:1f7:5705:b850 with SMTP id d9csp2103786lqa; Tue, 30 Apr 2024 08:15:13 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVojiQdKZfy3Z9UhwXbyif/SMipPozypLL+Ug8sQhSUjtSDh0pb2Imm90pBqni5y1qDyjlTH9uyYj/iyhW8yxOPPI9GzTP0u7T6BdDbbg== X-Google-Smtp-Source: AGHT+IEZ/pRRMbxIRoy/qgtlWOitsYO8fBVsHvVORCP4v7CDRcM+Z62wh+OlpNR+F5FTAtRz4s0M X-Received: by 2002:a05:6102:224c:b0:47a:411d:60e with SMTP id e12-20020a056102224c00b0047a411d060emr155965vsb.7.1714490113385; Tue, 30 Apr 2024 08:15:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1714490113; cv=pass; d=google.com; s=arc-20160816; b=mEPBxfwUbwuc+1dCBE8G8koqQEM0JK4hK8rArZA0AHXDJYssKW51yKnqTTIUEcN5iF +JmKYglggFPQyvZQYZSBVAYxwY8fyoIygUPQai5SGMJfTEdQSTpnmKmZb0Xf6r+mK0Hf Xv+1c9NMn57qfLpZSkhPBZvB00KabK++OfKCySX8X9JQ/kKcQ8Gep7ZScRgq5U3IdKJ+ ylDeeBfZ5JPjEFxHpQKZQNkwGcGKD20RgLaOHyqLts1/EfiVG+Le2BZ/cC1VK3XFFoVU 4kgtqN5nuHF0LxPYdeNLI937OILd48o3T0sHfUFE3rY6RzD0/O0INbb1HPuFSUyw6NHD gBHg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=user-agent:in-reply-to:content-disposition:mime-version :list-unsubscribe:list-subscribe:list-id:precedence:references :message-id:subject:cc:to:from:date:dkim-signature; bh=Qj+NJgrctHbYKvlDUtiq5+hS/4hqbk09ePj0poTKl4I=; fh=aSQYDYRmEvYxLo18tDzWiNO28TSysdvRYHqy6werw/8=; b=l7HVhoFxwriKBoJVLYA67OZYdYx3AAg8He7OluXa1iDW7KqzKfQlvwyzRrfR/f07bP bblD1F5+hEwSXONZyBwW68b2wKslkEBQDaMqA2ZFetJRJfmCzq04PH9Pal7t3J2LW2vC qXU5Z1cL/Sc+VqG2utdrUx4T37Ub7TpKNLYvX5j+j/Te1pyIH31MYSbH3yhh0MpORpdp FgskRT7LmpIfA1Dy2dwODJRxjo1sylJwKEgZw0KdVcA7xtvmUVKm5yJTW/Umg1KWKOZY bP0ccShLYynJ6cf/Z2W4fJo9IsyYozh2gLTYBbpCJ1JJA043WlpAwOjp3lX0M03aeOoy w+og==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=dJxwK9o4; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-164240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id v19-20020a056102331300b0047c0498e1b1si3345057vsc.40.2024.04.30.08.15.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 08:15:13 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-164240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.com header.s=google header.b=dJxwK9o4; arc=pass (i=1 spf=pass spfdomain=suse.com dkim=pass dkdomain=suse.com dmarc=pass fromdomain=suse.com); spf=pass (google.com: domain of linux-kernel+bounces-164240-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-164240-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=suse.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0D7AD1C22672 for ; Tue, 30 Apr 2024 15:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 49C8C143736; Tue, 30 Apr 2024 15:15:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b="dJxwK9o4" Received: from mail-lj1-f177.google.com (mail-lj1-f177.google.com [209.85.208.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 24B8C13D275 for ; Tue, 30 Apr 2024 15:14:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490102; cv=none; b=SjNX7hDJCI4Z21TBN41J5YrSEZdbkANiKA7+fxvQZP/+upDTT/dmah1N2/o0r0KkfoflqNE3MoMfa8I6tugYodKpkwO3kTEGi4HHf0OXSLZwbBciyksj47QDawD0+NmsO18uPwS6t9vGvm56LmIhlajfsrZLiTs0MwI/Mf0Aw+4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1714490102; c=relaxed/simple; bh=0q9JnC7AtHArcwRchYNVC63YijyWNbpeWNfZqlO+Gqo=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=p/EpEmjnkOR2vvlixvF8jKsdXV1Bk59o/No61lMgAngdA56KeWuCqFvtsqPqbPDHeo8A+gP6TCN6SvTAepdh8XwO0D8FaLoM/3IHS4MkuwH1u6Ns1aCZ/FIDYrZKxliPDDo2iLwtQWJAWT4jwr5x+WQ1xeEkOuuCEfqbBdg+wV4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; dkim=pass (2048-bit key) header.d=suse.com header.i=@suse.com header.b=dJxwK9o4; arc=none smtp.client-ip=209.85.208.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: by mail-lj1-f177.google.com with SMTP id 38308e7fff4ca-2e0933d3b5fso24612561fa.2 for ; Tue, 30 Apr 2024 08:14:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=google; t=1714490098; x=1715094898; darn=vger.kernel.org; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:from:to:cc:subject:date :message-id:reply-to; bh=Qj+NJgrctHbYKvlDUtiq5+hS/4hqbk09ePj0poTKl4I=; b=dJxwK9o41dg19i796kwWa4WUkhpF0SkvnQjcKBwEH6fXJjy6lj25JBKPmcPb/IE9oB k0fKQ50jwzLec7v6GAbiL30/J3y2JkGs5EXLzDRe8Jo26RuMuVH8Bk7+MIwgqN6rKdty QLZlwKS2y1uwUy7nNzOdFW0+SQ53Qn07z3QpBbd2/ujTw1ibIPOyGwnRT7D22IGnlBie y/jahfJbfFjgiQcahfyH8rIAeIV1dB1A03GF8CpiYXPurO5SU5B3jTNl7xM9Tk/wRJFR PssLVSrisJs6v45O/gnigWhIs2ECW1JSEyz5lpjMcmOEVqilu2ETmj96Yw2Skdhge5IW h9Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714490098; x=1715094898; h=user-agent:in-reply-to:content-disposition:mime-version:references :message-id:subject:cc:to:from:date:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Qj+NJgrctHbYKvlDUtiq5+hS/4hqbk09ePj0poTKl4I=; b=kX/FUWoBt9JQ0txtAxcO4u29M7onzNoDGBHxFoR7Tu/ss+7bEjy6yXTVMXsyAtuVUg EXpKCm0AiIIMklsorsULomwxxvuqUq3tZPwaCDQEa0YxaNPWIyX8iT3dreth5lL2SBSg q/fcFkLTHqyE38Tn3X2zGCEQ80r3d0zivMLJmLEONzZRWcpNScH3ui0X2NLgGM6jtNZ/ mpcmX0I4bgDSvtyjbXLiP+On2SG/jSJC1PhmmuifOQ6d/VpTC7iw8+gcteC0G2uuNHBd MfQJju/eqpkdNttW1Z8uMrQ2W7Xj3Oj3H5f6ZmgK/7cY+U89Hj/LLx8llN+LGAQx4cDb cgHA== X-Forwarded-Encrypted: i=1; AJvYcCUpjnLQ6TZ0Prr1V0df4IJuF4U6cAjk59v8w2LEmDJFWDy+3nqiUVQTL/e36kUTUbWSBeHVXa7OJHOrmMMK28OTpdEhWWAdsUXP4JQW X-Gm-Message-State: AOJu0YyXORxSUvA7wh5KlBP4HV05uoltRU6wib95H4WMM/nJc/iP6DEf X79/dIr404dw4tBj9Q2qBgWuSs24cXTGhRz5O7db0nRAad2fq42TJ+SZKb0PuI4= X-Received: by 2002:a2e:900e:0:b0:2e0:3132:94d4 with SMTP id h14-20020a2e900e000000b002e0313294d4mr18367ljg.16.1714490097887; Tue, 30 Apr 2024 08:14:57 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id o15-20020a170902d4cf00b001eb53dcf458sm6601555plg.188.2024.04.30.08.14.55 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2024 08:14:57 -0700 (PDT) Date: Tue, 30 Apr 2024 23:14:49 +0800 From: joeyli To: "Lee, Chun-Yi" Cc: Justin Sanders , Jens Axboe , Pavel Emelianov , Kirill Korotaev , "David S . Miller" , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] aoe: fix the potential use-after-free problem in more places Message-ID: <20240430151449.GM26307@linux-l9pv.suse> References: <20240410134858.6313-1-jlee@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240410134858.6313-1-jlee@suse.com> User-Agent: Mutt/1.11.4 (2019-03-13) Hi Justin, On Wed, Apr 10, 2024 at 09:48:58PM +0800, Lee, Chun-Yi wrote: > From: Chun-Yi Lee > > For fixing CVE-2023-6270, f98364e92662 patch moved dev_put() from > aoecmd_cfg_pkts() to tx() to avoid that the tx() runs into use-after-free. > > But Nicolai Stange found more places in aoe have potential use-after-free > problem with tx(). e.g. revalidate(), aoecmd_ata_rw(), resend(), probe() > and aoecmd_cfg_rsp(). Those functions also use aoenet_xmit() to push > packet to tx queue. So they should also use dev_hold() to increase the > refcnt of skb->dev. > > This patch adds dev_hold() to those functions and also uses dev_put() > when the skb_clone() returns NULL. > > Link: https://nvd.nist.gov/vuln/detail/CVE-2023-6270 > Fixes: f98364e92662 ("aoe: fix the potential use-after-free problem in > aoecmd_cfg_pkts") > Reported-by: Nicolai Stange > Signed-off-by: Chun-Yi Lee Do you have any suggestion for this patch? or I missed anything? Thanks a lot! Joey Lee > --- > drivers/block/aoe/aoecmd.c | 15 ++++++++++++--- > 1 file changed, 12 insertions(+), 3 deletions(-) > > diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c > index cc9077b588d7..fcedbad8e3be 100644 > --- a/drivers/block/aoe/aoecmd.c > +++ b/drivers/block/aoe/aoecmd.c > @@ -361,6 +361,7 @@ ata_rw_frameinit(struct frame *f) > } > > ah->cmdstat = ATA_CMD_PIO_READ | writebit | extbit; > + dev_hold(t->ifp->nd); > skb->dev = t->ifp->nd; > } > > @@ -401,7 +402,8 @@ aoecmd_ata_rw(struct aoedev *d) > __skb_queue_head_init(&queue); > __skb_queue_tail(&queue, skb); > aoenet_xmit(&queue); > - } > + } else > + dev_put(f->t->ifp->nd); > return 1; > } > > @@ -483,10 +485,13 @@ resend(struct aoedev *d, struct frame *f) > memcpy(h->dst, t->addr, sizeof h->dst); > memcpy(h->src, t->ifp->nd->dev_addr, sizeof h->src); > > + dev_hold(t->ifp->nd); > skb->dev = t->ifp->nd; > skb = skb_clone(skb, GFP_ATOMIC); > - if (skb == NULL) > + if (skb == NULL) { > + dev_put(t->ifp->nd); > return; > + } > f->sent = ktime_get(); > __skb_queue_head_init(&queue); > __skb_queue_tail(&queue, skb); > @@ -617,7 +622,8 @@ probe(struct aoetgt *t) > __skb_queue_head_init(&queue); > __skb_queue_tail(&queue, skb); > aoenet_xmit(&queue); > - } > + } else > + dev_put(f->t->ifp->nd); > } > > static long > @@ -1395,6 +1401,7 @@ aoecmd_ata_id(struct aoedev *d) > ah->cmdstat = ATA_CMD_ID_ATA; > ah->lba3 = 0xa0; > > + dev_hold(t->ifp->nd); > skb->dev = t->ifp->nd; > > d->rttavg = RTTAVG_INIT; > @@ -1404,6 +1411,8 @@ aoecmd_ata_id(struct aoedev *d) > skb = skb_clone(skb, GFP_ATOMIC); > if (skb) > f->sent = ktime_get(); > + else > + dev_put(t->ifp->nd); > > return skb; > } > -- > 2.35.3