From 58d23e7c3d848eea2fe7e65bf0a4e2fd830b07bd Mon Sep 17 00:00:00 2001 From: ZhiqiangLiu Date: Mon, 15 Jun 2020 21:33:35 +0800 Subject: [PATCH] open-iscsi: backport two upstream bugfix patches --- 0043-iscsi-Add-break-to-while-loop.patch | 35 ++++++++++++++++++++++++ 0044-iscsi-fix-fd-leak.patch | 33 ++++++++++++++++++++++ open-iscsi.spec | 7 ++++- 3 files changed, 74 insertions(+), 1 deletion(-) create mode 100644 0043-iscsi-Add-break-to-while-loop.patch create mode 100644 0044-iscsi-fix-fd-leak.patch diff --git a/0043-iscsi-Add-break-to-while-loop.patch b/0043-iscsi-Add-break-to-while-loop.patch new file mode 100644 index 0000000..98a48ac --- /dev/null +++ b/0043-iscsi-Add-break-to-while-loop.patch @@ -0,0 +1,35 @@ +From 05766f1e85ea7fbf975559d27814c769328c72dd Mon Sep 17 00:00:00 2001 +From: liubo +Date: Thu, 4 Jun 2020 16:57:07 +0800 +Subject: [PATCH] iscsi: Add break to while loop + +Fix the potential risk of rc value being washed out by jumping out of the loop + +Source Link: https://github.com/open-iscsi/open-iscsi/pull/211 + +Signed-off-by: liubo +Reported-by: Zhiqiang Liu +--- + utils/fwparam_ibft/fwparam_sysfs.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/utils/fwparam_ibft/fwparam_sysfs.c b/utils/fwparam_ibft/fwparam_sysfs.c +index a0cd1c7..87fd6d4 100644 +--- a/utils/fwparam_ibft/fwparam_sysfs.c ++++ b/utils/fwparam_ibft/fwparam_sysfs.c +@@ -115,8 +115,11 @@ static int get_iface_from_device(char *id, struct boot_context *context) + break; + } + +- if (sscanf(dent->d_name, "net:%s", context->iface) != 1) ++ if (sscanf(dent->d_name, "net:%s", context->iface) != 1) { + rc = EINVAL; ++ break; ++ } ++ + rc = 0; + break; + } else { +-- +2.21.1 (Apple Git-122.3) + diff --git a/0044-iscsi-fix-fd-leak.patch b/0044-iscsi-fix-fd-leak.patch new file mode 100644 index 0000000..9befe8b --- /dev/null +++ b/0044-iscsi-fix-fd-leak.patch @@ -0,0 +1,33 @@ +From e5c4073ae836cd049a4bc3d6c1291a25f88ad67d Mon Sep 17 00:00:00 2001 +From: lixiaokeng +Date: Thu, 4 Jun 2020 20:35:18 +0800 +Subject: [PATCH] iscsi: fix fd leak + +iscsi-review/utils/fwparam_ibft/fwparam_ibft.c: line 466 + +Before return -1, the fd was opend and not closed which would lead +to leak fd. Fix that. + +Source Link: https://github.com/open-iscsi/open-iscsi/pull/212 + +Signed-off-by: lixiaokeng +Reported-by: Zhiqiang Liu +--- + utils/fwparam_ibft/fwparam_ibft.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/utils/fwparam_ibft/fwparam_ibft.c b/utils/fwparam_ibft/fwparam_ibft.c +index 52edac1..e68e503 100644 +--- a/utils/fwparam_ibft/fwparam_ibft.c ++++ b/utils/fwparam_ibft/fwparam_ibft.c +@@ -463,6 +463,7 @@ fwparam_ibft(struct boot_context *context, const char *filepath) + if (stat(filename, &buf)!=0) { + fprintf(stderr, "Could not stat file %s: %s (%d)\n", + filename, strerror(errno), errno); ++ close(fd); + return -1; + } + /* And if not zero use that size */ +-- +2.21.1 (Apple Git-122.3) + diff --git a/open-iscsi.spec b/open-iscsi.spec index 33b3e77..dae5d85 100644 --- a/open-iscsi.spec +++ b/open-iscsi.spec @@ -4,7 +4,7 @@ Name: open-iscsi Version: 2.0.876 -Release: 19 +Release: 20 Summary: ISCSI software initiator daemon and utility programs License: GPLv2+ and BSD URL: http://www.open-iscsi.org @@ -54,6 +54,8 @@ Patch0039: 0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch Patch0040: 0040-iscsi-iname-remove-unneeded-temp-buffer.patch Patch0041: 0041-Fix-issue-where-iscsi-iname-p-core-dumps.patch Patch0042: 0042-modify-iSCSI-shared-memory-permissions-for-logs.patch +Patch0043: 0043-iscsi-Add-break-to-while-loop.patch +Patch0044: 0044-iscsi-fix-fd-leak.patch BuildRequires: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config gdb @@ -186,6 +188,9 @@ fi %{_mandir}/man8/* %changelog +* Mon Jun 15 2020 Zhiqiang Liu - 2.0.876-20 +- Backport two upstream bugfix patches + * Tue May 12 2020 Wu Bo - 2.0.876-19 - iscsi-iname verfiy prefix length is at most 210 characters. iscsi-iname remove unneeded temp buffer.