import smc-tools-1.6.1-1.git7202891.el8

This commit is contained in:
CentOS Sources 2022-05-10 03:15:33 -04:00 committed by Stepan Oksanichenko
parent c544a695ad
commit 4eca72a8b8
6 changed files with 10 additions and 205 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
SOURCES/smc-tools-393dd23.tar.gz
SOURCES/smc-tools-7202891.tar.gz

View File

@ -1 +1 @@
36bc253cf08f536eb67aa1ec10a4b04daf1fd467 SOURCES/smc-tools-393dd23.tar.gz
2d1bd702d2b8ab7f7731974ebfecbd2f32512115 SOURCES/smc-tools-7202891.tar.gz

View File

@ -1,74 +0,0 @@
From f365663e86fd06075bd5fe2d30bab0a64dc27b18 Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 09:54:03 +0200
Subject: [PATCH 1/3] smc-tools: stats: Fix memory overread in
is_data_consistent()
Fix memory overread in is_data_consistent() and merge_cache()
functions.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 13 +++++++------
2 files changed, 8 insertions(+), 6 deletions(-)
diff --git a/README.md b/README.md
index 2397475..5047f62 100644
--- a/README.md
+++ b/README.md
@@ -47,6 +47,7 @@ Release History:
- `smc_run`: Add various command-line switches
Bug fixes:
+ - `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index 2a00e42..d3a814f 100644
--- a/stats.c
+++ b/stats.c
@@ -900,7 +900,7 @@ static int is_data_consistent ()
cache++;
}
- size_fback = size + 2 * SMC_MAX_FBACK_RSN_CNT;
+ size_fback = 2 * SMC_MAX_FBACK_RSN_CNT;
kern_fbck = (struct smc_stats_fback *)&smc_rsn;
for (i = 0; i < size_fback; i++) {
val_err = kern_fbck->fback_code;
@@ -924,8 +924,8 @@ static int is_data_consistent ()
static void merge_cache ()
{
int size, i, size_fback, val_err, cache_cnt;
+ struct smc_stats_fback *kern_fbck;
__u64 *kernel, *cache;
- int *kern_fbck;
if (!is_data_consistent()) {
unlink(cache_file_path);
@@ -938,15 +938,16 @@ static void merge_cache ()
for (i = 0; i < size; i++)
*(kernel++) -= *(cache++);
- size_fback = size + 2 * SMC_MAX_FBACK_RSN_CNT;
- kern_fbck = (int *)&smc_rsn;
+ size_fback = 2 * SMC_MAX_FBACK_RSN_CNT;
+ kern_fbck = (struct smc_stats_fback *)&smc_rsn;
for (i = 0; i < size_fback; i++) {
- val_err = *(kern_fbck++);
+ val_err = kern_fbck->fback_code;
if (i < SMC_MAX_FBACK_RSN_CNT)
cache_cnt = get_fback_err_cache_count(smc_rsn_c.srv, val_err);
else
cache_cnt = get_fback_err_cache_count(smc_rsn_c.clnt, val_err);
- *(kern_fbck++) -= cache_cnt;
+ kern_fbck->count -= cache_cnt;
+ kern_fbck++;
}
smc_rsn.srv_fback_cnt -= smc_rsn_c.srv_fback_cnt;
--
2.25.1

View File

@ -1,71 +0,0 @@
From 96b9a33bc16a1d569fe24c3ab1266a7094f41dcb Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 13:47:39 +0200
Subject: [PATCH 2/3] smc-tools: stats: Fix memory and file handle leaks
When exiting the application, make sure that cache
file handle is closed and the memory used for the
cache file path is freed.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 12 +++++++++---
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/README.md b/README.md
index 5047f62..175525d 100644
--- a/README.md
+++ b/README.md
@@ -48,6 +48,7 @@ Release History:
Bug fixes:
- `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
+ - `smcd`/`smcr`: stats: Fix memory and file handle leaks
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index d3a814f..4495434 100644
--- a/stats.c
+++ b/stats.c
@@ -45,7 +45,7 @@ struct smc_stats_rsn smc_rsn;
struct smc_stats_rsn smc_rsn_c;
struct smc_stats_rsn smc_rsn_org;
FILE *cache_fp = NULL;
-char *cache_file_path;
+char *cache_file_path = NULL;
static char* j_output[63] = {"SMC_INT_TX_BUF_8K", "SMC_INT_TX_BUF_16K", "SMC_INT_TX_BUF_32K", "SMC_INT_TX_BUF_64K", "SMC_INT_TX_BUF_128K",
"SMC_INT_TX_BUF_256K", "SMC_INT_TX_BUF_512K", "SMC_INT_TX_BUF_1024K", "SMC_INT_TX_BUF_G_1024K",
@@ -1011,8 +1011,6 @@ static void fill_cache_file()
fprintf(cache_fp, "%16llu\n", smc_rsn.srv_fback_cnt);
fprintf(cache_fp, "%16llu\n", smc_rsn.clnt_fback_cnt);
-
- fclose(cache_fp);
}
int invoke_stats(int argc, char **argv, int option_details)
@@ -1044,10 +1042,18 @@ int invoke_stats(int argc, char **argv, int option_details)
print_as_json();
if (reset_cmd) {
unlink(cache_file_path);
+ if (cache_fp) {
+ fclose(cache_fp);
+ cache_fp = NULL;
+ }
+ free(cache_file_path);
+ cache_file_path = NULL;
open_cache_file();
fill_cache_file();
}
errout:
+ if (cache_fp)
+ fclose(cache_fp);
free(cache_file_path);
return 0;
}
--
2.25.1

