Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1209542
| From | Andrew Morton <akpm@linux-foundation.org> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t |
| Date | 2015-08-19 01:50 +0200 |
| Message-ID | <pYYNI-5lR-7@gated-at.bofh.it> (permalink) |
| References | <pYQds-BV-11@gated-at.bofh.it> <pYQQb-1B4-23@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Tue, 18 Aug 2015 17:18:19 +0200 Dongsu Park <dpark@posteo.net> wrote:
> To allow devpts to be mounted with options of uid/gid of uint32_t,
> use kstrtouint() instead of match_int(). Doing that, mounting devpts
> with uid or gid > (2^31 - 1) will work as expected, e.g.:
>
> # mount -t devpts devpts /tmp/devptsdir -o \
> newinstance,ptmxmode=0666,mode=620,uid=3598450688,gid=3598450693
>
> It was originally by reported on systemd github issues:
> https://github.com/systemd/systemd/issues/956
>
> --- a/fs/devpts/inode.c
> +++ b/fs/devpts/inode.c
> @@ -188,23 +188,35 @@ static int parse_mount_options(char *data, int op, struct pts_mount_opts *opts)
> token = match_token(p, tokens, args);
> switch (token) {
> case Opt_uid:
> - if (match_int(&args[0], &option))
> + {
It might be neater to lay this out as
case Opt_uid: {
> + char *uidstr = args[0].from;
> + uid_t uidval;
> + int rc = kstrtouint(uidstr, 0, &uidval);
This assumes that the architecture/config uses a uint for uid_t. We
have no business assuming this - it's an opaque type for a reason. It
would be safer to do
unsigned long uidl;
rc = kstrtoul(uidstr, 0, &uidl);
uidval = uidl;
> + if (rc)
> return -EINVAL;
I don't get it. From my reading, kstrtouint->parse_integer() returns
"number of characters parsed or -E". So this code won't work. But
presumably it *does* work, so why?
Also, we should probably return `rc' here if it's negative, to
propagate the error which kstrtouint() detected. That's a minor
non-back-compatible change but it shouldn't matter.
otoh, kstrtouint() likes to return -ERANGE when things go wrong.
ERANGE means "Math result not representable", which is a nonsenscal
error code in this context. Sigh, why do people keep doing this.
> - uid = make_kuid(current_user_ns(), option);
> + uid = make_kuid(current_user_ns(), uidval);
> if (!uid_valid(uid))
> return -EINVAL;
> opts->uid = uid;
> opts->setuid = 1;
> break;
>
> ...
>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
[PATCH] devpts: allow mounting with uid/gid of uint32_t Dongsu Park <dpark@posteo.net> - 2015-08-18 16:40 +0200
[PATCH v2] devpts: allow mounting with uid/gid of uint32_t Dongsu Park <dpark@posteo.net> - 2015-08-18 17:20 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Andrew Morton <akpm@linux-foundation.org> - 2015-08-19 01:50 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Dongsu Park <dpark@posteo.net> - 2015-08-19 09:30 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Andrew Morton <akpm@linux-foundation.org> - 2015-08-19 09:50 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Rasmus Villemoes <linux@rasmusvillemoes.dk> - 2015-08-19 10:40 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Alexey Dobriyan <adobriyan@gmail.com> - 2015-08-19 12:50 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Peter Hurley <peter@hurleysoftware.com> - 2015-08-28 21:40 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Dongsu Park <dpark@posteo.net> - 2015-08-29 13:00 +0200
Re: [PATCH v2] devpts: allow mounting with uid/gid of uint32_t Alexey Dobriyan <adobriyan@gmail.com> - 2015-08-29 23:50 +0200
csiph-web