From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934694AbbEOO56 (ORCPT ); Fri, 15 May 2015 10:57:58 -0400 Received: from out03.mta.xmission.com ([166.70.13.233]:40726 "EHLO out03.mta.xmission.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754891AbbEOO5s (ORCPT ); Fri, 15 May 2015 10:57:48 -0400 From: ebiederm@xmission.com (Eric W. Biederman) To: Nicolas Iooss Cc: Alexander Viro , linux-fsdevel@vger.kernel.org, Andrew Morton , linux-kernel@vger.kernel.org, Linux Containers References: <554A0684.2000400@m4x.org> <1431656975-3563-1-git-send-email-nicolas.iooss_linux@m4x.org> Date: Fri, 15 May 2015 09:52:59 -0500 In-Reply-To: <1431656975-3563-1-git-send-email-nicolas.iooss_linux@m4x.org> (Nicolas Iooss's message of "Fri, 15 May 2015 10:29:34 +0800") Message-ID: <87d221yjsk.fsf@x220.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-AID: U2FsdGVkX19Ecq7Nazm+tRucWujh9L1Po4QO69rANts= X-SA-Exim-Connect-IP: 67.3.205.90 X-SA-Exim-Mail-From: ebiederm@xmission.com X-Spam-Report: * -1.0 ALL_TRUSTED Passed through trusted hosts only via SMTP * 0.7 XMSubLong Long Subject * 0.0 TVD_RCVD_IP Message was received from an IP address * 0.0 T_TM2_M_HEADER_IN_MSG BODY: No description available. * 0.8 BAYES_50 BODY: Bayes spam probability is 40 to 60% * [score: 0.5000] * -0.0 DCC_CHECK_NEGATIVE Not listed in DCC * [sa07 1397; Body=1 Fuz1=1 Fuz2=1] * 0.5 XM_Body_Dirty_Words Contains a dirty word * 0.0 T_TooManySym_01 4+ unique symbols in subject * 0.4 XMBrknScrpt_02 Possible Broken Spam Script * 1.2 XMSubMetaSxObfu_03 Obfuscated Sexy Noun-People * 1.0 XMSubMetaSx_00 1+ Sexy Words * 1.0 XMSexyCombo_01 Sexy words in both body/subject X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ****;Nicolas Iooss X-Spam-Relay-Country: X-Spam-Timing: total 352 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 3.8 (1.1%), b_tie_ro: 2.6 (0.8%), parse: 0.67 (0.2%), extract_message_metadata: 17 (4.7%), get_uri_detail_list: 2.6 (0.7%), tests_pri_-1000: 7 (1.9%), tests_pri_-950: 1.24 (0.4%), tests_pri_-900: 1.06 (0.3%), tests_pri_-400: 21 (5.9%), check_bayes: 20 (5.6%), b_tokenize: 6 (1.8%), b_tok_get_all: 6 (1.7%), b_comp_prob: 1.76 (0.5%), b_tok_touch_all: 2.7 (0.8%), b_finish: 0.69 (0.2%), tests_pri_0: 289 (82.1%), tests_pri_500: 9 (2.5%), rewrite_mail: 0.00 (0.0%) Subject: Re: [PATCH v2 1/2] coredump: use from_kuid/kgid when formatting corename X-Spam-Flag: No X-SA-Exim-Version: 4.2.1 (built Wed, 24 Sep 2014 11:00:52 -0600) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Nicolas Iooss 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" > Signed-off-by: Nicolas Iooss > --- > 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",