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 /kernel | |
parent | ecfdb33d1fbc7e6e095ba24dac2930208494e734 (diff) |
acct: switch to __kernel_write()
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'kernel')
-rw-r--r-- | kernel/acct.c | 31 |
1 files changed, 12 insertions, 19 deletions
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 | ||