Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3572079ybb; Mon, 23 Mar 2020 03:42:47 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsnzNpqCfPHQVERvcTYHk+8n+t1JucU9eXJ69hwndATuTn5Khym/lTwSknm9CTHDgX2e+GP X-Received: by 2002:a05:6830:12d0:: with SMTP id a16mr17575077otq.218.1584960167203; Mon, 23 Mar 2020 03:42:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584960167; cv=none; d=google.com; s=arc-20160816; b=B/KPRqTekvui7x2CRe55PsO5dpa/ojJr5JMt1mKEyylNDYWoDP43SfSwU3ge7Ok9tk UHmQ3iRLmlOyXmKAc79IAnLqI4MVjHRvSZ3VVECY3nPJDTDczuQ5728PgLqcVbc1FWvr jAWRJFiCQE5FhX8lv60cLIRGQIVzLaywwTJJrdCxGbCmj+REFuOuxoZh649V+2/uZEXz WomHVJZALJue3mZWZybrR1teRHsQOEJyRdgb5aoaxjNOhjD5YtoV8Hcr1/0/NrRdaRJn sDdhuQpPewUY+pIZTVFDAtPLzgXi2/EkoOEuWfgC91pjcoyHnqDppgJPHzIl29y+qDEB uMgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id; bh=CVg2Sx9rAstC32JJ2NrvxjHMCdgYOTJ42VH9vrIERqQ=; b=qlntFbvNSG4/hbKQuEMuypVtsYt63rrg3ZTiH647U4qROt6gf1fvZuQqq0koJPtxmO 65oVf8UHmF8/8FFYM5oRrQml19srYaRzZ1u4JNCGHf1pCk9+z0/UpLXqpxLvEw1IWsg0 QyTOAW4dJLvQG0sR29pbMhI0HRvcabWbg8KEIfUhOLIvb8Tts7Ux7j4fgyj0reiQopym B/cb5xF6yGzPYXk54HT8MXNPb7FcgRcCrQLCKK1+GmQO3uWoeqJTraLyOM7kuVtHapuh Q/tvwnnUcBjZ1/YKlDqaCYB9JSq8Ezf5TVTgGG47V2ZttqSP4/U8ZUBg9p1ixfhN3trm qfmA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e19si7820773otp.40.2020.03.23.03.42.35; Mon, 23 Mar 2020 03:42:47 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728066AbgCWKmI (ORCPT + 99 others); Mon, 23 Mar 2020 06:42:08 -0400 Received: from smtprelay0192.hostedemail.com ([216.40.44.192]:40866 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727908AbgCWKmH (ORCPT ); Mon, 23 Mar 2020 06:42:07 -0400 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay01.hostedemail.com (Postfix) with ESMTP id 1FBD8100E7B47; Mon, 23 Mar 2020 10:42:07 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,,RULES_HIT:41:355:379:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1437:1515:1516:1518:1534:1539:1593:1594:1711:1714:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:2901:3138:3139:3140:3141:3142:3351:3622:3865:3866:3870:3871:3872:3873:4321:5007:10004:10400:10848:11026:11473:11658:11914:12295:12297:12740:12760:12895:13069:13138:13231:13311:13357:13439:14659:14721:21080:21627:30054:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: spot70_125bc865c5d12 X-Filterd-Recvd-Size: 1557 Received: from XPS-9350.home (unknown [47.151.136.130]) (Authenticated sender: joe@perches.com) by omf08.hostedemail.com (Postfix) with ESMTPA; Mon, 23 Mar 2020 10:42:06 +0000 (UTC) Message-ID: Subject: Re: [PATCH v5] f2fs: fix potential .flags overflow on 32bit architecture From: Joe Perches To: Chao Yu , jaegeuk@kernel.org Cc: linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, chao@kernel.org Date: Mon, 23 Mar 2020 03:40:16 -0700 In-Reply-To: <20200323031807.94473-1-yuchao0@huawei.com> References: <20200323031807.94473-1-yuchao0@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.34.1-2 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2020-03-23 at 11:18 +0800, Chao Yu wrote: > f2fs_inode_info.flags is unsigned long variable, it has 32 bits > in 32bit architecture, since we introduced FI_MMAP_FILE flag > when we support data compression, we may access memory cross > the border of .flags field, corrupting .i_sem field, result in > below deadlock. [] > diff --git a/fs/f2fs/inode.c b/fs/f2fs/inode.c [] > @@ -362,7 +362,7 @@ static int do_read_inode(struct inode *inode) > fi->i_flags = le32_to_cpu(ri->i_flags); > if (S_ISREG(inode->i_mode)) > fi->i_flags &= ~F2FS_PROJINHERIT_FL; > - fi->flags = 0; > + bitmap_zero(fi->flags, BITS_TO_LONGS(FI_MAX)); Sorry, I misled you here, this should be bitmap_zero(fi->flags, FI_MAX);