From: ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org (Eric W. Biederman)
To: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
Cc: linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Linux Containers
<containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Andrew Morton
<akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org>,
Alexander Viro
<viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.org>,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Subject: Re: [PATCH v2 1/2] coredump: use from_kuid/kgid when formatting corename
Date: Fri, 15 May 2015 09:52:59 -0500 [thread overview]
Message-ID: <87d221yjsk.fsf@x220.int.ebiederm.org> (raw)
In-Reply-To: <1431656975-3563-1-git-send-email-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org> (Nicolas Iooss's message of "Fri, 15 May 2015 10:29:34 +0800")
Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org> writes:
> When adding __printf attribute to cn_printf, gcc reports some issues:
>
> fs/coredump.c:213:5: warning: format '%d' expects argument of type
> 'int', but argument 3 has type 'kuid_t' [-Wformat=]
> err = cn_printf(cn, "%d", cred->uid);
> ^
> fs/coredump.c:217:5: warning: format '%d' expects argument of type
> 'int', but argument 3 has type 'kgid_t' [-Wformat=]
> err = cn_printf(cn, "%d", cred->gid);
> ^
>
> These warnings come from the fact that the value of uid/gid needs to be
> extracted from the kuid_t/kgid_t structure before being used as an
> integer. More precisely, cred->uid and cred->gid need to be converted
> to either user-namespace uid/gid or to init_user_ns uid/gid.
>
> Use init_user_ns in order not to break existing ABI, and document this
> in Documentation/sysctl/kernel.txt.
>
> While at it, format uid and gid values with %u instead of %d because
> uid_t/__kernel_uid32_t and gid_t/__kernel_gid32_t are unsigned int.
Acked-by: "Eric W. Biederman" <ebiederm-aS9lmoZGLiVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Nicolas Iooss <nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
> ---
> Documentation/sysctl/kernel.txt | 4 ++--
> fs/coredump.c | 8 ++++++--
> 2 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt
> index c831001c45f1..e1913f78f21e 100644
> --- a/Documentation/sysctl/kernel.txt
> +++ b/Documentation/sysctl/kernel.txt
> @@ -197,8 +197,8 @@ core_pattern is used to specify a core dumpfile pattern name.
> %P global pid (init PID namespace)
> %i tid
> %I global tid (init PID namespace)
> - %u uid
> - %g gid
> + %u uid (in initial user namespace)
> + %g gid (in initial user namespace)
> %d dump mode, matches PR_SET_DUMPABLE and
> /proc/sys/fs/suid_dumpable
> %s signal number
> diff --git a/fs/coredump.c b/fs/coredump.c
> index bbbe139ab280..833a57bc856c 100644
> --- a/fs/coredump.c
> +++ b/fs/coredump.c
> @@ -209,11 +209,15 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm)
> break;
> /* uid */
> case 'u':
> - err = cn_printf(cn, "%d", cred->uid);
> + err = cn_printf(cn, "%u",
> + from_kuid(&init_user_ns,
> + cred->uid));
> break;
> /* gid */
> case 'g':
> - err = cn_printf(cn, "%d", cred->gid);
> + err = cn_printf(cn, "%u",
> + from_kgid(&init_user_ns,
> + cred->gid));
> break;
> case 'd':
> err = cn_printf(cn, "%d",
next prev parent reply other threads:[~2015-05-15 14:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1429181404.2850.44.camel@perches.com>
[not found] ` <1430649246-32726-1-git-send-email-nicolas.iooss_linux@m4x.org>
[not found] ` <1430649246-32726-1-git-send-email-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2015-05-05 19:13 ` [PATCH 1/2] coredump: use from_kuid/kgid_munged when formatting corename Eric W. Biederman
[not found] ` <87bnhyhm7f.fsf-JOvCrm2gF+uungPnsOpG7nhyD016LWXt@public.gmane.org>
2015-05-06 12:18 ` Nicolas Iooss
[not found] ` <554A0684.2000400-oWGTIYur0i8@public.gmane.org>
2015-05-15 2:29 ` [PATCH v2 1/2] coredump: use from_kuid/kgid " Nicolas Iooss
[not found] ` <1431656975-3563-1-git-send-email-nicolas.iooss_linux@m4x.org>
[not found] ` <1431656975-3563-1-git-send-email-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2015-05-15 2:29 ` [PATCH v2 2/2] coredump: add __printf attribute to cn_*printf functions Nicolas Iooss
2015-05-15 14:52 ` Eric W. Biederman [this message]
[not found] ` <1431656975-3563-2-git-send-email-nicolas.iooss_linux@m4x.org>
[not found] ` <1431656975-3563-2-git-send-email-nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org>
2015-05-15 14:54 ` Eric W. Biederman
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=87d221yjsk.fsf@x220.int.ebiederm.org \
--to=ebiederm-as9lmozglivwk0htik3j/w@public.gmane.org \
--cc=akpm-de/tnXTf+JLsfHDXvbKv3WD2FQJk+8+b@public.gmane.org \
--cc=containers-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-fsdevel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nicolas.iooss_linux-oWGTIYur0i8@public.gmane.org \
--cc=viro-RmSDqhL/yNMiFSDQTTA3OLVCufUGDwFn@public.gmane.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