diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2014-04-19 14:37:20 -0400 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2014-08-07 14:40:07 -0400 |
commit | ed44724b79d8e03a40665436019cf22baba80d30 (patch) | |
tree | 9062239f57fbffff21bbd81cf28b6dc45081722b | |
parent | ecfdb33d1fbc7e6e095ba24dac2930208494e734 (diff) |
acct: switch to __kernel_write()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
-rw-r--r-- | fs/internal.h | 1 | ||||
-rw-r--r-- | include/linux/fs.h | 1 | ||||
-rw-r--r-- | kernel/acct.c | 31 |
3 files changed, 13 insertions, 20 deletions
diff --git a/fs/internal.h b/fs/internal.h index 465742407466..9a2edba87c2b 100644 --- a/fs/internal.h +++ b/fs/internal.h | |||
@@ -131,7 +131,6 @@ extern long prune_dcache_sb(struct super_block *sb, unsigned long nr_to_scan, | |||
131 | /* | 131 | /* |
132 | * read_write.c | 132 | * read_write.c |
133 | */ | 133 | */ |
134 | extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); | ||
135 | extern int rw_verify_area(int, struct file *, const loff_t *, size_t); | 134 | extern int rw_verify_area(int, struct file *, const loff_t *, size_t); |
136 | 135 | ||
137 | /* | 136 | /* |
diff --git a/include/linux/fs.h b/include/linux/fs.h index e11d60cc867b..4b7d57cf7863 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h | |||
@@ -2335,6 +2335,7 @@ extern int do_pipe_flags(int *, int); | |||
2335 | 2335 | ||
2336 | extern int kernel_read(struct file *, loff_t, char *, unsigned long); | 2336 | extern int kernel_read(struct file *, loff_t, char *, unsigned long); |
2337 | extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); | 2337 | extern ssize_t kernel_write(struct file *, const char *, size_t, loff_t); |
2338 | extern ssize_t __kernel_write(struct file *, const char *, size_t, loff_t *); | ||
2338 | extern struct file * open_exec(const char *); | 2339 | extern struct file * open_exec(const char *); |
2339 | 2340 | ||
2340 | /* fs/dcache.c -- generic fs support functions */ | 2341 | /* fs/dcache.c -- generic fs support functions */ |
diff --git a/kernel/acct.c b/kernel/acct.c index 807ebc5d8333..8082d9875d6b 100644 --- a/kernel/acct.c +++ b/kernel/acct.c | |||
@@ -456,12 +456,16 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
456 | { | 456 | { |
457 | struct pacct_struct *pacct = ¤t->signal->pacct; | 457 | struct pacct_struct *pacct = ¤t->signal->pacct; |
458 | acct_t ac; | 458 | acct_t ac; |
459 | mm_segment_t fs; | ||
460 | unsigned long flim; | 459 | unsigned long flim; |
461 | u64 elapsed, run_time; | 460 | u64 elapsed, run_time; |
462 | struct tty_struct *tty; | 461 | struct tty_struct *tty; |
463 | const struct cred *orig_cred; | 462 | const struct cred *orig_cred; |
464 | 463 | ||
464 | /* | ||
465 | * Accounting records are not subject to resource limits. | ||
466 | */ | ||
467 | flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
468 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; | ||
465 | /* Perform file operations on behalf of whoever enabled accounting */ | 469 | /* Perform file operations on behalf of whoever enabled accounting */ |
466 | orig_cred = override_creds(file->f_cred); | 470 | orig_cred = override_creds(file->f_cred); |
467 | 471 | ||
@@ -536,25 +540,14 @@ static void do_acct_process(struct bsd_acct_struct *acct, | |||
536 | * Get freeze protection. If the fs is frozen, just skip the write | 540 | * Get freeze protection. If the fs is frozen, just skip the write |
537 | * as we could deadlock the system otherwise. | 541 | * as we could deadlock the system otherwise. |
538 | */ | 542 | */ |
539 | if (!file_start_write_trylock(file)) | 543 | if (file_start_write_trylock(file)) { |
540 | goto out; | 544 | /* it's been opened O_APPEND, so position is irrelevant */ |
541 | /* | 545 | loff_t pos = 0; |
542 | * Kernel segment override to datasegment and write it | 546 | __kernel_write(file, (char *)&ac, sizeof(acct_t), &pos); |
543 | * to the accounting file. | 547 | file_end_write(file); |
544 | */ | 548 | } |
545 | fs = get_fs(); | ||
546 | set_fs(KERNEL_DS); | ||
547 | /* | ||
548 | * Accounting records are not subject to resource limits. | ||
549 | */ | ||
550 | flim = current->signal->rlim[RLIMIT_FSIZE].rlim_cur; | ||
551 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = RLIM_INFINITY; | ||
552 | file->f_op->write(file, (char *)&ac, | ||
553 | sizeof(acct_t), &file->f_pos); | ||
554 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; | ||
555 | set_fs(fs); | ||
556 | file_end_write(file); | ||
557 | out: | 549 | out: |
550 | current->signal->rlim[RLIMIT_FSIZE].rlim_cur = flim; | ||
558 | revert_creds(orig_cred); | 551 | revert_creds(orig_cred); |
559 | } | 552 | } |
560 | 553 | ||