Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2726217rwd; Mon, 22 May 2023 03:30:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Av5engIok02bekwkk0AB387NX1DqFnkTmbe59oSEezN8rbimjg5suGwBAScT1swd4hCMw X-Received: by 2002:a05:6a20:9386:b0:10a:e27e:b794 with SMTP id x6-20020a056a20938600b0010ae27eb794mr7057663pzh.19.1684751412931; Mon, 22 May 2023 03:30:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684751412; cv=none; d=google.com; s=arc-20160816; b=h90Gj6RQ5Kk9ueZF1RR4nah5Da591KmTgX3CjLVJSGFEQ4PVLCw44V+ajxU79kaBQA KEugvk6TCbMUXaz2qK/bNAuLc1jcHonwfb4M9UmszR0plxytiurSCLYsRDTRB1yZEOjI 4OrFgQ7aTaFmf0DoYsShXZt/sTQLD74r5OPitTrh+t5MLVLnDfK9cNAZ4TRzpynyr8AC d6c2tmglpMx/kzpWmgXV3pqT1wLC3zO7F6IAl9t86DUHGdZk+fmCf7aPJzrHD4RoSy70 7wBiCNcQGQRMDexzgITgTSvlk8su9ioobNl23C29eEH3W7CRQE21hA1dRCPtkpwf6Zsc dLsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature :dkim-signature; bh=UWemZErlloMTCdVWorQ4/wn7rdudTuYoPoEblvyctGQ=; b=jHFcylNJyp0EcL1lpAginHFRGSRoxB7GPBY6KGDrK9m4j0+4RzflQdoxrkO/D2rsnm mNTThVYBXxbeXRCVhHP++yu5tr57tDI6ql1FMphgJvPsSzwrnG+4Hiwq4HgpTAp8UcKk w8aDEVc4/aen9tSpceZ0uPEGLpfzXBKXECrDhALTf9T4baXgxqq8WkiITFK4awWBXTO3 IcqJZ1miMnHk0tL2603p1i4nzvEua7jJHbUQO43Kj0oJA0FJRFzijtmdDH9gq5Qh5X+S mBy/V984I6qVaYY6Zy2jRQgiN9kUFMt6EqEudkt6Aw+VT7FkJgAck1fxHB93/Seafytv dt/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QQTjL4QD; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=wKRzbRx5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d2-20020a637342000000b0052872c32995si4449285pgn.724.2023.05.22.03.30.00; Mon, 22 May 2023 03:30:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=QQTjL4QD; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=wKRzbRx5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232644AbjEVKZQ (ORCPT + 99 others); Mon, 22 May 2023 06:25:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232018AbjEVKZH (ORCPT ); Mon, 22 May 2023 06:25:07 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 91505D2 for ; Mon, 22 May 2023 03:25:04 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4C72A1FDFE; Mon, 22 May 2023 10:25:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1684751103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UWemZErlloMTCdVWorQ4/wn7rdudTuYoPoEblvyctGQ=; b=QQTjL4QDyHtniL9u0v5PF8UzTIRq7/2LV3NUcAlGu/utAasoDij+m+nFVURh1xBnqorVd8 ysZmNiYmRm9FS1NmCKPmtC3YG6qH2l+dNyEepXb+jjVvN93Sb/G9X2TvM0Kz87glOyh3iy HYwTSyTpxMk2fpUNei4hWJ7dVdxif5U= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1684751103; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=UWemZErlloMTCdVWorQ4/wn7rdudTuYoPoEblvyctGQ=; b=wKRzbRx5iZD1HrstnU5oYyYMA/Ubp7dh32DxMCfkugTTSs1Zldo3NqmRwC7Vs/W4c6Flok P4Dku6mur3JKrECw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id D143F13776; Mon, 22 May 2023 10:25:02 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id iJzYL/5Ca2TFEgAAMHmgww (envelope-from ); Mon, 22 May 2023 10:25:02 +0000 Received: from localhost (brahms.olymp [local]) by brahms.olymp (OpenSMTPD) with ESMTPA id 6dd15e18; Mon, 22 May 2023 10:25:00 +0000 (UTC) Date: Mon, 22 May 2023 11:24:34 +0100 From: =?iso-8859-1?Q?Lu=EDs?= Henriques To: Mark Fasheh , Joel Becker , Joseph Qi Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, =?iso-8859-1?Q?Lu=EDs?= Henriques Subject: [PATCH] ocfs2: fix use-after-free when unmounting read-only filesystem Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org It's trivial to trigger a use-after-free bug in the ocfs2 quotas code using fstest generic/452. After mounting a filesystem as read-only, quotas are suspended and ocfs2_mem_dqinfo is freed through ->ocfs2_local_free_info(). When unmounting the filesystem, an UAF access to the oinfo will eventually cause a crash. Cc: Signed-off-by: Lu?s Henriques --- fs/ocfs2/super.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ocfs2/super.c b/fs/ocfs2/super.c index 0b0e6a132101..988d1c076861 100644 --- a/fs/ocfs2/super.c +++ b/fs/ocfs2/super.c @@ -952,8 +952,10 @@ static void ocfs2_disable_quotas(struct ocfs2_super *osb) for (type = 0; type < OCFS2_MAXQUOTAS; type++) { if (!sb_has_quota_loaded(sb, type)) continue; - oinfo = sb_dqinfo(sb, type)->dqi_priv; - cancel_delayed_work_sync(&oinfo->dqi_sync_work); + if (!sb_has_quota_suspended(sb, type)) { + oinfo = sb_dqinfo(sb, type)->dqi_priv; + cancel_delayed_work_sync(&oinfo->dqi_sync_work); + } inode = igrab(sb->s_dquot.files[type]); /* Turn off quotas. This will remove all dquot structures from * memory and so they will be automatically synced to global Cheers, -- Lu?s