Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4499964ybb; Mon, 23 Mar 2020 23:14:41 -0700 (PDT) X-Google-Smtp-Source: ADFU+vv/hi2ny1w70yI3t83MfjEPvgPCWxeirCIECZHSIstZUL+oYHbK2C3x992AblrR8nu8Lg/i X-Received: by 2002:a9d:4f0:: with SMTP id 103mr20274421otm.336.1585030481196; Mon, 23 Mar 2020 23:14:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585030481; cv=none; d=google.com; s=arc-20160816; b=ZES8bZVfqBtGXQ00VLB1XQVp4wIyK5MftXUj3koE6F9gSsiPlRrtogaK4oOLuDHUw+ S0VCEW27R7h3UHvfu5D+txchF2boJrX+GP/paCItWt3xlOsZxvnAtt7LgQPs+zNO1tMD 3y1xlCvHwk/RVoUqOaL6MjarPEx+zsES2hFe3D05lVqrH+1Mzj+S9KIMlEe6UcKlArBF 5m1TtVtqnSN+M9JRcBpXcKPHtgJ0lZ9XQ3Dtkmy89x9M47Ufrzy4F35h1UDWM9yMWOWM FvXvHhtPbtJRdxqwACCHC0nx5MxtpiLFSBKmsxq+05WVxR0qb1981RXRuKbARYojb57Y pf1g== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=SXgZh6cA45JnaDWrSFK6DuFNe7edN58cN2gV/jEcHuQ=; b=hRuuvs8rsDZjwzhFx3oeO0GS7/OtzR/cYoj/lVo4WZI2IA9LG97lJsHkum2dv5YGCH Sn2NGZ27n5hYB45oM6S0E+XzYjKaS4r6xZlgFDMrDYS9Pv0G/9D/c4MXmdUx+W/pC1ek 34Rox7Jeg1Z4fqpX/IU9/vGHtczNURuaju9i7fIZKOPlBgIIScl02YxfS375YY9DaWZI YHfwMJHeb2BDbNBZ40kaQVWdviAOGxFErPpM5NPTpLPF/NejEy5YvMDQiVkuD6JqEc5D T0YOI5Xd29PgQQbiCMqNdSZVKjiJueUUg309f6ut5rspfWs8AgQJ7fE3S1FjGGylbSAz 7IzA== 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 w128si9006521oib.247.2020.03.23.23.14.28; Mon, 23 Mar 2020 23:14:41 -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 S1727289AbgCXGOI (ORCPT + 99 others); Tue, 24 Mar 2020 02:14:08 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:56462 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725951AbgCXGOH (ORCPT ); Tue, 24 Mar 2020 02:14:07 -0400 Received: from DGGEMS411-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 423F98E17D8711737378; Tue, 24 Mar 2020 14:13:33 +0800 (CST) Received: from [10.134.22.195] (10.134.22.195) by smtp.huawei.com (10.3.19.211) with Microsoft SMTP Server (TLS) id 14.3.487.0; Tue, 24 Mar 2020 14:13:29 +0800 Subject: Re: [PATCH v5] f2fs: fix potential .flags overflow on 32bit architecture To: Jaegeuk Kim , Joe Perches CC: , , References: <20200323031807.94473-1-yuchao0@huawei.com> <20200323151027.GA123526@google.com> From: Chao Yu Message-ID: Date: Tue, 24 Mar 2020 14:13:28 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: <20200323151027.GA123526@google.com> Content-Type: text/plain; charset="windows-1252" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.134.22.195] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020/3/23 23:10, Jaegeuk Kim wrote: > On 03/23, Joe Perches wrote: >> 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); Oh, I missed to check that as well. :( > > Thanks, I applied this directly in the f2fs tree. Thanks for the help. Thanks, > . >