Skip to content

Commit f8f3d4d

Browse files
committed
userns: Convert bsd process accounting to use kuid and kgid where appropriate
BSD process accounting conveniently passes the file the accounting records will be written into to do_acct_process. The file credentials captured the user namespace of the opener of the file. Use the file credentials to format the uid and the gid of the current process into the user namespace of the user that started the bsd process accounting. Cc: Pavel Emelyanov <[email protected]> Reviewed-by: Serge Hallyn <[email protected]> Signed-off-by: Eric W. Biederman <[email protected]>
1 parent 4bd6e32 commit f8f3d4d

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

init/Kconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -931,7 +931,6 @@ config UIDGID_CONVERTED
931931
depends on FS_POSIX_ACL = n
932932
depends on QUOTA = n
933933
depends on QUOTACTL = n
934-
depends on BSD_PROCESS_ACCT = n
935934

936935
# Networking
937936
depends on NET_9P = n

kernel/acct.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,8 +507,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
507507
do_div(elapsed, AHZ);
508508
ac.ac_btime = get_seconds() - elapsed;
509509
/* we really need to bite the bullet and change layout */
510-
ac.ac_uid = orig_cred->uid;
511-
ac.ac_gid = orig_cred->gid;
510+
ac.ac_uid = from_kuid_munged(file->f_cred->user_ns, orig_cred->uid);
511+
ac.ac_gid = from_kgid_munged(file->f_cred->user_ns, orig_cred->gid);
512512
#if ACCT_VERSION==2
513513
ac.ac_ahz = AHZ;
514514
#endif

0 commit comments

Comments
 (0)