From: Stephen Hemminger <stephen@networkplumber.org>
To: Junxiao Shi <git@mail1.yoursunny.com>
Cc: dev@dpdk.org
Subject: Re: [RFC PATCH] net/memif: change socket listener owner uid/gid
Date: Tue, 15 Nov 2022 15:53:44 -0800 [thread overview]
Message-ID: <20221115155344.17a5ed4c@hermes.local> (raw)
In-Reply-To: <c079a935de8f9101@cs.arizona.edu>
On Tue, 15 Nov 2022 20:44:41 +0000
Junxiao Shi <git@mail1.yoursunny.com> wrote:
> +static int
> +memif_set_owner_uid(const char *key __rte_unused, const char *value, void *extra_args)
> +{
> + uid_t *uid = (uid_t *)extra_args;
> + *uid = strtoul(value, NULL, 10);
> + return 0;
> +}
> +
> +static int
> +memif_set_owner_gid(const char *key __rte_unused, const char *value, void *extra_args)
> +{
> + gid_t *gid = (gid_t *)extra_args;
> + *gid = strtoul(value, NULL, 10);
> + return 0;
> +}
> +
This should be one function and it should check for valid arguments.
Things like not a number, extra characters, and out of range.
Modern Linux allows 32 bits of uid. with some values like -1 reserved.
On a 64 bit system like most DPDK usage, sizeof(unsigned long) is 64 bits.
Since uid and gid have same restrictions, then something like this (untested):
static int strtouid(const char *value, uint32_t *id)
{
unsigned long val;
char *endp;
val = strtoul(value, &endp, 10);
if (*value == '\0' || *endp != '\0')
return -EINVAL;
if (val >= UINT32_MAX)
return -ERANGE;
*id = val;
return 0;
}
next prev parent reply other threads:[~2022-11-15 23:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-15 20:44 Junxiao Shi
2022-11-15 23:53 ` Stephen Hemminger [this message]
2022-11-16 13:09 ` [RFC PATCH v2] " Junxiao Shi
2022-11-16 17:04 ` Stephen Hemminger
2022-11-16 17:14 ` [RFC PATCH v3] " Junxiao Shi
2022-11-16 17:14 ` [PATCH] " Junxiao Shi
2022-12-07 14:28 ` Ferruh Yigit
2022-12-07 14:41 ` [PATCH v2] " Junxiao Shi
2022-12-07 15:43 ` Ferruh Yigit
2022-12-07 16:56 ` Ferruh Yigit
2022-12-07 17:48 ` Junxiao Shi
2022-12-08 14:29 ` Ferruh Yigit
2022-12-07 15:53 ` [PATCH v3] " Junxiao Shi
2022-12-08 16:25 ` Ferruh Yigit
2022-12-08 16:25 ` Ferruh Yigit
2022-11-16 17:52 ` [RFC PATCH " Stephen Hemminger
2022-12-07 11:43 ` Ferruh Yigit
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=20221115155344.17a5ed4c@hermes.local \
--to=stephen@networkplumber.org \
--cc=dev@dpdk.org \
--cc=git@mail1.yoursunny.com \
/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).