From: Eric Biggers <ebiggers@kernel.org>
To: Ritesh Harjani <riteshh@linux.ibm.com>
Cc: linux-fsdevel@vger.kernel.org, linux-xfs@vger.kernel.org,
Alexander Viro <viro@zeniv.linux.org.uk>,
"Darrick J . Wong" <darrick.wong@oracle.com>,
Christoph Hellwig <hch@infradead.org>, Jan Kara <jack@suse.com>,
tytso@mit.edu, "Aneesh Kumar K . V" <aneesh.kumar@linux.ibm.com>,
linux-ext4@vger.kernel.org
Subject: Re: [PATCH 1/2] fibmap: Warn and return an error in case of block > INT_MAX
Date: Fri, 24 Apr 2020 12:17:39 -0700 [thread overview]
Message-ID: <20200424191739.GA217280@gmail.com> (raw)
In-Reply-To: <e34d1ac05d29aeeb982713a807345a0aaafc7fe0.1587670914.git.riteshh@linux.ibm.com>
On Fri, Apr 24, 2020 at 12:52:17PM +0530, Ritesh Harjani wrote:
> We better warn the fibmap user and not return a truncated and therefore
> an incorrect block map address if the bmap() returned block address
> is greater than INT_MAX (since user supplied integer pointer).
>
> It's better to WARN all user of ioctl_fibmap() and return a proper error
> code rather than silently letting a FS corruption happen if the user tries
> to fiddle around with the returned block map address.
>
> We fix this by returning an error code of -ERANGE and returning 0 as the
> block mapping address in case if it is > INT_MAX.
>
> Signed-off-by: Ritesh Harjani <riteshh@linux.ibm.com>
> ---
> fs/ioctl.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/fs/ioctl.c b/fs/ioctl.c
> index f1d93263186c..3489f3a12c1d 100644
> --- a/fs/ioctl.c
> +++ b/fs/ioctl.c
> @@ -71,6 +71,11 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
> block = ur_block;
> error = bmap(inode, &block);
>
> + if (block > INT_MAX) {
> + error = -ERANGE;
> + WARN(1, "would truncate fibmap result\n");
> + }
> +
WARN() is only for kernel bugs. This case would be a userspace bug, not a
kernel bug, right? If so, it should use pr_warn(), not WARN().
- Eric
next prev parent reply other threads:[~2020-04-24 19:17 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 7:22 [PATCH 0/2] WARN fibmap user in case of possible addr truncation Ritesh Harjani
2020-04-24 7:22 ` [PATCH 1/2] fibmap: Warn and return an error in case of block > INT_MAX Ritesh Harjani
2020-04-24 9:57 ` Jan Kara
2020-04-24 10:07 ` Christoph Hellwig
2020-04-24 19:17 ` Eric Biggers [this message]
2020-04-24 22:54 ` Ritesh Harjani
2020-04-24 23:40 ` Matthew Wilcox
2020-04-24 23:46 ` Darrick J. Wong
2020-04-25 7:03 ` Ritesh Harjani
2020-04-27 1:04 ` Dave Chinner
2020-04-28 7:29 ` Ritesh Harjani
2020-04-24 7:22 ` [PATCH 2/2] iomap: bmap: Remove the WARN and return the proper block address Ritesh Harjani
2020-04-24 9:59 ` Jan Kara
2020-04-24 10:07 ` Christoph Hellwig
2020-04-24 17:48 ` Darrick J. Wong
2020-04-24 22:39 ` Ritesh Harjani
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200424191739.GA217280@gmail.com \
--to=ebiggers@kernel.org \
--cc=aneesh.kumar@linux.ibm.com \
--cc=darrick.wong@oracle.com \
--cc=hch@infradead.org \
--cc=jack@suse.com \
--cc=linux-ext4@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=riteshh@linux.ibm.com \
--cc=tytso@mit.edu \
--cc=viro@zeniv.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).