From patchwork Fri Jul 12 01:18:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuxuan Luo X-Patchwork-Id: 1959636 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 4WKtzW71dhz20Mc 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 1sS4wG-0007Rp-9r; Fri, 12 Jul 2024 01:19:08 +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 1sS4wE-0007RD-F0 for kernel-team@lists.ubuntu.com; Fri, 12 Jul 2024 01:19:06 +0000 Received: from mail-qk1-f198.google.com (mail-qk1-f198.google.com [209.85.222.198]) (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 3CD1E3F0E9 for ; Fri, 12 Jul 2024 01:19:05 +0000 (UTC) Received: by mail-qk1-f198.google.com with SMTP id af79cd13be357-79f1a81bd7fso189948985a.3 for ; Thu, 11 Jul 2024 18:19:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1720747143; x=1721351943; 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=O8T6ZiI2YKOkR/4f98uek/B21mC4jvFjtuzCpE4BQ+w=; b=JbMyssUizMG6A4Q8p70Wqtx7J9vqUEltLqLP8mtEV0m73zXq9rzK5sWZ6f0iNn0jnZ CT9Q5w2tKV+jVoyJdn9kpdDtYh/9U9HGmfqLecEep/XW7+iOJeCiFQ0KukKP0bc3K/Kz VKRiS6SPsySUo7sR6HSJLOgU5bZqJXneWvd9jfPchEdwXQGr82SAH0hA9+F3ndbE1hy6 PKqqcekHLiopv2GCmSMq9eACsOZ5HW00vH54Z0TpKhUyf8E8Zdv+jQd0qcbLnzLaAJ5u +wIY3k5PDvQNgXj/opna2xmjyuicX6YrIwxGpe6Bkg7+7s+7wX2K3zjuezf+IBGkOpvF u3kw== X-Gm-Message-State: AOJu0Yz55JAwF2e52MCLWCOfUC6u7ACmpJOi4U98CwHTJpmidQkl2wf3 Jew7WnHWr3p8ta/FIgiLHbTFyAR7HS/LUsCVoWfqJYheIwAPbxWK1kw3oE0QE7OwLR2raze1mQL 4qVuJnB0Hnginiqgje1UU6nL0NVgUyMAxnY1MCP0JgrB42S+QSvg0CsenWf9KWecT1eYn7jLyIV CioQMWHJ852g== X-Received: by 2002:ad4:5bea:0:b0:6b0:6400:3b6f with SMTP id 6a1803df08f44-6b61bc7f160mr122345766d6.8.1720747143014; Thu, 11 Jul 2024 18:19:03 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGsDgQEk1cHBg3oZz7YDRUap5va+TW2Wf1CDTjg9g5tunGUw+5elxI5gxo/R6bR61NZo6gk8Q== X-Received: by 2002:ad4:5bea:0:b0:6b0:6400:3b6f with SMTP id 6a1803df08f44-6b61bc7f160mr122345586d6.8.1720747142723; Thu, 11 Jul 2024 18:19:02 -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:02 -0700 (PDT) From: Yuxuan Luo To: kernel-team@lists.ubuntu.com Subject: [F][PATCH] gfs2: Fix slab-use-after-free in gfs2_qd_dealloc Date: Thu, 11 Jul 2024 21:18:54 -0400 Message-Id: <20240712011855.2233154-2-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 15e757f763806..09bb630185952 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c @@ -662,6 +662,8 @@ static void gfs2_put_super(struct super_block *sb) error = gfs2_make_fs_ro(sdp); if (error) gfs2_io_error(sdp); + } else { + gfs2_quota_cleanup(sdp); } /* At this point, we're through modifying the disk */