linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Carlos Maiolino <cmaiolino@redhat.com>
To: linux-fsdevel@vger.kernel.org
Subject: [PATCH] fibmap: Reject negative addresses
Date: Mon, 18 Mar 2019 17:10:04 +0100	[thread overview]
Message-ID: <20190318161004.10743-1-cmaiolino@redhat.com> (raw)

FIBMAP receives an integer from userspace which is then implicitly
converted into sector_t on ->bmap(). No check is made to ensure
userspace didn't send a negative address, which can confuse the ->bmap
interface, and return fuzzy addresses.

Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com>
---

I am not 100% sure if is there any reason for ->bmap interface to accept
negative values, from the top of my mind, I really can't see a reason, if there
is a reason why we don't check for negative addresses, I'd be happy to know,
otherwise we should reject it.

Cheers

 fs/ioctl.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/ioctl.c b/fs/ioctl.c
index fef3a6bf7c78..e3a01c43adb4 100644
--- a/fs/ioctl.c
+++ b/fs/ioctl.c
@@ -64,6 +64,11 @@ static int ioctl_fibmap(struct file *filp, int __user *p)
 	res = get_user(block, p);
 	if (res)
 		return res;
+
+	/* No reason to query a negative block addr */
+	if (block < 0)
+		return -EINVAL;
+
 	res = mapping->a_ops->bmap(mapping, block);
 	return put_user(res, p);
 }
-- 
2.20.1


             reply	other threads:[~2019-03-18 16:10 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-18 16:10 Carlos Maiolino [this message]
2019-03-19 19:30 ` [PATCH] fibmap: Reject negative addresses Eric Sandeen
2019-03-20 12:28   ` Carlos Maiolino

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=20190318161004.10743-1-cmaiolino@redhat.com \
    --to=cmaiolino@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    /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).