From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 03CD8C77B75 for ; Mon, 22 May 2023 12:01:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233662AbjEVMB5 (ORCPT ); Mon, 22 May 2023 08:01:57 -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 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