linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: David Howells <dhowells@redhat.com>
To: miklos@szeredi.hu, viro@zeniv.linux.org.uk
Cc: linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org,
	dhowells@redhat.com, anprice@redhat.com
Subject: [RFC PATCH 2/4] vfs: Make fs_parse() handle fs_param_is_fd-type params better
Date: Tue, 19 Mar 2019 16:23:38 +0000	[thread overview]
Message-ID: <155301261872.7556.14287203880762974502.stgit@warthog.procyon.org.uk> (raw)
In-Reply-To: <155301260319.7556.1326405089184672936.stgit@warthog.procyon.org.uk>

Make fs_parse() handle fs_param_is_fd-type parameters that are passed a
string by converting it to an integer (in addition to handling direct fd
specification).

Also range check the integer.

Signed-off-by: David Howells <dhowells@redhat.com>
---

 fs/fs_parser.c |   15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/fs/fs_parser.c b/fs/fs_parser.c
index be86703ec371..bd59e1725c50 100644
--- a/fs/fs_parser.c
+++ b/fs/fs_parser.c
@@ -208,9 +208,20 @@ int fs_parse(struct fs_context *fc,
 		goto okay;
 
 	case fs_param_is_fd: {
-		if (param->type != fs_value_is_file)
+		switch (param->type) {
+		case fs_value_is_string:
+			ret = kstrtouint(param->string, 0, &result->uint_32);
+			break;
+		case fs_value_is_file:
+			result->uint_32 = param->dirfd;
+			ret = 0;
+		default:
 			goto bad_value;
-		goto okay;
+		}
+
+		if (result->uint_32 > INT_MAX)
+			goto bad_value;
+		goto maybe_okay;
 	}
 
 	case fs_param_is_blockdev:


  parent reply	other threads:[~2019-03-19 16:23 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 16:23 [RFC PATCH 0/4] fuse: Convert to fs_context David Howells
2019-03-19 16:23 ` [RFC PATCH 1/4] vfs: Create fs_context-aware mount_bdev() replacement David Howells
2019-03-26 21:02   ` Andrew Price
2019-03-27 11:23   ` David Howells
2019-03-27 13:51     ` Andrew Price
2019-03-19 16:23 ` David Howells [this message]
2019-03-19 16:23 ` [RFC PATCH 3/4] fuse: Convert to mount API David Howells
2019-03-19 16:23 ` [RFC PATCH 4/4] fuse: Move the subtype parameter into fuse David Howells

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=155301261872.7556.14287203880762974502.stgit@warthog.procyon.org.uk \
    --to=dhowells@redhat.com \
    --cc=anprice@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=miklos@szeredi.hu \
    --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).