Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp153151lqj; Wed, 10 Apr 2024 06:56:40 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVy2VYxm+kPrN1xXcr+mpW2wQ9JuSoXQsSmzrUnB0KZwLIOET1H6/9PotJzWhP9WEhShvrcK5Q0R+H6zbDv6KHt9nx/PQ9FNhpN0ENROg== X-Google-Smtp-Source: AGHT+IHBc1qLF+GSUw1JFwNfv9Ats2tzAW5S1hQbWNkic2dd6WsueJNqXyIPQkkF0jkDogXuzyjP X-Received: by 2002:a05:6a21:150c:b0:1a9:5eb1:7f35 with SMTP id nq12-20020a056a21150c00b001a95eb17f35mr1355766pzb.46.1712757400540; Wed, 10 Apr 2024 06:56:40 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712757400; cv=pass; d=google.com; s=arc-20160816; b=s5gta15xwMlAHwc8HIOibu2/Ml5cNf/KTfaIVqwI1JqkjBhwbdO46B2Xgl/Tq1nEVX MnzR892hnxOIQTBUa2AYlvmPIqO5fG0l2qpYc8/FvrxA+xssU4J+KOOko+AhRFR+03CC 6lNCL1bF5oQyxxkXd3fGz1I+Ev3bwZ4OQQKO4fGwFQ1BsGKflRyEqAssC8JtaaSL5bd1 vB4CkE8e7uo0/akyN+wHseL9VIr1Rknta9bVF4QM+QhSbn0Mbsd7s9jPXaDmiM+/nzAr aAQEcIjj11nbTmJoXsD5HQmGVneW+IL944cc4sPkPVPP9jv015lS5XLfYu1UlgoCHqeo o7MQ== 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=ACLCyOatAYHZP8xv0gaT1bpB8I1NWTCVByRXRODXmv0=; fh=FD2yNgucLl3ol+5fHQelcJ6gEjtPbvwd53/vc5z4KBQ=; b=jNeXQASjq7VAGZ9g1OrDyu0nMYuLS9b3yqQkemwgZeDvcsS+WuTy3DZiMRwUr2zneH OYlhp9KrmJty4PKrOLrQsmf8PG5GLJO+xerQO7vURonajTJUff+keHmKviLTcyyM8wv4 0S2PEtVnIKAxXuzWcLB2sSK0HrNuhPfJ8mxtr4AOj5lu6awgkDG3CAFdXfE2tYyUNUNr aheyIlPdPMVvl0nuJTX1Mh4YpKi+VYAV/D/HILyv63yK0p7ARO0D9qIeuShRXczDXDEt hz4AdnX57wGjA2wYaxoqIjbXyX4XWWwG4wF+PWeg4GSEDJXvroC5yNxikmGs15Vyi8H2 FRkA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XJGt5fwT; 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-138677-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138677-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id g22-20020a056a000b9600b006eaf3fb26eesi10832921pfj.311.2024.04.10.06.56.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 06:56:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138677-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=XJGt5fwT; 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-138677-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138677-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 00D28285586 for ; Wed, 10 Apr 2024 13:56:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38005161308; Wed, 10 Apr 2024 13:49:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="XJGt5fwT" Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) (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 CBBF5160792; Wed, 10 Apr 2024 13:49:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.176 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756946; cv=none; b=ezy1cP5dySAsfmZcCXlVWTg16fl6L5wNs5NE4a0m8lu046a824akPuNZR9TjFgxjCVEfgJoz8LJaOR2NzPqToC/8deqDYUagv+17bM4Duw8b+Ek+JMqUDq73C7Q+67ljSWD9XmF5qgKHjgv75zguzwWghalVg2lMQ/tmQD+2iio= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712756946; c=relaxed/simple; bh=z7WWEmfGexfSzYypM+C/PDKMr6HcbNcz0JwCfglFf74=; h=From:To:Cc:Subject:Date:Message-Id; b=u5VNLOiodPa+MHxm1f59uaoohc3yugS57gFFJNsIV9+NEdE03eh1BTs+AyH+lmfhju+cLjlb06wxbOdlh3RSYVePyLTDmy4igsmesgu0V+gYH0WFxs+C3M2yce+sr7RxtgdcNDnf3pzeNo9Hz9DXXdSI6LPUmKBDVMxnbdcHR2Y= 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=XJGt5fwT; arc=none smtp.client-ip=209.85.210.176 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-pf1-f176.google.com with SMTP id d2e1a72fcca58-6edc61d0ff6so499287b3a.2; Wed, 10 Apr 2024 06:49:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712756944; x=1713361744; darn=vger.kernel.org; h=message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ACLCyOatAYHZP8xv0gaT1bpB8I1NWTCVByRXRODXmv0=; b=XJGt5fwTMN6Rf74ILGm9Jrlj0FJq8MY3WEsloe/priEoipmnazSbPFO0IG1aRJvS4v p52WTJVSJHiVZECbngEkXd0pmDK3scfD47tgYAyI1EaTii5/eKd0PiFHoQbtc+ywmvog zxM0t9K4/lTTBW+dZlbYv6oQ0XOK98dFFtEgiLUawsXawX7/pQUYxEoj1/7ap70nSIni q9ltonwAwDh6rKmRBmlz+TXDgUhS5sXF2iMzR+6LpSUJVCtuo9xbrpEDXYAuOLqOAdpr ys+UyVNJ4VIPMtlLS6F6LaC2UnOVqRDA2gm6i8gGf3bpmrqi6HNWXD+ic87XVQ4NIpS1 ZNNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712756944; x=1713361744; h=message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ACLCyOatAYHZP8xv0gaT1bpB8I1NWTCVByRXRODXmv0=; b=N4QpI279kPosKBdBBwFVHV2wp3UvxCQ8nmdIOIHli70j0z6Hqloi6hS+P7mkCGYFKR wMX6tOZPoSnWlMXwYzXeLZZZmIGpwYVS2RU6CY1dP/L7Xf9t/MaERcWvBoYWpI/HzQVC jTAxtE4i5evlNBLP3Zp90mJ9Uy6cW6Fo9I0+5OlfKx9r1O7IiDZDJEHQeNw0LC6QK1Tg uhU29I3VbkA3JHc4ELs+tF6UKL1QFNl1TYOXyZpYraxlfGxbuGGRDzeUcGMnBUQzXnia 6AeuewWIZRoUmt23CCDo6ZC3froL059GbEWo0NRRO0pDfY/JxLrJSiouLj3mMNKsLeUu s7sw== X-Forwarded-Encrypted: i=1; AJvYcCW/tRsC8SLyDQabClJZQXGjv+G5xdeH0JV4994rIRn70JH6X3ZUMeO4/qlmQVn4KMP7u2qV6BBKesF+65d+Wx6DeOfVb0NkXyjnyO4F/4avoBIb1E9SAw0MJnVPvA8SkM/889v1Hh4L+2g= X-Gm-Message-State: AOJu0YzutGQ4Mq6zvapQLZgry2KxOyyEQ1pHb2IArDb2DrFHrxI+tWNV l4rn46pHjLM9EwQWjtRbdF1Y3RL/qRtiKWnphvxBDxvDU/FWDCLR X-Received: by 2002:a05:6a20:324f:b0:1a3:aed1:4d50 with SMTP id hm15-20020a056a20324f00b001a3aed14d50mr2901107pzc.31.1712756943937; Wed, 10 Apr 2024 06:49:03 -0700 (PDT) Received: from linux-l9pv.suse ([124.11.22.254]) by smtp.gmail.com with ESMTPSA id h11-20020a63210b000000b005dcc8a3b26esm9630636pgh.16.2024.04.10.06.49.02 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Apr 2024 06:49:03 -0700 (PDT) From: "Lee, Chun-Yi" X-Google-Original-From: "Lee, Chun-Yi" To: Justin Sanders Cc: Jens Axboe , Pavel Emelianov , Kirill Korotaev , "David S . Miller" , linux-block@vger.kernel.org, linux-kernel@vger.kernel.org, Chun-Yi Lee Subject: [PATCH] aoe: fix the potential use-after-free problem in more places Date: Wed, 10 Apr 2024 21:48:58 +0800 Message-Id: <20240410134858.6313-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: 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 --- 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