已开启
[sync] PR-54: backport some patches from upstream #58
[sync] PR-54: backport some patches from upstream #58
已开启
AtomGit-Bot创建于 2025年11月7日
共 3 个文件变更+99-1
@@ -0,0 +1,46 @@
1+From fd328ccb3cc0d74d6818817b14d9de25aac85331 Mon Sep 17 00:00:00 2001
2+From: AntonMoryakov <ant.v.moryakov@gmail.com>
3+Date: Sun, 18 May 2025 16:01:11 +0300
4+Subject: json_print: add NULL check before jsonw_string_field() in
5+ print_string()
6+ 
7+Static analyzer (Svace) reported a potential null pointer dereference
8+in print_string(). Specifically, when both 'key' and 'value' are NULL,
9+the function falls through to jsonw_string_field(_jw, key, value),
10+which dereferences both pointers.
11+ 
12+Although comments suggest this case is unlikely, it is safer to
13+explicitly guard against it. This patch adds a check to ensure
14+both key and value are non-NULL before passing to jsonw_string_field().
15+ 
16+This resolves:
17+DEREF_AFTER_NULL: json_print.c:142
18+ 
19+Found by Svace static analysis tool.
20+ 
21+Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
22+---
23+ json_print.c | 5 +++--
24+ 1 file changed, 3 insertions(+), 2 deletions(-)
25+ 
26+diff --git a/json_print.c b/json_print.c
27+index 4f62767..dc52f54 100644
28+--- a/json_print.c
29++++ b/json_print.c
30+@@ -138,10 +138,11 @@ void print_string(enum output_type type,
31+ jsonw_name(_jw, key);
32+ else if (!key && value)
33+ jsonw_string(_jw, value);
34+- else
35++ else if (key && value)
36+ jsonw_string_field(_jw, key, value);
37+ } else if (_IS_FP_CONTEXT(type)) {
38+- fprintf(stdout, fmt, value);
39++ if (value)
40++ fprintf(stdout, fmt, value);
41+ }
42+ }
43+
44+--
45+2.43.0
46+ 
@@ -0,0 +1,43 @@
1+From d12a0a7b343e476c735e6bcde03be0ea20192aff Mon Sep 17 00:00:00 2001
2+From: Anton Moryakov <ant.v.moryakov@gmail.com>
3+Date: Tue, 13 May 2025 23:01:28 +0300
4+Subject: netlink: add NULL check for get_string() in features.c
5+ 
6+Report of the static analyzer:
7+Return value of a function 'get_string' is dereferenced at features.c:279
8+without checking for NULL, but it is usually checked for this function (6/7).
9+ 
10+Correct explained:
11+Added NULL check for get_string() return value before passing to strcmp()
12+to prevent potential NULL pointer dereference. This matches the behavior
13+in other similar code paths where get_string() is used.
14+ 
15+Triggers found by static analyzer Svace.
16+ 
17+Fixes: a7a05af4a1ea ("netlink: add netlink handler for sfeatures (-K)")
18+Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
19+---
20+ netlink/features.c | 6 ++++--
21+ 1 file changed, 4 insertions(+), 2 deletions(-)
22+ 
23+diff --git a/netlink/features.c b/netlink/features.c
24+index 5711ff4..6eb2139 100644
25+--- a/netlink/features.c
26++++ b/netlink/features.c
27+@@ -275,9 +275,11 @@ static int find_feature(const char *name,
28+ const unsigned int count = get_count(feature_names);
29+ unsigned int i;
30+
31+- for (i = 0; i < count; i++)
32+- if (!strcmp(name, get_string(feature_names, i)))
33++ for (i = 0; i < count; i++){
34++ const char *str = get_string(feature_names, i);
35++ if (str && !strcmp(name, str))
36+ return i;
37++ }
38+
39+ return -1;
40+ }
41+--
42+2.43.0
43+ 
@@ -1,7 +1,7 @@
1Name: ethtool1Name: ethtool
2Epoch: 22Epoch: 2
3Version: 6.63Version: 6.6
4-Release: 64+Release: 7
5Summary: Settings tool for Ethernet NICs5Summary: Settings tool for Ethernet NICs
6License: GPL-2.0-only AND GPL-2.0-or-later6License: GPL-2.0-only AND GPL-2.0-or-later
7URL: https://www.kernel.org/pub/software/network/ethtool7URL: https://www.kernel.org/pub/software/network/ethtool
@@ -16,6 +16,8 @@ Patch5: backport-net-ethtool-Add-default-branch-to-sff8636_show_all_i.pa
16Patch6: backport-qsfp-Better-handling-of-Page-03h-netlink-read-failur.patch16Patch6: backport-qsfp-Better-handling-of-Page-03h-netlink-read-failur.patch
17Patch7: backport-module-eeprom-treat-zero-arguments-like-any-other-ar.patch17Patch7: backport-module-eeprom-treat-zero-arguments-like-any-other-ar.patch
18Patch8: backport-qsf-Better-handling-of-Page-A2h-netlink-read-failure.patch18Patch8: backport-qsf-Better-handling-of-Page-A2h-netlink-read-failure.patch
19+Patch9: backport-add-NULL-check-before-jsonw_string_field.patch
20+Patch10: backport-add-NULL-check-for-get_string-in-features.c.patch
19 21 
20BuildRequires: gcc22BuildRequires: gcc
21BuildRequires: libmnl-devel23BuildRequires: libmnl-devel
@@ -63,6 +65,13 @@ make check
63%{_mandir}/man8/%{name}.8*65%{_mandir}/man8/%{name}.8*
64 66 
65%changelog67%changelog
68+* Thu Oct 16 2025 zhangyaqi <zhangyaqi@kylinos.cn> - 2:6.6-7
69+- Type:bugfix
70+- Id:NA
71+- SUG:NA
72+- DESC:add NULL check before jsonw_string_field() in print_string()
73+ netlink: add NULL check for get_string() in features.c
74+ 
66* Wed Jul 30 2025 andy <liuyang01@kylinos.cn> - 2:6.6-675* Wed Jul 30 2025 andy <liuyang01@kylinos.cn> - 2:6.6-6
67- Type:requirement76- Type:requirement
68- Id:NA77- Id:NA