summaryrefslogtreecommitdiffstats
path: root/kernel/acct.c
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2009-08-20 14:39:52 -0700
committerJames Morris <jmorris@namei.org>2009-08-24 11:33:40 +1000
commitd8e180dcd5bbbab9cd3ff2e779efcf70692ef541 (patch)
tree0d2f864e4673df4abf994e222616651409a91c0a /kernel/acct.c
parent939a9421eb53d3ea83188ae13802779041caefdb (diff)
downloadop-kernel-dev-d8e180dcd5bbbab9cd3ff2e779efcf70692ef541.zip
op-kernel-dev-d8e180dcd5bbbab9cd3ff2e779efcf70692ef541.tar.gz
bsdacct: switch credentials for writing to the accounting file
When process accounting is enabled, every exiting process writes a log to the account file. In addition, every once in a while one of the exiting processes checks whether there's enough free space for the log. SELinux policy may or may not allow the exiting process to stat the fs. So unsuspecting processes start generating AVC denials just because someone enabled process accounting. For these filesystem operations, the exiting process's credentials should be temporarily switched to that of the process which enabled accounting, because it's really that process which wanted to have the accounting information logged. Signed-off-by: Michal Schmidt <mschmidt@redhat.com> Acked-by: David Howells <dhowells@redhat.com> Acked-by: Serge Hallyn <serue@us.ibm.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'kernel/acct.c')
-rw-r--r--kernel/acct.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/kernel/acct.c b/kernel/acct.c
index 9f33910..9a4715a 100644
--- a/kernel/acct.c
+++ b/kernel/acct.c
@@ -491,13 +491,17 @@ static void do_acct_process(struct bsd_acct_struct *acct,
u64 run_time;
struct timespec uptime;
struct tty_struct *tty;
+ const struct cred *orig_cred;
+
+ /* Perform file operations on behalf of whoever enabled accounting */
+ orig_cred = override_creds(file->f_cred);
/*
* First check to see if there is enough free_space to continue
* the process accounting system.
*/
if (!check_free_space(acct, file))
- return;
+ goto out;
/*
* Fill the accounting struct with the needed info as recorded
@@ -578,6 +582,8 @@ static void do_acct_process(struct bsd_acct_struct *acct,
sizeof(acct_t), &file->f_pos);
current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim;
set_fs(fs);
+out:
+ revert_creds(orig_cred);
}
/**
OpenPOWER on IntegriCloud