hc
2024-05-10 61598093bbdd283a7edc367d900f223070ead8d2
kernel/kernel/acct.c
....@@ -25,7 +25,7 @@
2525 * Now we silently close acct_file on attempt to reopen. Cleaned sys_acct().
2626 * XTerms and EMACS are manifestations of pure evil. 21/10/98, AV.
2727 *
28
- * Fixed a nasty interaction with with sys_umount(). If the accointing
28
+ * Fixed a nasty interaction with sys_umount(). If the accounting
2929 * was suspeneded we failed to stop it on umount(). Messy.
3030 * Another one: remount to readonly didn't stop accounting.
3131 * Question: what should we do if we have CAP_SYS_ADMIN but not
....@@ -40,7 +40,7 @@
4040 * is one more bug... 10/11/98, AV.
4141 *
4242 * Oh, fsck... Oopsable SMP race in do_process_acct() - we must hold
43
- * ->mmap_sem to walk the vma list of current->mm. Nasty, since it leaks
43
+ * ->mmap_lock to walk the vma list of current->mm. Nasty, since it leaks
4444 * a struct file opened for write. Fixed. 2/6/2000, AV.
4545 */
4646
....@@ -263,12 +263,12 @@
263263 * sys_acct - enable/disable process accounting
264264 * @name: file name for accounting records or NULL to shutdown accounting
265265 *
266
- * Returns 0 for success or negative errno values for failure.
267
- *
268266 * sys_acct() is the only system call needed to implement process
269267 * accounting. It takes the name of the file where accounting records
270268 * should be written. If the filename is NULL, accounting will be
271269 * shutdown.
270
+ *
271
+ * Returns: 0 for success or negative errno values for failure.
272272 */
273273 SYSCALL_DEFINE1(acct, const char __user *, name)
274274 {
....@@ -331,6 +331,8 @@
331331 exp++;
332332 }
333333
334
+ if (exp > (((comp_t) ~0U) >> MANTSIZE))
335
+ return (comp_t) ~0U;
334336 /*
335337 * Clean it up and polish it off.
336338 */
....@@ -416,6 +418,7 @@
416418 {
417419 struct pacct_struct *pacct = &current->signal->pacct;
418420 u64 elapsed, run_time;
421
+ time64_t btime;
419422 struct tty_struct *tty;
420423
421424 /*
....@@ -448,7 +451,8 @@
448451 }
449452 #endif
450453 do_div(elapsed, AHZ);
451
- ac->ac_btime = get_seconds() - elapsed;
454
+ btime = ktime_get_real_seconds() - elapsed;
455
+ ac->ac_btime = clamp_t(time64_t, btime, 0, U32_MAX);
452456 #if ACCT_VERSION==2
453457 ac->ac_ahz = AHZ;
454458 #endif
....@@ -539,13 +543,13 @@
539543 if (group_dead && current->mm) {
540544 struct vm_area_struct *vma;
541545
542
- down_read(&current->mm->mmap_sem);
546
+ mmap_read_lock(current->mm);
543547 vma = current->mm->mmap;
544548 while (vma) {
545549 vsize += vma->vm_end - vma->vm_start;
546550 vma = vma->vm_next;
547551 }
548
- up_read(&current->mm->mmap_sem);
552
+ mmap_read_unlock(current->mm);
549553 }
550554
551555 spin_lock_irq(&current->sighand->siglock);
....@@ -584,9 +588,7 @@
584588 }
585589
586590 /**
587
- * acct_process
588
- *
589
- * handles process accounting for an exiting task
591
+ * acct_process - handles process accounting for an exiting task
590592 */
591593 void acct_process(void)
592594 {