Received: by 2002:ab2:6a05:0:b0:1f8:1780:a4ed with SMTP id w5csp2758561lqo; Tue, 14 May 2024 08:19:12 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVOuEJ9uuOqw9LMqcBUIZ6S+sEQGffOxI/0pwMOGS0fJ+fnSgXOeau6VuwFnkQJA6ebyKM/yQsdrMopTbqiEZSD3wNV16Kvl9ZGBGqsIg== X-Google-Smtp-Source: AGHT+IGAAnOGFkenZtdtAC2ANbYfftSeSPIMJ82+VMeqSZwdBmBQoBz51QObR/zVzrXEx/NmRYbo X-Received: by 2002:a17:907:3186:b0:a59:ea4f:46b9 with SMTP id a640c23a62f3a-a5a2d675763mr936017166b.77.1715699952433; Tue, 14 May 2024 08:19:12 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715699952; cv=pass; d=google.com; s=arc-20160816; b=rFRiEPwfkFvP1GZX8JPm+6qZZ9yL+CbxnrrKyosOuXoOWFyUVZXUaYAqMN6LNA2Btm FrlA2mPMjqAKBtyHB1hULhnyy8f9wuPsG8/HyI1cMdjGrOOqEnIN4raKEuXvMfXLZTzi Jy/f6HSkPoluJyPOQYOpfHH3Ue1yMls+ICInVTMonrwKMsj78Gv7IXdXMq8cmmrAYprY rnOLWKlaR80sSxX0462WAzKze+cKUH7l7wvaqlama424G2MNnCHxmnVjkF5GRCQ4Orau z6Ipy6NRqZB2h6YgF+lTm4nQJtykyBsHnuqtlDZBCyE/zlqebI/1ubzz06A/3pLp2X7a XQ1w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-id:precedence:message-id:date :subject:cc:to:from:dkim-signature; bh=h4GeLlZbJrhRPA2trbEECF1V8nbw1OgWT9lb2M4w+JI=; fh=DP6zxOxeS6gr6fXcZQ49WRPORLgqUfvt3VZolGXE3Ow=; b=PC7HiVRc+7+9vMGDIq5vxNc2m6m4bN2JNr+rEkQzAjKbGCMeA++pC456MbhgAPlzdq EpbaWY9mNUR7gGAuRVUPPhus6ucN8XCrm/JoXg+bAo7ovq4/OG5ItfQeu26xXtO9K66v uf2+0GV+h0esEqRUZ++ERG25OhtaReC5IYDkt4dyBPCBkBDPQwG2RC4MJ5Yjn/1ofKeZ 0Ciu2qNffXZgmn065mzXJvJVuPWCPAyLz2K+FoApPmhTOK2PUEFpJ6jqi+8JoRKGM5iz Eaw/S1Wc00qexPSa6b0hc8GXqgdOG9aKzWujS23UCBVFp0cD7+dB+Hqi+TX+RtXmyHTh nOyw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KaEnBaLX; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-178846-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id a640c23a62f3a-a5a17945e9csi601972066b.85.2024.05.14.08.19.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 May 2024 08:19:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-178846-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=KaEnBaLX; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-178846-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-178846-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 am.mirrors.kernel.org (Postfix) with ESMTPS id 4A4A71F22F9D for ; Tue, 14 May 2024 15:19:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9852417EB99; Tue, 14 May 2024 15:19:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KaEnBaLX" Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (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 73DB46D1A7; Tue, 14 May 2024 15:19:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715699942; cv=none; b=KMkDEsxWDczmrm4jG7epTgVKygSrQrDA0zABQo1SHHZ+/3MKuGaP89FoQbVDNs4ZrUuijJJ4kfQggJZhOCdkPZvidcCTArvR1nkHM3aZpA8dXM+cLhATfPJ4/gDDgDvk0wRe1RvQ9iVxA9b2Sco7gujzbCJ/HTl4ngCUOD8wX4A= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715699942; c=relaxed/simple; bh=JXROq6O+Dzwqo8N4KN5rAIu9jMja79JWlM4fwbIot2Q=; h=From:To:Cc:Subject:Date:Message-Id; b=U1G5vlOgzbOPtne+0y1YMeW7UvqEIfq2YSvK4T9DA7RZfpNne48XwsjVHUpFgMbsHLhjJvNgc4DlkpzJa88QEnTwLFat0R/YryInEgpbDfochJ9y0cnyadc402glAzYuC0FU19Q/lNqBFOae6vkm1dbIpdMdPzc+B0EwwZwszHk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=KaEnBaLX; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1f08442b7bcso7637795ad.1; Tue, 14 May 2024 08:19:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1715699941; x=1716304741; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=h4GeLlZbJrhRPA2trbEECF1V8nbw1OgWT9lb2M4w+JI=; b=KaEnBaLXl5ch0ktpAYSLvJXzpaYSlGdFS2PsPcYLEIkYI2YfNrf2Pr5G4mhP2L3kDx 59tDL9oDs2fd1PJM+SVHuIbJ3Na6j/1fmnJ7Rber5DBz+QlPA02QqrBUU/1ot14s4TYS 9a6vnKQFSaLBwx9gFN/rwLalWIkGj2QYOLVSakZ04x+24PWaVd/UKG9aHDT2QuzvnkZM 6Qx7yb8jj8QSSgvQHAHhNuF8EnbD+ILoXQ+ea0ERkEI8zXxOH/O3EiNE9ZCdVb91DDS0 KoQ7AwtxZ5F7JcvxzF/9B4fWV71Y/75J7yNQsshxRuhZ/5bEvvrRDhB/0vKSNj98Ihpu mjOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715699941; x=1716304741; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=h4GeLlZbJrhRPA2trbEECF1V8nbw1OgWT9lb2M4w+JI=; b=N8+P/sQcrZGT0JPgLgpJaiZIAptF7IhJ0YWJE5aC6xBdE2qhcOrXr+gETMrJcU0r1T eiaYRCBDqqVBNwOsDBkvxcm4FKrCcx6cruuVrWVNJde+g3C9fVWFvMnj93wsnZBSqhll SfBT677VucW7k8acfFnteyySiOK8SeGU3/cEmfRfiWzpnN81JjHSu9O6xUlks7Y/jzPL sudmMGdaFQJYpB0+EikQF8Fq4sq6KYG+xH8JBxI1klXg/XO9BPP43WlkNCqka5pRvgUo QVZCCGeD0ydkwBf1RVpZ8WG8WRdGjNQIloB8gbpDo8QJKuASgdmpmblrwbk7ONurN1lc /W/g== X-Forwarded-Encrypted: i=1; AJvYcCWAmqmt37ZqjjDX0hE+Zy+2omhhrNXTzJoeAwyfNILV0eZbjC/eE4b0RXdAxL/wmnzuweBxlogd475oN2Y04R6UOI4Kokgzye6anXEEqmvsbkWcNSYha6Go2AJ9t0G9UimzYE83j3Qskeo= X-Gm-Message-State: AOJu0Yw6bIu7t4nnqUKMa6FUzSuHlEnwBDIOKH8MMz3k5I8sUFUktzY2 Of47/hq/b9w7BePngPxyFzMJlut5g+KVcAO5JIwgUHMc4V5aGPqT X-Received: by 2002:a17:902:d48d:b0:1ec:4cd7:6c7c with SMTP id d9443c01a7336-1ef43e2a1dcmr190159345ad.40.1715699940517; Tue, 14 May 2024 08:19:00 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1ef0c035dd9sm98689985ad.201.2024.05.14.08.18.58 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 May 2024 08:19:00 -0700 (PDT) From: Chun-Yi Lee X-Google-Original-From: Chun-Yi Lee To: Justin Sanders Cc: Jens Axboe , Pavel Emelianov , Kirill Korotaev , "David S . Miller" , Markus Elfring , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chun-Yi Lee Subject: [PATCH v2] aoe: fix the potential use-after-free problem in more places Date: Tue, 14 May 2024 23:18:54 +0800 Message-Id: <20240514151854.13066-1-jlee@suse.com> X-Mailer: git-send-email 2.12.3 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: For fixing CVE-2023-6270, f98364e92662 ("aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts") makes tx() do dev_put() instead of doing in aoecmd_cfg_pkts(). It avoids 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 makes the above functions do 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 --- v2: - Improve patch description - Improved wording - Add oneline summary of the commit f98364e92662 - Used curly brackets in the if-else blocks. drivers/block/aoe/aoecmd.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/drivers/block/aoe/aoecmd.c b/drivers/block/aoe/aoecmd.c index cc9077b588d7..d1f4ddc57645 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,6 +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 +486,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,6 +623,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); } } @@ -1395,6 +1403,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 +1413,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