View File

@ -1,48 +0,0 @@
From d1a690e104e95ea8f35f82d500abb3aff5c77097 Mon Sep 17 00:00:00 2001
From: Guvenc Gulce <guvenc@linux.ibm.com>
Date: Fri, 16 Jul 2021 14:44:02 +0200
Subject: [PATCH 3/3] smc-tools: stats: Use correct fallback counter values
after reset
Fallback counters are using the merged values for the cache
when reset is called. The cache file needs to be filled with
absolute values as a reference point for the reset as the
successive calls will deduct this reference point from the
new absolute value.
Signed-off-by: Guvenc Gulce <guvenc@linux.ibm.com>
---
README.md | 1 +
stats.c | 4 ++--
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 175525d..aa80dbd 100644
--- a/README.md
+++ b/README.md
@@ -49,6 +49,7 @@ Release History:
Bug fixes:
- `smcd`/`smcr`: stats: Fix memory overread in is_data_consistent()
- `smcd`/`smcr`: stats: Fix memory and file handle leaks
+ - `smcd`/`smcr`: stats: Use correct fallback counter values after reset
- `smc_chk`: Remove 'EXPERIMENTAL' flag
- `smc_chk`: Improve cleanup
- `smc_chk`: Start server with intended port
diff --git a/stats.c b/stats.c
index 4495434..a74c4cf 100644
--- a/stats.c
+++ b/stats.c
@@ -1009,8 +1009,8 @@ static void fill_cache_file()
fprintf(cache_fp, "%-12d%-16d%-16d\n",i , val_err, val_cnt);
}
- fprintf(cache_fp, "%16llu\n", smc_rsn.srv_fback_cnt);
- fprintf(cache_fp, "%16llu\n", smc_rsn.clnt_fback_cnt);
+ fprintf(cache_fp, "%16llu\n", smc_rsn_org.srv_fback_cnt);
+ fprintf(cache_fp, "%16llu\n", smc_rsn_org.clnt_fback_cnt);
}
int invoke_stats(int argc, char **argv, int option_details)
--
2.25.1

View File

@ -1,6 +1,6 @@
%global forgeurl https://github.com/ibm-s390-tools/smc-tools
%global commitdate 20210702
%global commit 393dd23a767ab111608a534b4b0d200e45fe04f0
%global commitdate 20211001
%global commit 720289183736102964c4884bedb84e8d50e84609
%global shortcommit %(c=%{commit}; echo ${c:0:7})
%forgemeta -i
@ -8,8 +8,8 @@
%define debug_package %{nil}
Name: smc-tools
Version: 1.6.0
Release: 3%{?dist}
Version: 1.6.1
Release: 1%{?dist}
Summary: Shared Memory Communication Tools
License: EPL
@ -23,9 +23,6 @@ BuildRequires: bash-completion
Source0: https://github.com/ibm-s390-tools/smc-tools/archive/%{commit}/%{name}-%{shortcommit}.tar.gz
Patch0: smc-tools-1.6.0-smc_chk-py3.patch
Patch1: 0001-smc-tools-stats-Fix-memory-overread-in-is_data_consi.patch
Patch2: 0002-smc-tools-stats-Fix-memory-and-file-handle-leaks.patch
Patch3: 0003-smc-tools-stats-Use-correct-fallback-counter-values-.patch
%description
The Shared Memory Communication Tools (smc-tools) package enables usage of SMC
@ -34,9 +31,6 @@ sockets in Linux.
%prep
%forgesetup
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%build
%make_build CFLAGS="%{build_cflags} -I%{_includedir}/libnl3" LDFLAGS="%{build_ldflags}" V=1
@ -64,6 +58,10 @@ sockets in Linux.
%{_libdir}/libsmc-preload.so*
%changelog
* Mon Oct 18 2021 Čestmír Kalina <ckalina@redhat.com> - 1.6.1-1
- Upgrade smc-tools to latest version
- Resolves: #1984975
* Fri Jul 16 2021 Čestmír Kalina <ckalina@redhat.com> - 1.6.0-3
- Patch stats.c to fix overruns
- Patch stats.c to fix leaks