Compare commits

...

3 Commits

Author SHA1 Message Date
Lukáš Zaoral 9137b9fbd3 add description of UMASK to man/systat.in 2023-09-29 12:28:31 +00:00
Pavel Šimovec 26bbb5c622 check_overflow() function can work incorrectly that lead to an overflow 2023-06-30 13:10:35 +02:00
Lukáš Zaoral ef63c0211a
Fix --dec argument validation
Resolves: rhbz#2080650
2023-02-21 13:26:40 +01:00
5 changed files with 186 additions and 1 deletions

1
.sysstat.metadata Normal file
View File

@ -0,0 +1 @@
597196f8f2be7a8960bec880c18eec875b27ff73 v12.5.4.tar.gz

View File

@ -0,0 +1,23 @@
From 954ff2e2673cef48f0ed44668c466eab041db387 Mon Sep 17 00:00:00 2001
From: Pavel Kopylov <pkopylov@cloudlinux.com>
Date: Wed, 17 May 2023 11:33:45 +0200
Subject: [PATCH] Fix an overflow which is still possible for some values.
diff --git a/common.c b/common.c
index 583a0ca..6d73b1b 100644
--- a/common.c
+++ b/common.c
@@ -1639,9 +1639,11 @@ int parse_values(char *strargv, unsigned char bitmap[], int max_val, const char
*/
void check_overflow(size_t val1, size_t val2, size_t val3)
{
- if ((unsigned long long) val1 *
- (unsigned long long) val2 *
- (unsigned long long) val3 > UINT_MAX) {
+if ((val1 != 0) && (val2 != 0) && (val3 != 0) &&
+ (((unsigned long long)UINT_MAX / (unsigned long long)val1 <
+ (unsigned long long)val2) ||
+ ((unsigned long long)UINT_MAX / ((unsigned long long)val1 *
+ (unsigned long long)val2) < (unsigned long long)val3))) {
#ifdef DEBUG
fprintf(stderr, "%s: Overflow detected (%llu). Aborting...\n",
__FUNCTION__,

View File

@ -0,0 +1,112 @@
From 398585bfe7b1340d41143f50dfc868ef8ab9a5e4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Zaoral?= <lzaoral@redhat.com>
Date: Tue, 21 Feb 2023 12:43:42 +0100
Subject: [PATCH] Tools that take --dec=X option should only accept digits
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Right now the argument of --dec is passed to atoi(3) which returns 0
on conversion error. Therefore, --dec=A was not rejected and was
equivalent to --dec=0 by mistake.
Signed-off-by: Lukáš Zaoral <lzaoral@redhat.com>
---
cifsiostat.c | 5 +++++
iostat.c | 5 +++++
mpstat.c | 5 +++++
pidstat.c | 5 +++++
sar.c | 6 ++++++
5 files changed, 26 insertions(+)
diff --git a/cifsiostat.c b/cifsiostat.c
index 375b1ff..849583b 100644
--- a/cifsiostat.c
+++ b/cifsiostat.c
@@ -522,6 +522,11 @@ int main(int argc, char **argv)
}
else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
+ /* Check that the argument is a digit */
+ if (!isdigit(argv[opt][6])) {
+ usage(argv[0]);
+ }
+
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
diff --git a/iostat.c b/iostat.c
index 1d7ea3c..7ac56ef 100644
--- a/iostat.c
+++ b/iostat.c
@@ -2142,6 +2142,11 @@ int main(int argc, char **argv)
#endif
else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
+ /* Check that the argument is a digit */
+ if (!isdigit(argv[opt][6])) {
+ usage(argv[0]);
+ }
+
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
diff --git a/mpstat.c b/mpstat.c
index 90d6226..5045e45 100644
--- a/mpstat.c
+++ b/mpstat.c
@@ -2221,6 +2221,11 @@ int main(int argc, char **argv)
while (++opt < argc) {
if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
+ /* Check that the argument is a digit */
+ if (!isdigit(argv[opt][6])) {
+ usage(argv[0]);
+ }
+
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
diff --git a/pidstat.c b/pidstat.c
index 21fed6c..d550605 100644
--- a/pidstat.c
+++ b/pidstat.c
@@ -2633,6 +2633,11 @@ int main(int argc, char **argv)
}
else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
+ /* Check that the argument is a digit */
+ if (!isdigit(argv[opt][6])) {
+ usage(argv[0]);
+ }
+
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
diff --git a/sar.c b/sar.c
index 4f06172..7691793 100644
--- a/sar.c
+++ b/sar.c
@@ -28,6 +28,7 @@
#include <errno.h>
#include <signal.h>
#include <sys/stat.h>
+#include <ctype.h>
#include "version.h"
#include "sa.h"
@@ -1372,6 +1373,11 @@ int main(int argc, char **argv)
}
else if (!strncmp(argv[opt], "--dec=", 6) && (strlen(argv[opt]) == 7)) {
+ /* Check that the argument is a digit */
+ if (!isdigit(argv[opt][6])) {
+ usage(argv[0]);
+ }
+
/* Get number of decimal places */
dplaces_nr = atoi(argv[opt] + 6);
if ((dplaces_nr < 0) || (dplaces_nr > 2)) {
--
2.39.2

View File

@ -0,0 +1,34 @@
From 370ad59826c2320288a1999ef9038e2a2655b8a0 Mon Sep 17 00:00:00 2001
From: Sebastien GODARD <sysstat@users.noreply.github.com>
Date: Thu, 22 Jun 2023 17:47:59 +0200
Subject: [PATCH] Add UMASK definition to sysstat(5) manual page (#362)
Explain UMASK variable in sysstat(5) manual page.
Signed-off-by: Sebastien GODARD <sysstat@users.noreply.github.com>
Cherry-picked-by: Lukáš Zaoral <lzaoral@redhat.com>
Upstream-commit: 370ad59826c2320288a1999ef9038e2a2655b8a0
---
man/sysstat.in | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/man/sysstat.in b/man/sysstat.in
index 6ce6b473..89bdd3f4 100644
--- a/man/sysstat.in
+++ b/man/sysstat.in
@@ -140,6 +140,15 @@ daily data files.
These options are used only when a new data file is created. They will be
ignored with an already existing one.
.TP
+.B UMASK
+.RB "The " "sa1" " and " "sa2"
+scripts generate system activity data and report files in the
+.IR /var/log/sa
+directory. By default the files are created with umask 0022
+and are therefore readable for all users. Change this variable to restrict
+the permissions on the files (e.g. use 0027 to adhere to more strict
+security standards).
+.TP
.B YESTERDAY
.RB "By default " "sa2"
script generates yesterday's summary, since the

View File

@ -1,7 +1,7 @@
Summary: Collection of performance monitoring tools for Linux
Name: sysstat
Version: 12.5.4
Release: 4%{?dist}
Release: 7%{?dist}
License: GPLv2+
URL: http://sebastien.godard.pagesperso-orange.fr/
Source: https://github.com/sysstat/sysstat/archive/v%{version}.tar.gz
@ -12,6 +12,12 @@ Source2: colorsysstat.sh
# arithmetic overflow in allocate_structures() on 32 bit systems (CVE-2022-39377)
Patch1: sysstat-12.5.4-CVE-2022-39377.patch
# {cifsio,io,mp,pid}stat --dec and sar --dec report values from single alphabet other than defined (bz2080650)
Patch2: sysstat-12.5.4-bz2080650.patch
# check_overflow() function can work incorrectly that lead to an overflow (CVE-2023-33204)
Patch3: sysstat-12.5.4-CVE-2023-33204.patch
# add description of UMASK to man/systat.in (bz2216805)
Patch4: sysstat-12.5.4-bz2216805.patch
BuildRequires: make
BuildRequires: gcc, gettext, lm_sensors-devel, pcp-libs-devel, systemd, git
@ -89,6 +95,15 @@ fi
%{_localstatedir}/log/sa
%changelog
* Thu Jul 27 2023 Lukáš Zaoral <lzaoral@redhat.com> - 12.5.4-7
- add description of UMASK to man/systat.in (rhbz#2216805)
* Fri Jun 30 2023 Pavel Šimovec <psimovec@redhat.com> - 12.5.4-6
- fix the arithmetic overflow in allocate_structures() that is still possible on some 32 bit systems (CVE-2023-33204)
* Tue Feb 21 2023 Lukáš Zaoral <lzaoral@redhat.com> - 12.5.4-5
- Fix --dec argument validation (rhbz#2080650)
* Thu Nov 10 2022 Lukáš Zaoral <lzaoral@redhat.com> - 12.5.4-4
- arithmetic overflow in allocate_structures() on 32 bit systems (CVE-2022-39377)