aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorNicolas Iooss <nicolas.iooss_linux@m4x.org>2015-06-25 18:03:51 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2015-06-25 20:00:43 -0400
commit5202efe544c279be152f44f2821010ff7b2d7e5b (patch)
tree35d7726c6314074c18963cd08d7351ea50f1f0db /fs
parent89bfae43c8999344c3025802a3652ac42f55278e (diff)
coredump: use from_kuid/kgid when formatting corename
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. Signed-off-by: Nicolas Iooss <nicolas.iooss_linux@m4x.org> Acked-by: "Eric W. Biederman" <ebiederm@xmission.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/coredump.c8
1 files changed, 6 insertions, 2 deletions
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)
209 break; 209 break;
210 /* uid */ 210 /* uid */
211 case 'u': 211 case 'u':
212 err = cn_printf(cn, "%d", cred->uid); 212 err = cn_printf(cn, "%u",
213 from_kuid(&init_user_ns,
214 cred->uid));
213 break; 215 break;
214 /* gid */ 216 /* gid */
215 case 'g': 217 case 'g':
216 err = cn_printf(cn, "%d", cred->gid); 218 err = cn_printf(cn, "%u",
219 from_kgid(&init_user_ns,
220 cred->gid));
217 break; 221 break;
218 case 'd': 222 case 'd':
219 err = cn_printf(cn, "%d", 223 err = cn_printf(cn, "%d",