Package: atop
Severity: wishlist
Tags: patch
User: ubuntu-de...@lists.ubuntu.com
Usertags: origin-ubuntu mantic ubuntu-patch
X-Debbugs-Cc: vladimir.pe...@canonical.com
Dear Maintainer,
When the atopacctd service crashes, it may leave a 0-length shadow file.
atopacctd() routine tries to read it and fails. It returns 1 (success)
and sets maxshadowrec size to the size from the 'current' file. The rest
of the code assumes that the shadow file read was successful and tries
to use an empty acct structure, causing a division by zero.
This was reproduced during armhf autopkgtest in Ubuntu because atopacctd did
not have sufficient permissions to run.
The issue was fixed upstream and the commit was applied as a patch.
In Ubuntu, the attached patch was applied to achieve the following:
* d/p/atopacctd_return_error.patch: apply upstream patch to fix SIGFPE in
acctprocnt() (LP: #1725896, LP: #2037910).
Thanks for considering the patch.
-- System Information:
Debian Release: bookworm/sid
APT prefers lunar-updates
APT policy: (500, 'lunar-updates'), (500, 'lunar-security'), (500, 'lunar'),
(100, 'lunar-backports')
Architecture: amd64 (x86_64)
Foreign Architectures: i386
Kernel: Linux 6.2.0-34-generic (SMP w/32 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_OOT_MODULE
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE=en
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
diff -Nru atop-2.9.0/debian/patches/atopacctd_return_error.patch
atop-2.9.0/debian/patches/atopacctd_return_error.patch
--- atop-2.9.0/debian/patches/atopacctd_return_error.patch 1970-01-01
12:00:00.0 +1200
+++ atop-2.9.0/debian/patches/atopacctd_return_error.patch 2023-10-05
15:25:12.0 +1300
@@ -0,0 +1,31 @@
+Description: Avoid floating point exception when atopacctd fails
+ When the atopacctd service crashes, it may leave a 0-length shadow file.
+ atopacctd() routine tries to read it and fails. It returns 1 (success)
+ and sets maxshadowrec size to the size from the 'current' file. The rest
+ of the code assumes that the shadow file read was successful and tries
+ to use an empty acct structure, causing a division by zero.
+Author: Gerlof Langeveld
+Bug: https://github.com/Atoptool/atop/issues/277
+Bug-Ubuntu: https://bugs.launchpad.net/ubuntu/+source/atop/+bug/2037910
+Applied-Upstream:
https://github.com/Atoptool/atop/commit/f72f7c06278ec9ad2209975eca67c2e3c0b3a44b
+Last-Update: 2023-10-08
+--- a/acctproc.c
b/acctproc.c
+@@ -430,7 +430,6 @@ atopacctd(int swon)
+ {
+ if ( swon && !acctvers(acctfd) )
+ {
+-
+ int maxcnt = 40;
+
+ if ( fork() == 0 )
+@@ -453,7 +452,8 @@ atopacctd(int swon)
+ , 1);
+
+ regainrootprivs();
+- return 1;
++ maxshadowrec = 0;
++ return -1; // try other
+ }
+ }
+
diff -Nru atop-2.9.0/debian/patches/series atop-2.9.0/debian/patches/series
--- atop-2.9.0/debian/patches/series2023-07-02 02:37:19.0 +1200
+++ atop-2.9.0/debian/patches/series2023-10-05 15:25:12.0 +1300
@@ -15,3 +15,4 @@
no-atopgpud
handle-default-file
default
+atopacctd_return_error.patch