Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2346006imc; Tue, 12 Mar 2019 11:51:51 -0700 (PDT) X-Google-Smtp-Source: APXvYqyCB/V2HI0E4Sh2TcHzEt9A2zDB+BTNNPSiim4BqvQkp35CUvzITR4HgdE40FmJmjsDDP3e X-Received: by 2002:a17:902:7682:: with SMTP id m2mr41919679pll.311.1552416711904; Tue, 12 Mar 2019 11:51:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552416711; cv=none; d=google.com; s=arc-20160816; b=QT4i6bQ9Q5Vy0gpppEyk7J4q2QkFinup2VC41V4hDELfIk3bWZm4MMeJS1ZNvXdlKg TfiirNeSWnrxAH/x13RgZZEh8w4Ysx+1XVpI38c61dBCbZBtgkVAXhv9Xa4Z91/GJ4tX lwPaNpNUypKR26NOdXkKK7hGTn4nzjkkThUryv7+dkdqayTI2ueCtzG31Md4nr7Hh+aP 1FZ0hmr5dO8iJ/K42IOSuAQMPdRK3A5SZw3UQWCiRkfBaXCmd86tebTzPcQ/khLMAhpN p1sSmyYYJubmJoc4ea74fymZ7/UnH08r8McGrEhJJ4TvNAXFsH9uvMYe/U85a3WQGI9U JEPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=Iam2Kdu7JY0JkvPZ7swPjiGpOFjN0MPEVJMVm/+1Kso=; b=oMoxc5/ghN6XbECEqhj+1gVz8YPA4fOhpfMDZM41wzWxHjlzHApWx5krTa8f24sIuP Vc2wAAkRjKLbLP6ATPq2DjcMAkUA5I2KEzo7+bM9IsHGD3hHK9cFK+Sza+N4kv40St9N I90KQNGmzHqiBSTHQ3Tq72xAaVsdCAOiia3vbO5OpRgKKAKMxKq8BpOXZqA0DPkJIFXy UyI8zLdTP80VsjouQp+09vi4OU70NT4IKx0NAQiqRv7MInFDKmiJ/p1nQZBes3youlFa ZBjB6MeLEI0C/4FYpatcupjA2jRGzDRynmDm4LxlE8f7B+eWLddADMxpoX50jA46/7XZ XGYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="Sfn/u6Vu"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y18si7956321pgf.247.2019.03.12.11.51.34; Tue, 12 Mar 2019 11:51:51 -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; dkim=pass header.i=@kernel.org header.s=default header.b="Sfn/u6Vu"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727134AbfCLSvA (ORCPT + 99 others); Tue, 12 Mar 2019 14:51:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:40244 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727041AbfCLSu7 (ORCPT ); Tue, 12 Mar 2019 14:50:59 -0400 Received: from localhost (unknown [104.132.1.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AF376206BA; Tue, 12 Mar 2019 18:50:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552416658; bh=DEqyzLHUHAyMTqMI0/4aM5ydiivX4x8vNjvsXrpZOLA=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Sfn/u6VuUrd87OGYfaR05JJtVFKZfRl+WG6yqtn+TEp2n8NA8nFWLZnxFosLv876k A8gDdom8awK4gN88W8UTstHzi0ReON/Ud4aEfojuts0L4P5zOKPuDsldNTi/QYpVk4 4OJPeVMl079ML8JJeChBYy6PVPmFFzI0Idsb3W70= Date: Tue, 12 Mar 2019 11:50:57 -0700 From: Jaegeuk Kim To: Chao Yu Cc: Chao Yu , linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: Re: [PATCH v2] f2fs: fix to check inline_xattr_size boundary correctly Message-ID: <20190312185057.GB45421@jaegeuk-macbookpro.roam.corp.google.com> References: <20190214160825.4973-1-chao@kernel.org> <82ef0ff8-452c-1894-6776-41c70ad7654b@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <82ef0ff8-452c-1894-6776-41c70ad7654b@huawei.com> User-Agent: Mutt/1.8.2 (2017-04-18) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? --- 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; } } -- 2.19.0.605.g01d371f741-goog