Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2831447rwd; Mon, 22 May 2023 05:09:01 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ6U//mh5R1ycOPvmL+/qwbVjOiFPQQsY9rS0tIK5EnI7SUMcjsdQDcPZl98YSSyQqHZ0OsI X-Received: by 2002:a05:6a00:1741:b0:64d:42f6:4c7b with SMTP id j1-20020a056a00174100b0064d42f64c7bmr10734257pfc.27.1684757341044; Mon, 22 May 2023 05:09:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684757341; cv=none; d=google.com; s=arc-20160816; b=ISEV4zHPzKRQpsTDcELOWLRTlk+V+/SoY34AuVh9SpDZAnxGPEpkhhGC/h1dQ6EI8K OKnLRPEaianeAgPrmwBeVLdIIGUS3tJ0DXqo2AYBIBUNIMiro/sgZQGWfQ8iw+cuhGY8 axtj2exqLHAJ8ITwlELhgmcSf2LXCKNBBLPgdtUfAo/B1MNx21l/HgoDfeFPbkHWiExC XXTgemuV/UQ83StTfiRuw/WuJXqFNPnscGZYNA2y5ttMhUi2PC68Io33v/G1F7Luk0X+ gmTwc2COJM18C3o2xtnE0LjMe7MX4C/f7TYg8IVEQQlnQ7P/E14em6RnYYMxcVDfZM3j 1Kgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=g58+BSwEiBUOWu/DFJTWQKguirHV3fHJrMPB+aeJDEw=; b=sDrMnzsqem3TnBTakOVH4pDs4EbMRH7z9IPWq1ySwND8/WJsSRF7xIzwtQnRDXCPJo FTziZxjdvXsHofJNzhYEcPu5dkkoo10NdFFUS0wrxIkcblR1H9oBmA3t6pQQ1TcN4ykc D/j3o7rItU2GsKeEizXV4yjufmtSITA66OZ3PJ6BVMldxcJ+69jlbA/tnt3pxkgpe2bW ryDvjIVKlLYSeb8EkUf0JVmSK02isjkfH8jqC7nlbvWXdX3NMh8WS44vDClpgEZDD5A6 k74NG/wyKo4x7bmaacKGSnfNxEyC/c9hqjUjV6APpQdutK3AW5Jn+R9rYe66O4Vwv1jE uYRw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id c4-20020a633504000000b005074cff89b9si4743233pga.250.2023.05.22.05.08.48; Mon, 22 May 2023 05:09:01 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233626AbjEVMB4 (ORCPT + 99 others); Mon, 22 May 2023 08:01:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233048AbjEVMBy (ORCPT ); Mon, 22 May 2023 08:01:54 -0400 Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B816EE41 for ; Mon, 22 May 2023 05:01:29 -0700 (PDT) X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R321e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=ay29a033018046059;MF=joseph.qi@linux.alibaba.com;NM=1;PH=DS;RN=6;SR=0;TI=SMTPD_---0VjEZgMP_1684756885; Received: from 30.221.132.35(mailfrom:joseph.qi@linux.alibaba.com fp:SMTPD_---0VjEZgMP_1684756885) by smtp.aliyun-inc.com; Mon, 22 May 2023 20:01:26 +0800 Message-ID: Date: Mon, 22 May 2023 20:01:25 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.11.0 Subject: Re: [PATCH] ocfs2: fix use-after-free when unmounting read-only filesystem Content-Language: en-US To: =?UTF-8?Q?Lu=c3=ads_Henriques?= Cc: ocfs2-devel@oss.oracle.com, linux-kernel@vger.kernel.org, Mark Fasheh , Joel Becker , Heming Zhao References: <20230522102506.9205-1-lhenriques@suse.de> From: Joseph Qi In-Reply-To: <20230522102506.9205-1-lhenriques@suse.de> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, ENV_AND_HDR_SPF_MATCH,NICE_REPLY_A,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY,USER_IN_DEF_SPF_WL 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 On 5/22/23 6:25 PM, Luís Henriques wrote: > 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 generic/452 is for testing ext4 mounted with dax and ro. But ocfs2 doesn't support dax yet. > 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. In ocfs2_fill_super(), it won't enable quota if is a readonly mount. Do you mean remount as readonly? Thanks, Joseph > > 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