From patchwork Fri Jul 12 01:18:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1959635 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ubuntu.com (client-ip=185.125.189.65; helo=lists.ubuntu.com; envelope-from=kernel-team-bounces@lists.ubuntu.com; receiver=patchwork.ozlabs.org) Received: from lists.ubuntu.com (lists.ubuntu.com [185.125.189.65]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WKtzW6bH6z1xqx for ; Fri, 12 Jul 2024 11:19:19 +1000 (AEST) Received: from localhost ([127.0.0.1] helo=lists.ubuntu.com) by lists.ubuntu.com with esmtp (Exim 4.86_2) (envelope-from ) id 1sS4wH-0007SB-Eo; Fri, 12 Jul 2024 01:19:09 +0000 Received: from smtp-relay-internal-1.internal ([10.131.114.114] helo=smtp-relay-internal-1.canonical.com) by lists.ubuntu.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1sS4wF-0007RR-AV for kernel-team@lists.ubuntu.com; Fri, 12 Jul 2024 01:19:07 +0000 Received: from mail-yb1-f197.google.com (mail-yb1-f197.google.com [209.85.219.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 2E2B23F0E9 for ; Fri, 12 Jul 2024 01:19:07 +0000 (UTC) Received: by mail-yb1-f197.google.com with SMTP id 3f1490d57ef6-dfa7a8147c3so2751782276.3 for ; Thu, 11 Jul 2024 18:19:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720747145; x=1721351945; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ii5e/5gZC/E9wfJHE+gScArkQLzexzHjoViY5t2tNMQ=; b=lXpnSJkQ143ckpMR7n9PpdJzQSghpSTLnkesM+y6myhyugHPAF0V64Le2Y1C8qeSs/ gP5CfnFdHpBaVyWT7yO7IyorpKjsyH+Zi1j0D6FekWdakuIxiL4tBfQAPpK5gd7sWRE1 KExn3vf7QvEulrSqXIhSTsLv5M9QSBGVVcbf7oRNOavbTi4nDHhg4vEsjxzzET8buYN+ aVKGH2e2s0sN/XhS2zAZJ/Ga21cABqWJxQbXXLtm63K5m/rGn0sbrIQctgiAWqUtyEQr TSecQj9pH8aKbCPVK4Nw12MK9wyU/9MVqvMABfwPkeMSH+EGpj7eaIPZ+C6OMnAv7fXo N6Og== X-Gm-Message-State: AOJu0Yym+U0azqcCOKb0SBJ3FhtHmyheqIyz7X24k5GaMLJ1iKjdahOv /pkCXK4J2c+guNVNlz+srNkbxHz+A1SNQFB6uCZbxWfbO7XYSwcO0mi3fD95cUZukiFZm7X04pQ Wq5QtoIXyS1Z6RiW6+b4Q+MMsVq1UpDZnXGQFi/7CKnYfM3udU8KnYE8Np2p72L5CWmmxYy5lh6 G9rBpwqBTqEg== X-Received: by 2002:a25:ab43:0:b0:dff:4862:b0a with SMTP id 3f1490d57ef6-e041b11d36bmr11921817276.46.1720747145062; Thu, 11 Jul 2024 18:19:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFW7goPSVjwOUwXEV1owEDSUbD2ilnNA3+BaUoaIAPHpPrGv69peGo3bE1ffjqKiHTdIe4Tpg== X-Received: by 2002:a25:ab43:0:b0:dff:4862:b0a with SMTP id 3f1490d57ef6-e041b11d36bmr11921810276.46.1720747144730; Thu, 11 Jul 2024 18:19:04 -0700 (PDT) Received: from cache-ubuntu.hsd1.nj.comcast.net ([2001:67c:1562:8007::aac:4795]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-6b61b9d5f89sm30644246d6.34.2024.07.11.18.19.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jul 2024 18:19:03 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [J][PATCH 1/1] gfs2: Fix slab-use-after-free in gfs2_qd_dealloc Date: Thu, 11 Jul 2024 21:18:55 -0400 Message-Id: <20240712011855.2233154-3-yuxuan.luo@canonical.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240712011855.2233154-1-yuxuan.luo@canonical.com> References: <20240712011855.2233154-1-yuxuan.luo@canonical.com> MIME-Version: 1.0 X-BeenThere: kernel-team@lists.ubuntu.com X-Mailman-Version: 2.1.20 Precedence: list List-Id: Kernel team discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: kernel-team-bounces@lists.ubuntu.com Sender: "kernel-team" From: Juntong Deng In gfs2_put_super(), whether withdrawn or not, the quota should be cleaned up by gfs2_quota_cleanup(). Otherwise, struct gfs2_sbd will be freed before gfs2_qd_dealloc (rcu callback) has run for all gfs2_quota_data objects, resulting in use-after-free. Also, gfs2_destroy_threads() and gfs2_quota_cleanup() is already called by gfs2_make_fs_ro(), so in gfs2_put_super(), after calling gfs2_make_fs_ro(), there is no need to call them again. Reported-by: syzbot+29c47e9e51895928698c@syzkaller.appspotmail.com Closes: https://syzkaller.appspot.com/bug?extid=29c47e9e51895928698c Signed-off-by: Juntong Deng Signed-off-by: Andreas Gruenbacher (backported from commit bdcb8aa434c6d36b5c215d02a9ef07551be25a37) [yuxuan.luo: TODO] CVE-2023-52760 Signed-off-by: Yuxuan Luo --- fs/gfs2/super.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 268651ac9fc84..98158559893f4 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -590,6 +590,8 @@ static void gfs2_put_super(struct super_block *sb) if (!sb_rdonly(sb)) { gfs2_make_fs_ro(sdp); + } else { + gfs2_quota_cleanup(sdp); } WARN_ON(gfs2_withdrawing(sdp));