Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2598801imc; Tue, 12 Mar 2019 18:24:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzdNMmj1YVILXBM+LblOvW94IjapzkG5rFSNPMJfghSjsuDHQj2w3NUTgjXzN4C3WcBkM7U X-Received: by 2002:a17:902:7201:: with SMTP id ba1mr13579125plb.56.1552440256741; Tue, 12 Mar 2019 18:24:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552440256; cv=none; d=google.com; s=arc-20160816; b=WOThVLZA42Kl2SH3negUbndkAqtONDhkg9M2o74Sh8eqTD4QypLLlLiuZpGjz5+bMC TH+nwAAEs4X09YHk8+leOOpOqNg/dtYFEJ3rjBwmAn0F6utNBgezPACDBTtS022QiwXO EcJzu1+JzjkvMfLizlG5NPKoAfdJfHXs3RdSm/6VWzP85CUf2N5Od6r/mkmn0OsHvkrW sYg80yr80c2yav/q4gEDGKynmr+Jtz/mtissI0dM3SG0BwHpExJNQWuhgM/0ZXUCoUpL /paCzovztWr7j86i3+HLu/BdBmLrZTJcLN0cdKmitmqa2qYMGibUHXijNs4ROSjaGd8A Nhfg== 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=Fhq4BFd6PJYycg3zm8BksEERQf3P2c+HZpZ0dvd1mjg=; b=GYNvghdQyImhUkCSOWW4N/LR6NBjGRwCNuHQ91UDPALfe2d+gz2IWozTv3dW0mXIdS NS/io0HgxyneKXxKlnGSXuYGiNTb+mx4a3BMozRFB7WBGANx54nsM1WXaWSZOruX7SxW CEtzJcx38B2UICCRJeFigS745mtUXYhhE9Hswe7Jvxb2dYjPPVHwcRAwTKOR7QY9yBF6 8bgcWY+ue+7cciwKOrspx8RI+jCOkUnYe3Ps3w3M4iggW1eLgrbM9WDTD9kAroYavtzX q4E4rHDOb3pongLuuSwORS7FgMMppz4Xv9Uwur0JvNlbQnPMSTXGd7IrOkK0rljufFGR 51Qw== 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 h7si8494997pgp.566.2019.03.12.18.23.59; Tue, 12 Mar 2019 18:24:16 -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 S1726451AbfCMBXj (ORCPT + 99 others); Tue, 12 Mar 2019 21:23:39 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:47974 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726269AbfCMBXj (ORCPT ); Tue, 12 Mar 2019 21:23:39 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 7DDE1CE67EC91307116C; Wed, 13 Mar 2019 09:23:37 +0800 (CST) Received: from [127.0.0.1] (10.134.22.195) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.408.0; Wed, 13 Mar 2019 09:23:34 +0800 Subject: Re: [PATCH v2] f2fs: fix to check inline_xattr_size boundary correctly To: Jaegeuk Kim CC: Chao Yu , , References: <20190214160825.4973-1-chao@kernel.org> <82ef0ff8-452c-1894-6776-41c70ad7654b@huawei.com> <20190312185057.GB45421@jaegeuk-macbookpro.roam.corp.google.com> From: Chao Yu Message-ID: <7b028daf-538e-a10e-6b79-f686021ee899@huawei.com> Date: Wed, 13 Mar 2019 09:23:35 +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: <20190312185057.GB45421@jaegeuk-macbookpro.roam.corp.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 2019/3/13 2:50, Jaegeuk Kim wrote: > On 03/04, Chao Yu wrote: >> Hi Jaegeuk, >> >> On 2019/2/15 0:08, Chao Yu wrote: >>> --- >>> v2: >>> - fix lower bound check, inline xattr size should be larger than >>> xattr_header's size at least. >> >> ... >> >>> + if (F2FS_OPTION(sbi).inline_xattr_size < >>> + sizeof(struct f2fs_xattr_header) / sizeof(__le32) >> >> No sure we should set this low bound as above... now I guess original >> non-zero check is enough. >> >> How do you think of setting inline_xattr_size range as >> (0, MAX_INLINE_XATTR_SIZE]? > > How about this? If you think it's necessary to check low bound with size of xattr header, I'm also okay with that. And below diff looks good to me, could you please merge this into original one? Thanks, > > --- > fs/f2fs/super.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c > index 42eb5c86330a..96302a428fdc 100644 > --- a/fs/f2fs/super.c > +++ b/fs/f2fs/super.c > @@ -821,6 +821,8 @@ static int parse_options(struct super_block *sb, char *options) > } > > if (test_opt(sbi, INLINE_XATTR_SIZE)) { > + int min_size, max_size; > + > if (!f2fs_sb_has_extra_attr(sbi) || > !f2fs_sb_has_flexible_inline_xattr(sbi)) { > f2fs_msg(sb, KERN_ERR, > @@ -834,15 +836,18 @@ static int parse_options(struct super_block *sb, char *options) > "set with inline_xattr option"); > return -EINVAL; > } > - if (F2FS_OPTION(sbi).inline_xattr_size < > - sizeof(struct f2fs_xattr_header) / sizeof(__le32) || > - F2FS_OPTION(sbi).inline_xattr_size > > - DEF_ADDRS_PER_INODE - > + > + min_size = sizeof(struct f2fs_xattr_header) / sizeof(__le32); > + max_size = DEF_ADDRS_PER_INODE - > F2FS_TOTAL_EXTRA_ATTR_SIZE / sizeof(__le32) - > DEF_INLINE_RESERVED_SIZE - > - MIN_INLINE_DENTRY_SIZE / sizeof(__le32)) { > + MIN_INLINE_DENTRY_SIZE / sizeof(__le32); > + > + if (F2FS_OPTION(sbi).inline_xattr_size < min || > + F2FS_OPTION(sbi).inline_xattr_size > max) { > f2fs_msg(sb, KERN_ERR, > - "inline xattr size is out of range"); > + "inline xattr size is out of range: %d ~ %d", > + min, max); > return -EINVAL; > } > } >