diff --git a/0019-Fix-iscsi.service-so-it-handles-restarts-better.patch b/0019-Fix-iscsi.service-so-it-handles-restarts-better.patch new file mode 100644 index 0000000000000000000000000000000000000000..62fae4e21bd3f930f46ec8ec5b0c50c965773abb --- /dev/null +++ b/0019-Fix-iscsi.service-so-it-handles-restarts-better.patch @@ -0,0 +1,40 @@ +From 6a9b0728c55b8ad5c6d5dba3f38697eded09538a Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Wed, 4 Mar 2020 12:59:10 -0800 +Subject: [PATCH 151/170] Fix iscsi.service so it handles restarts better + +Requiring iscsid.service means that a restart of iscsi.service +restarted iscsid.service when unneccesary. + +Also, we should treat an exit value of 15 as normal, since +this just means the session is already present. +It should rely on iscsid.socket, no iscsid.service. +--- + etc/systemd/iscsi.service | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service +index e475888..1c286d1 100644 +--- a/etc/systemd/iscsi.service ++++ b/etc/systemd/iscsi.service +@@ -3,7 +3,7 @@ Description=Login and scanning of iSCSI devices + Documentation=man:iscsiadm(8) man:iscsid(8) + Before=remote-fs.target + After=network.target network-online.target iscsid.service +-Requires=iscsid.service ++Requires=iscsid.socket + ConditionPathExists=/etc/iscsi/initiatorname.iscsi + + [Service] +@@ -11,7 +11,7 @@ Type=oneshot + ExecStart=/sbin/iscsiadm -m node --loginall=automatic + ExecStop=/sbin/iscsiadm -m node --logoutall=automatic + ExecStop=/sbin/iscsiadm -m node --logoutall=manual +-SuccessExitStatus=21 ++SuccessExitStatus=21 15 + RemainAfterExit=true + + [Install] +-- +2.21.1 (Apple Git-122.3) + diff --git a/0020-iscsi-iname-fix-iscsi-iname-p-access-NULL-pointer-wi.patch b/0020-iscsi-iname-fix-iscsi-iname-p-access-NULL-pointer-wi.patch new file mode 100644 index 0000000000000000000000000000000000000000..c7f6da2e1d6a2be17aaac9be8468a0ecd1d72aa2 --- /dev/null +++ b/0020-iscsi-iname-fix-iscsi-iname-p-access-NULL-pointer-wi.patch @@ -0,0 +1,26 @@ +From c0d3969b12c97f324c701b773bcabac9ec01d8b1 Mon Sep 17 00:00:00 2001 +From: Wu Bo +Date: Tue, 24 Mar 2020 20:47:50 +0800 +Subject: [PATCH 152/170] iscsi-iname: fix iscsi-iname -p access NULL pointer + without given IQN prefix + +--- + utils/iscsi-iname.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c +index da850dc..7df7bb0 100644 +--- a/utils/iscsi-iname.c ++++ b/utils/iscsi-iname.c +@@ -69,7 +69,7 @@ main(int argc, char *argv[]) + exit(0); + } else if ( strcmp(prefix, "-p") == 0 ) { + prefix = argv[2]; +- if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) { ++ if (prefix && (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN)) { + printf("Error: Prefix cannot exceed %d " + "characters.\n", PREFIX_MAX_LEN); + exit(1); +-- +2.21.1 (Apple Git-122.3) + diff --git a/0021-Fix-type-mismatch-under-musl.patch b/0021-Fix-type-mismatch-under-musl.patch new file mode 100644 index 0000000000000000000000000000000000000000..f27912c9ed9e4da192721d61a69d3a2a6b169aba --- /dev/null +++ b/0021-Fix-type-mismatch-under-musl.patch @@ -0,0 +1,40 @@ +From fbe6c1c766a88edccb0d7f4168d2d87a3cdb4660 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Fri, 27 Mar 2020 17:57:52 -0700 +Subject: [PATCH 156/170] Fix type mismatch under musl. + +It complains about rl.rlim_cur and rl.rlim_max being +long long unsigned, so cast them, since it's debug +messages anyway. +--- + usr/iscsi_util.c | 7 +++++-- + 1 file changed, 5 insertions(+), 2 deletions(-) + +diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c +index fd8fc0c..db1dc37 100644 +--- a/usr/iscsi_util.c ++++ b/usr/iscsi_util.c +@@ -152,7 +152,9 @@ int increase_max_files(void) + log_debug(1, "Could not get file limit (err %d)", errno); + return errno; + } +- log_debug(1, "Max file limits %lu %lu", rl.rlim_cur, rl.rlim_max); ++ log_debug(1, "Max file limits %lu %lu", ++ (long unsigned)rl.rlim_cur, ++ (long unsigned)rl.rlim_max); + + if (rl.rlim_cur < ISCSI_MAX_FILES) + rl.rlim_cur = ISCSI_MAX_FILES; +@@ -162,7 +164,8 @@ int increase_max_files(void) + err = setrlimit(RLIMIT_NOFILE, &rl); + if (err) { + log_debug(1, "Could not set file limit to %lu/%lu (err %d)", +- rl.rlim_cur, rl.rlim_max, errno); ++ (long unsigned)rl.rlim_cur, ++ (long unsigned)rl.rlim_max, errno); + return errno; + } + +-- +2.21.1 (Apple Git-122.3) + diff --git a/0022-Fix-SIGPIPE-loop-in-signal-handler.patch b/0022-Fix-SIGPIPE-loop-in-signal-handler.patch new file mode 100644 index 0000000000000000000000000000000000000000..c16c70f12f1f34be6e71922d67062a5368cafc68 --- /dev/null +++ b/0022-Fix-SIGPIPE-loop-in-signal-handler.patch @@ -0,0 +1,30 @@ +From 71e4ce5e7722dde25751025cac0e8b29d8d540df Mon Sep 17 00:00:00 2001 +From: fredvx <48496214+fredvx@users.noreply.github.com> +Date: Wed, 22 Apr 2020 14:24:50 -0400 +Subject: [PATCH 161/170] Fix SIGPIPE loop in signal handler + +--- + usr/iscsid.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/usr/iscsid.c b/usr/iscsid.c +index 99d27ab..e501498 100644 +--- a/usr/iscsid.c ++++ b/usr/iscsid.c +@@ -310,7 +310,12 @@ static void iscsid_shutdown(void) + + static void catch_signal(int signo) + { +- log_debug(1, "pid %d caught signal %d", getpid(), signo); ++ /* ++ * Do not try to call log_debug() if there is a PIPE error ++ * because we can get caught in a PIPE error loop. ++ */ ++ if (signo != SIGPIPE) ++ log_debug(1, "pid %d caught signal %d", getpid(), signo); + + /* In foreground mode, treat SIGINT like SIGTERM */ + if (!daemonize && signo == SIGINT) +-- +2.21.1 (Apple Git-122.3) + diff --git a/0023-Fix-issue-with-zero-length-arrays-at-end-of-struct.patch b/0023-Fix-issue-with-zero-length-arrays-at-end-of-struct.patch new file mode 100644 index 0000000000000000000000000000000000000000..44bf39c566f8cd2a9cf9ff41ed9e00f1690ca3f7 --- /dev/null +++ b/0023-Fix-issue-with-zero-length-arrays-at-end-of-struct.patch @@ -0,0 +1,66 @@ +From 8d96cc47381a840e5e03384e8077ad238fd1adc4 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Wed, 3 Jun 2020 08:29:39 -0700 +Subject: [PATCH 164/170] Fix issue with zero-length arrays at end of struct +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +A common practice in C coding, over the years, has been to +add a zero-length array at the end of the structure when trying +to represent a possibly-empty array of bytes that may be +appended to the struct. But the gcc-10 compiler does not +like such structures, taking the zero-length literally. + +The following errors are fixed by this commit: + +> iscsiadm.c: In function ‘session_stats’: +> iscsiadm.c:939:56: error: array subscript ‘() + -1’ is outside the bounds of an interior zero-length array ‘struct iscsi_stats_custom[0]’ [-Werror=zero-length-bounds] +> 939 | (unsigned long long)rsp.u.getstats.stats.custom[i].value); +> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ +> In file included from initiator.h:29, +> from iscsiadm.c:36: +> ../include/iscsi_if.h:844:28: note: while referencing ‘custom’ +> 844 | struct iscsi_stats_custom custom[0] +> | ^~~~~~ +> iscsiadm.c:938:56: error: array subscript ‘() + -1’ is outside the bounds of an interior zero-length array ‘struct iscsi_stats_custom[0]’ [-Werror=zero-length-bounds] +> 938 | printf("\t%s: %llu\n", rsp.u.getstats.stats.custom[i].desc, +> | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~ +> In file included from initiator.h:29, +> from iscsiadm.c:36: +> ../include/iscsi_if.h:844:28: note: while referencing ‘custom’ +> 844 | struct iscsi_stats_custom custom[0] +> | ^~~~~~ +> cc1: all warnings being treated as errors + +The work around is to convert the two "custom[0]" structure members to +use "custom[]". +--- + include/iscsi_if.h | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/include/iscsi_if.h b/include/iscsi_if.h +index 2d46214..5a1c614 100644 +--- a/include/iscsi_if.h ++++ b/include/iscsi_if.h +@@ -841,7 +841,7 @@ struct iscsi_stats { + * up to ISCSI_STATS_CUSTOM_MAX + */ + uint32_t custom_length; +- struct iscsi_stats_custom custom[0] ++ struct iscsi_stats_custom custom[] + __attribute__ ((aligned (sizeof(uint64_t)))); + }; + +@@ -972,7 +972,7 @@ struct iscsi_offload_host_stats { + * up to ISCSI_HOST_STATS_CUSTOM_MAX + */ + uint32_t custom_length; +- struct iscsi_host_stats_custom custom[0] ++ struct iscsi_host_stats_custom custom[] + __attribute__ ((aligned (sizeof(uint64_t)))); + }; + +-- +2.21.1 (Apple Git-122.3) + diff --git a/0024-Fix-a-compiler-complaint-about-writing-one-byte.patch b/0024-Fix-a-compiler-complaint-about-writing-one-byte.patch new file mode 100644 index 0000000000000000000000000000000000000000..f4216e078e668a5ad35f991fe58433ad9c3e1aa5 --- /dev/null +++ b/0024-Fix-a-compiler-complaint-about-writing-one-byte.patch @@ -0,0 +1,30 @@ +From 10009f1c5fc01238be976867bc02be046325850b Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Wed, 3 Jun 2020 08:36:45 -0700 +Subject: [PATCH 165/170] Fix a compiler complaint about writing one byte + +When playing with IPv6 IP addresses, which are described +in C using a union, and the gcc-10 compiler didn't like +that we were not specifying which member of the union +we wanted to address of, when in fact all members have +the same address. The fix is to be more explicit. +--- + iscsiuio/src/uip/ipv6.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/iscsiuio/src/uip/ipv6.c b/iscsiuio/src/uip/ipv6.c +index 05efa73..11cb4e9 100644 +--- a/iscsiuio/src/uip/ipv6.c ++++ b/iscsiuio/src/uip/ipv6.c +@@ -519,7 +519,7 @@ static void ipv6_insert_protocol_chksum(struct ipv6_hdr *ipv6) + * SRC IP, DST IP, Protocol Data Length, and Next Header. + */ + sum = 0; +- ptr = (u16_t *)&ipv6->ipv6_src; ++ ptr = (u16_t *)&ipv6->ipv6_src.addr16[0]; + + for (i = 0; i < sizeof(struct ipv6_addr); i++) { + sum += HOST_TO_NET16(*ptr); +-- +2.21.1 (Apple Git-122.3) + diff --git a/0025-Fix-compiler-complaint-about-string-copy-in-iscsiuio.patch b/0025-Fix-compiler-complaint-about-string-copy-in-iscsiuio.patch new file mode 100644 index 0000000000000000000000000000000000000000..4dbe45a6103dbcbee07b7e53cde806d3a03bd9f6 --- /dev/null +++ b/0025-Fix-compiler-complaint-about-string-copy-in-iscsiuio.patch @@ -0,0 +1,57 @@ +From 3f24547f246ee44000d67c7a9b97ff5704327a60 Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Wed, 3 Jun 2020 08:42:17 -0700 +Subject: [PATCH 166/170] Fix compiler complaint about string copy in iscsiuio + +This makes the compiler happy when searching for uio%d sysfs +directories. +--- + iscsiuio/src/unix/nic_utils.c | 20 +++++++++++++++----- + 1 file changed, 15 insertions(+), 5 deletions(-) + +diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c +index ec3b915..ec4535d 100644 +--- a/iscsiuio/src/unix/nic_utils.c ++++ b/iscsiuio/src/unix/nic_utils.c +@@ -603,7 +603,10 @@ static int from_uio_find_associated_host(nic_t *nic, int uio_minor, + search_filters[path_iterator], alphasort); + + switch (count) { +- case 1: ++ case 1: { ++ char *parsed_src; ++ size_t parsed_size; ++ + parsed_name = (*extract_name[path_iterator]) (files); + if (!parsed_name) { + LOG_WARN(PFX "Couldn't find delimiter in: %s", +@@ -612,15 +615,22 @@ static int from_uio_find_associated_host(nic_t *nic, int uio_minor, + break; + } + +- strncpy(name, +- parsed_name + +- extract_name_offset[path_iterator], name_size); ++ parsed_src = parsed_name + extract_name_offset[path_iterator]; ++ parsed_size = strlen(parsed_src); ++ if (parsed_size >= name_size) { ++ LOG_WARN(PFX "uio device name too long: %s (max %d)", ++ parsed_src, (int)name_size - 1); ++ rc = -EINVAL; ++ } else { ++ strncpy(name, parsed_src, name_size); ++ rc = 0; ++ } + + free(files[0]); + free(files); + +- rc = 0; + break; ++ } + + case 0: + rc = -EINVAL; +-- +2.21.1 (Apple Git-122.3) + diff --git a/open-iscsi.spec b/open-iscsi.spec index 42775477513ff2df4cf7311532e1ca1386743ffb..07863901166978fbeced0f6a2f5b618ad3b9576a 100644 --- a/open-iscsi.spec +++ b/open-iscsi.spec @@ -4,7 +4,7 @@ Name: open-iscsi Version: 2.1.1 -Release: 1 +Release: 2 Summary: ISCSI software initiator daemon and utility programs License: GPLv2+ and BSD URL: http://www.open-iscsi.org @@ -27,6 +27,13 @@ Patch15: 0015-iscsi-Add-break-to-while-loop.patch Patch16: 0016-iscsi-fix-fd-leak.patch Patch17: 0017-Fix-devel-without-node-header-files.patch Patch18: 0018-resolve-compilation-errors.patch +Patch19: 0019-Fix-iscsi.service-so-it-handles-restarts-better.patch +Patch20: 0020-iscsi-iname-fix-iscsi-iname-p-access-NULL-pointer-wi.patch +Patch21: 0021-Fix-type-mismatch-under-musl.patch +Patch22: 0022-Fix-SIGPIPE-loop-in-signal-handler.patch +Patch23: 0023-Fix-issue-with-zero-length-arrays-at-end-of-struct.patch +Patch24: 0024-Fix-a-compiler-complaint-about-writing-one-byte.patch +Patch25: 0025-Fix-compiler-complaint-about-string-copy-in-iscsiuio.patch BuildRequires: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel systemd-devel @@ -160,6 +167,9 @@ fi %{_mandir}/man8/* %changelog +* Wed Jul 29 2020 Wangjun - 2.1.1-2 +- patches for bugfix + * Thu Jul 9 2020 wuguanghao - 2.1.1-1 - update open-iscsi version to 2.1.1-1