From dba849b90ab0e5b019ea43b5d8a22e649cfa74cc Mon Sep 17 00:00:00 2001 From: wubo009 Date: Tue, 12 May 2020 17:27:41 +0800 Subject: [PATCH] backport bugfix for open-iscsi --- ...lugging-a-memory-leak-from-discovery.patch | 0 ...r-message-when-reading-sysfs-numbers.patch | 0 ...multiple-sessions-when-nr_sessions-1.patch | 0 ...sible-discovery-hang-when-timing-out.patch | 0 ...eak-returning-without-freeing-netdev.patch | 0 ...-write-Overrunning-array-link_target.patch | 0 ...ariable-rec-going-out-of-scope-leaks.patch | 0 ...-write-Overrunning-array-link_target.patch | 0 ...-not-null-terminated-Calling-strncpy.patch | 0 ...riable-startup_cmd-going-out-of-scop.patch | 0 ...-not-null-terminated-Calling-strncpy.patch | 0 ...> 0011-Uninitialized-scalar-variable.patch | 0 ...e-variable-sockfd-going-out-of-scope.patch | 0 ...ariable-chap_info-going-out-of-scope.patch | 0 ...iable-matched_ses-going-out-of-scope.patch | 0 ...andle-variable-fd-going-out-of-scope.patch | 0 ...andle-variable-fd-going-out-of-scope.patch | 0 ...ead.patch => 0017-Out-of-bounds-read.patch | 0 ...-fwparam_pcc-mulitple-resource-leaks.patch | 0 ...0019-Resource-leak-Handl-variable-fd.patch | 0 ...h => 0020-Resource-leak-Variable-raw.patch | 0 ...eading-sysfs-port-to-fail-gracefully.patch | 0 ...-sysfs-logic-for-port-and-ip-address.patch | 0 ...-error-separately-when-reading-sysfs.patch | 0 ...-Added-service-file-for-iscsi-logins.patch | 0 ...ice-considering-every-signal-and-exi.patch | 0 ... 0026-change-iscsi-iqn-default-value.patch | 0 ...sessions-when-creating-a-copy-of-exi.patch | 0 ....patch => 0028-add-sleep-for-service.patch | 0 ...t-send-stop-message-if-iscsid-absent.patch | 0 ...0030-iscsid-SIGTERM-syncprocess-hang.patch | 0 ...-timeout-setting-on-session-commands.patch | 0 ...rt-log-daemon-when-exited-abnormally.patch | 0 ...33-check-initiator-name-out-of-range.patch | 0 ...on-when-a-session-is-already-created.patch | 0 ...tch => 0035-fix-default-file-corrupt.patch | 0 ...x-infinite-loop-while-recv-returns-0.patch | 0 ... => 0037-fix-iscsiadm-logout-timeout.patch | 0 ...default-file-zero-after-power-outage.patch | 0 ...-verify-prefix-length-is-at-most-210.patch | 43 +++++++++ ...si-iname-remove-unneeded-temp-buffer.patch | 56 +++++++++++ ...issue-where-iscsi-iname-p-core-dumps.patch | 56 +++++++++++ ...I-shared-memory-permissions-for-logs.patch | 49 ++++++++++ 9013-modify-utils-iscsi-iname.patch | 27 ------ ...i-iname-p-name-occur-buffer-overflow.patch | 62 ------------- open-iscsi.spec | 92 ++++++++++--------- 46 files changed, 254 insertions(+), 131 deletions(-) rename 6000-Plugging-a-memory-leak-from-discovery.patch => 0000-Plugging-a-memory-leak-from-discovery.patch (100%) rename 6001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch => 0001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch (100%) rename 6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch => 0002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch (100%) rename 6003-Fix-possible-discovery-hang-when-timing-out.patch => 0003-Fix-possible-discovery-hang-when-timing-out.patch (100%) rename 6004-Resource-leak-returning-without-freeing-netdev.patch => 0004-Resource-leak-returning-without-freeing-netdev.patch (100%) rename 6005-Out-of-bounds-write-Overrunning-array-link_target.patch => 0005-Out-of-bounds-write-Overrunning-array-link_target.patch (100%) rename 6006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch => 0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch (100%) rename 6007-Out-of-bounds-write-Overrunning-array-link_target.patch => 0007-Out-of-bounds-write-Overrunning-array-link_target.patch (100%) rename 6008-Buffer-not-null-terminated-Calling-strncpy.patch => 0008-Buffer-not-null-terminated-Calling-strncpy.patch (100%) rename 6009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch => 0009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch (100%) rename 6010-Buffer-not-null-terminated-Calling-strncpy.patch => 0010-Buffer-not-null-terminated-Calling-strncpy.patch (100%) rename 6011-Uninitialized-scalar-variable.patch => 0011-Uninitialized-scalar-variable.patch (100%) rename 6012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch => 0012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch (100%) rename 6013-Resource-leak-Variable-chap_info-going-out-of-scope.patch => 0013-Resource-leak-Variable-chap_info-going-out-of-scope.patch (100%) rename 6014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch => 0014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch (100%) rename 6015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch => 0015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch (100%) rename 6016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch => 0016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch (100%) rename 6017-Out-of-bounds-read.patch => 0017-Out-of-bounds-read.patch (100%) rename 6018-fwparam_pcc-mulitple-resource-leaks.patch => 0018-fwparam_pcc-mulitple-resource-leaks.patch (100%) rename 6019-Resource-leak-Handl-variable-fd.patch => 0019-Resource-leak-Handl-variable-fd.patch (100%) rename 6020-Resource-leak-Variable-raw.patch => 0020-Resource-leak-Variable-raw.patch (100%) rename 6021-Allow-reading-sysfs-port-to-fail-gracefully.patch => 0021-Allow-reading-sysfs-port-to-fail-gracefully.patch (100%) rename 6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch => 0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch (100%) rename 6023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch => 0023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch (100%) rename 6024-Added-service-file-for-iscsi-logins.patch => 0024-Added-service-file-for-iscsi-logins.patch (100%) rename 6025-Fixed-iscsi.service-considering-every-signal-and-exi.patch => 0025-Fixed-iscsi.service-considering-every-signal-and-exi.patch (100%) rename 9000-change-iscsi-iqn-default-value.patch => 0026-change-iscsi-iqn-default-value.patch (100%) rename 9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch => 0027-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch (100%) rename 9002-add-sleep-for-service.patch => 0028-add-sleep-for-service.patch (100%) rename 9003-not-send-stop-message-if-iscsid-absent.patch => 0029-not-send-stop-message-if-iscsid-absent.patch (100%) rename 9004-iscsid-SIGTERM-syncprocess-hang.patch => 0030-iscsid-SIGTERM-syncprocess-hang.patch (100%) rename 9005-fix-timeout-setting-on-session-commands.patch => 0031-fix-timeout-setting-on-session-commands.patch (100%) rename 9006-restart-log-daemon-when-exited-abnormally.patch => 0032-restart-log-daemon-when-exited-abnormally.patch (100%) rename 9007-check-initiator-name-out-of-range.patch => 0033-check-initiator-name-out-of-range.patch (100%) rename 9008-do-not-sync-session-when-a-session-is-already-created.patch => 0034-do-not-sync-session-when-a-session-is-already-created.patch (100%) rename 9009-fix-default-file-corrupt.patch => 0035-fix-default-file-corrupt.patch (100%) rename 9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch => 0036-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch (100%) rename 9011-fix-iscsiadm-logout-timeout.patch => 0037-fix-iscsiadm-logout-timeout.patch (100%) rename 9012-default-file-zero-after-power-outage.patch => 0038-default-file-zero-after-power-outage.patch (100%) create mode 100644 0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch create mode 100644 0040-iscsi-iname-remove-unneeded-temp-buffer.patch create mode 100644 0041-Fix-issue-where-iscsi-iname-p-core-dumps.patch create mode 100644 0042-modify-iSCSI-shared-memory-permissions-for-logs.patch delete mode 100644 9013-modify-utils-iscsi-iname.patch delete mode 100644 9014-iscsi-iname-p-name-occur-buffer-overflow.patch diff --git a/6000-Plugging-a-memory-leak-from-discovery.patch b/0000-Plugging-a-memory-leak-from-discovery.patch similarity index 100% rename from 6000-Plugging-a-memory-leak-from-discovery.patch rename to 0000-Plugging-a-memory-leak-from-discovery.patch diff --git a/6001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch b/0001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch similarity index 100% rename from 6001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch rename to 0001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch diff --git a/6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch b/0002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch similarity index 100% rename from 6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch rename to 0002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch diff --git a/6003-Fix-possible-discovery-hang-when-timing-out.patch b/0003-Fix-possible-discovery-hang-when-timing-out.patch similarity index 100% rename from 6003-Fix-possible-discovery-hang-when-timing-out.patch rename to 0003-Fix-possible-discovery-hang-when-timing-out.patch diff --git a/6004-Resource-leak-returning-without-freeing-netdev.patch b/0004-Resource-leak-returning-without-freeing-netdev.patch similarity index 100% rename from 6004-Resource-leak-returning-without-freeing-netdev.patch rename to 0004-Resource-leak-returning-without-freeing-netdev.patch diff --git a/6005-Out-of-bounds-write-Overrunning-array-link_target.patch b/0005-Out-of-bounds-write-Overrunning-array-link_target.patch similarity index 100% rename from 6005-Out-of-bounds-write-Overrunning-array-link_target.patch rename to 0005-Out-of-bounds-write-Overrunning-array-link_target.patch diff --git a/6006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch b/0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch similarity index 100% rename from 6006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch rename to 0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch diff --git a/6007-Out-of-bounds-write-Overrunning-array-link_target.patch b/0007-Out-of-bounds-write-Overrunning-array-link_target.patch similarity index 100% rename from 6007-Out-of-bounds-write-Overrunning-array-link_target.patch rename to 0007-Out-of-bounds-write-Overrunning-array-link_target.patch diff --git a/6008-Buffer-not-null-terminated-Calling-strncpy.patch b/0008-Buffer-not-null-terminated-Calling-strncpy.patch similarity index 100% rename from 6008-Buffer-not-null-terminated-Calling-strncpy.patch rename to 0008-Buffer-not-null-terminated-Calling-strncpy.patch diff --git a/6009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch b/0009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch similarity index 100% rename from 6009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch rename to 0009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch diff --git a/6010-Buffer-not-null-terminated-Calling-strncpy.patch b/0010-Buffer-not-null-terminated-Calling-strncpy.patch similarity index 100% rename from 6010-Buffer-not-null-terminated-Calling-strncpy.patch rename to 0010-Buffer-not-null-terminated-Calling-strncpy.patch diff --git a/6011-Uninitialized-scalar-variable.patch b/0011-Uninitialized-scalar-variable.patch similarity index 100% rename from 6011-Uninitialized-scalar-variable.patch rename to 0011-Uninitialized-scalar-variable.patch diff --git a/6012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch b/0012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch similarity index 100% rename from 6012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch rename to 0012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch diff --git a/6013-Resource-leak-Variable-chap_info-going-out-of-scope.patch b/0013-Resource-leak-Variable-chap_info-going-out-of-scope.patch similarity index 100% rename from 6013-Resource-leak-Variable-chap_info-going-out-of-scope.patch rename to 0013-Resource-leak-Variable-chap_info-going-out-of-scope.patch diff --git a/6014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch b/0014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch similarity index 100% rename from 6014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch rename to 0014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch diff --git a/6015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch b/0015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch similarity index 100% rename from 6015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch rename to 0015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch diff --git a/6016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch b/0016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch similarity index 100% rename from 6016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch rename to 0016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch diff --git a/6017-Out-of-bounds-read.patch b/0017-Out-of-bounds-read.patch similarity index 100% rename from 6017-Out-of-bounds-read.patch rename to 0017-Out-of-bounds-read.patch diff --git a/6018-fwparam_pcc-mulitple-resource-leaks.patch b/0018-fwparam_pcc-mulitple-resource-leaks.patch similarity index 100% rename from 6018-fwparam_pcc-mulitple-resource-leaks.patch rename to 0018-fwparam_pcc-mulitple-resource-leaks.patch diff --git a/6019-Resource-leak-Handl-variable-fd.patch b/0019-Resource-leak-Handl-variable-fd.patch similarity index 100% rename from 6019-Resource-leak-Handl-variable-fd.patch rename to 0019-Resource-leak-Handl-variable-fd.patch diff --git a/6020-Resource-leak-Variable-raw.patch b/0020-Resource-leak-Variable-raw.patch similarity index 100% rename from 6020-Resource-leak-Variable-raw.patch rename to 0020-Resource-leak-Variable-raw.patch diff --git a/6021-Allow-reading-sysfs-port-to-fail-gracefully.patch b/0021-Allow-reading-sysfs-port-to-fail-gracefully.patch similarity index 100% rename from 6021-Allow-reading-sysfs-port-to-fail-gracefully.patch rename to 0021-Allow-reading-sysfs-port-to-fail-gracefully.patch diff --git a/6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch b/0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch similarity index 100% rename from 6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch rename to 0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch diff --git a/6023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch b/0023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch similarity index 100% rename from 6023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch rename to 0023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch diff --git a/6024-Added-service-file-for-iscsi-logins.patch b/0024-Added-service-file-for-iscsi-logins.patch similarity index 100% rename from 6024-Added-service-file-for-iscsi-logins.patch rename to 0024-Added-service-file-for-iscsi-logins.patch diff --git a/6025-Fixed-iscsi.service-considering-every-signal-and-exi.patch b/0025-Fixed-iscsi.service-considering-every-signal-and-exi.patch similarity index 100% rename from 6025-Fixed-iscsi.service-considering-every-signal-and-exi.patch rename to 0025-Fixed-iscsi.service-considering-every-signal-and-exi.patch diff --git a/9000-change-iscsi-iqn-default-value.patch b/0026-change-iscsi-iqn-default-value.patch similarity index 100% rename from 9000-change-iscsi-iqn-default-value.patch rename to 0026-change-iscsi-iqn-default-value.patch diff --git a/9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch b/0027-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch similarity index 100% rename from 9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch rename to 0027-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch diff --git a/9002-add-sleep-for-service.patch b/0028-add-sleep-for-service.patch similarity index 100% rename from 9002-add-sleep-for-service.patch rename to 0028-add-sleep-for-service.patch diff --git a/9003-not-send-stop-message-if-iscsid-absent.patch b/0029-not-send-stop-message-if-iscsid-absent.patch similarity index 100% rename from 9003-not-send-stop-message-if-iscsid-absent.patch rename to 0029-not-send-stop-message-if-iscsid-absent.patch diff --git a/9004-iscsid-SIGTERM-syncprocess-hang.patch b/0030-iscsid-SIGTERM-syncprocess-hang.patch similarity index 100% rename from 9004-iscsid-SIGTERM-syncprocess-hang.patch rename to 0030-iscsid-SIGTERM-syncprocess-hang.patch diff --git a/9005-fix-timeout-setting-on-session-commands.patch b/0031-fix-timeout-setting-on-session-commands.patch similarity index 100% rename from 9005-fix-timeout-setting-on-session-commands.patch rename to 0031-fix-timeout-setting-on-session-commands.patch diff --git a/9006-restart-log-daemon-when-exited-abnormally.patch b/0032-restart-log-daemon-when-exited-abnormally.patch similarity index 100% rename from 9006-restart-log-daemon-when-exited-abnormally.patch rename to 0032-restart-log-daemon-when-exited-abnormally.patch diff --git a/9007-check-initiator-name-out-of-range.patch b/0033-check-initiator-name-out-of-range.patch similarity index 100% rename from 9007-check-initiator-name-out-of-range.patch rename to 0033-check-initiator-name-out-of-range.patch diff --git a/9008-do-not-sync-session-when-a-session-is-already-created.patch b/0034-do-not-sync-session-when-a-session-is-already-created.patch similarity index 100% rename from 9008-do-not-sync-session-when-a-session-is-already-created.patch rename to 0034-do-not-sync-session-when-a-session-is-already-created.patch diff --git a/9009-fix-default-file-corrupt.patch b/0035-fix-default-file-corrupt.patch similarity index 100% rename from 9009-fix-default-file-corrupt.patch rename to 0035-fix-default-file-corrupt.patch diff --git a/9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch b/0036-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch similarity index 100% rename from 9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch rename to 0036-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch diff --git a/9011-fix-iscsiadm-logout-timeout.patch b/0037-fix-iscsiadm-logout-timeout.patch similarity index 100% rename from 9011-fix-iscsiadm-logout-timeout.patch rename to 0037-fix-iscsiadm-logout-timeout.patch diff --git a/9012-default-file-zero-after-power-outage.patch b/0038-default-file-zero-after-power-outage.patch similarity index 100% rename from 9012-default-file-zero-after-power-outage.patch rename to 0038-default-file-zero-after-power-outage.patch diff --git a/0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch b/0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch new file mode 100644 index 0000000..0e6e290 --- /dev/null +++ b/0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch @@ -0,0 +1,43 @@ +From 8576421467835d5c5ff5d48c3ff82ca797274236 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Tue, 12 May 2020 15:43:10 +0800 +Subject: [PATCH] iscsi-iname: verify prefix length is at most 210 + +Don't know who might be trying to make reall long IQNs + +Signed-off-by: Chris Leech +--- + utils/iscsi-iname.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c +index 6273d83..da8e68a 100644 +--- a/utils/iscsi-iname.c ++++ b/utils/iscsi-iname.c +@@ -35,7 +35,11 @@ + #include "md5.h" + + #define RANDOM_NUM_GENERATOR "/dev/urandom" +- ++/* ++ * iSCSI names have a maxinum length of 223 characters, we reserve 13 to append ++ * a seperator and 12 characters (6 random bytes in hex representation) ++ */ ++#define PREFIX_MAX_LEN 210 + int + main(int argc, char *argv[]) + { +@@ -67,6 +71,10 @@ 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) { ++ printf("Error: Prexfix cannot exceed %d " ++ "characters.\n", PREFIX_MAX_LEN); ++ } + } else { + printf("\nUsage: iscsi-iname [-h | --help | " + "-p ]\n"); +-- +1.8.3.1 + diff --git a/0040-iscsi-iname-remove-unneeded-temp-buffer.patch b/0040-iscsi-iname-remove-unneeded-temp-buffer.patch new file mode 100644 index 0000000..4f2a730 --- /dev/null +++ b/0040-iscsi-iname-remove-unneeded-temp-buffer.patch @@ -0,0 +1,56 @@ +From ed9621a9330c542e73c4290de76644b48e4d5113 Mon Sep 17 00:00:00 2001 +From: Chris Leech +Date: Tue, 12 May 2020 15:50:09 +0800 +Subject: [PATCH] iscsi-iname remove unneeded temp buffer + +iscsi-iname remove unneeded temp buffer + +Signed-off-by: Chris Leech +--- + utils/iscsi-iname.c | 8 ++------ + 1 file changed, 2 insertions(+), 6 deletions(-) + +diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c +index da8e68a..086d9bb 100644 +--- a/utils/iscsi-iname.c ++++ b/utils/iscsi-iname.c +@@ -43,7 +43,6 @@ + int + main(int argc, char *argv[]) + { +- char iname[256]; + struct timeval time; + struct utsname system_info; + long hostid; +@@ -56,7 +55,6 @@ main(int argc, char *argv[]) + char *prefix; + + /* initialize */ +- memset(iname, 0, sizeof (iname)); + memset(digest, 0, sizeof (digest)); + memset(&context, 0, sizeof (context)); + MD5Init(&context); +@@ -71,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 (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) { + printf("Error: Prexfix cannot exceed %d " + "characters.\n", PREFIX_MAX_LEN); + } +@@ -140,10 +138,8 @@ main(int argc, char *argv[]) + } + + /* print the prefix followed by 6 bytes of the MD5 hash */ +- sprintf(iname, "%s:%x%x%x%x%x%x", prefix, ++ printf("%s:%x%x%x%x%x%x", prefix, + bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]); + +- iname[sizeof (iname) - 1] = '\0'; +- printf("%s\n", iname); + return 0; + } +-- +1.8.3.1 + diff --git a/0041-Fix-issue-where-iscsi-iname-p-core-dumps.patch b/0041-Fix-issue-where-iscsi-iname-p-core-dumps.patch new file mode 100644 index 0000000..76ffaad --- /dev/null +++ b/0041-Fix-issue-where-iscsi-iname-p-core-dumps.patch @@ -0,0 +1,56 @@ +From 9cfd62d24ea564c69f09b9f129b39d4460504cec Mon Sep 17 00:00:00 2001 +From: Lee Duncan +Date: Tue, 12 May 2020 16:01:50 +0800 +Subject: [PATCH] Fix issue where 'iscsi-iname -p' core dumps + +Fix issue where 'iscsi-iname -p' core dumps + +Signed-off-by: Lee Duncan +--- + utils/iscsi-iname.c | 19 +++++++++++++++---- + 1 file changed, 15 insertions(+), 4 deletions(-) + +diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c +index ad843a0..173e632 100644 +--- a/utils/iscsi-iname.c ++++ b/utils/iscsi-iname.c +@@ -40,6 +40,14 @@ + * a seperator and 12 characters (6 random bytes in hex representation) + */ + #define PREFIX_MAX_LEN 210 ++ ++static void usage(void) ++{ ++ fprintf(stderr, "Usage: iscsi-iname [-h | --help | -p ]\n"); ++ fprintf(stderr, "where has max length of %d\n", ++ PREFIX_MAX_LEN); ++} ++ + int + main(int argc, char *argv[]) + { +@@ -68,14 +76,17 @@ main(int argc, char *argv[]) + "on every invocation.\n"); + exit(0); + } else if ( strcmp(prefix, "-p") == 0 ) { ++ if (argc != 3) { ++ usage(); ++ exit(1); ++ } + prefix = argv[2]; + if (strnlen(prefix, PREFIX_MAX_LEN + 1) > PREFIX_MAX_LEN) { +- printf("Error: Prexfix cannot exceed %d " +- "characters.\n", PREFIX_MAX_LEN); ++ usage(); ++ exit(1); + } + } else { +- printf("\nUsage: iscsi-iname [-h | --help | " +- "-p ]\n"); ++ usage(); + exit(0); + } + } else { +-- +1.8.3.1 + diff --git a/0042-modify-iSCSI-shared-memory-permissions-for-logs.patch b/0042-modify-iSCSI-shared-memory-permissions-for-logs.patch new file mode 100644 index 0000000..4f5967f --- /dev/null +++ b/0042-modify-iSCSI-shared-memory-permissions-for-logs.patch @@ -0,0 +1,49 @@ +From 3948dec9e2bd50ee3eec9e2288635362eddce171 Mon Sep 17 00:00:00 2001 +From: Wu Bo +Date: Tue, 12 May 2020 16:07:43 +0800 +Subject: [PATCH] modify iSCSI shared memory permissions for logs + +iscsid log damon is responsible for reading data from shared memory +and writing syslog. iscsid is the root group. Currently, it is not +seen that non-root users need to read logs. The priciple of minimizing +the use of permisssions, all the permissions are changed from 644 to 600. + +Signed-off-by: Wu Bo +--- + usr/log.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/usr/log.c b/usr/log.c +index b5c1bdd..2f60bf2 100644 +--- a/usr/log.c ++++ b/usr/log.c +@@ -80,7 +80,7 @@ static int logarea_init (int size) + logdbg(stderr,"enter logarea_init\n"); + + if ((shmid = shmget(IPC_PRIVATE, sizeof(struct logarea), +- 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ 0600 | IPC_CREAT | IPC_EXCL)) == -1) { + syslog(LOG_ERR, "shmget logarea failed %d", errno); + return 1; + } +@@ -100,7 +100,7 @@ static int logarea_init (int size) + size = DEFAULT_AREA_SIZE; + + if ((shmid = shmget(IPC_PRIVATE, size, +- 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ 0600 | IPC_CREAT | IPC_EXCL)) == -1) { + syslog(LOG_ERR, "shmget msg failed %d", errno); + free_logarea(); + return 1; +@@ -121,7 +121,7 @@ static int logarea_init (int size) + la->tail = la->start; + + if ((shmid = shmget(IPC_PRIVATE, MAX_MSG_SIZE + sizeof(struct logmsg), +- 0644 | IPC_CREAT | IPC_EXCL)) == -1) { ++ 0600 | IPC_CREAT | IPC_EXCL)) == -1) { + syslog(LOG_ERR, "shmget logmsg failed %d", errno); + free_logarea(); + return 1; +-- +1.8.3.1 + diff --git a/9013-modify-utils-iscsi-iname.patch b/9013-modify-utils-iscsi-iname.patch deleted file mode 100644 index 15baca8..0000000 --- a/9013-modify-utils-iscsi-iname.patch +++ /dev/null @@ -1,27 +0,0 @@ -From e1d19f028533f5cc20d61121b425891009eddd48 Mon Sep 17 00:00:00 2001 -From: openEuler Buildteam -Date: Fri, 23 Aug 2019 19:12:13 +0800 -Subject: [PATCH] modify iscsi initiatorname - ---- - utils/iscsi-iname.c | 4 ++-- - 1 file changed, 2 insertions(+), 2 deletions(-) - -diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c -index 6347edc..ebcf96c 100644 ---- a/utils/iscsi-iname.c -+++ b/utils/iscsi-iname.c -@@ -132,8 +132,8 @@ main(int argc, char *argv[]) - } - - /* print the prefix followed by 6 bytes of the MD5 hash */ -- sprintf(iname, "%s:%x%x%x%x%x%x", prefix, -- bytes[0], bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]); -+ sprintf(iname, "%s:node", prefix); -+ - - iname[sizeof (iname) - 1] = '\0'; - printf("%s\n", iname); --- -1.8.3.1 - diff --git a/9014-iscsi-iname-p-name-occur-buffer-overflow.patch b/9014-iscsi-iname-p-name-occur-buffer-overflow.patch deleted file mode 100644 index cca2608..0000000 --- a/9014-iscsi-iname-p-name-occur-buffer-overflow.patch +++ /dev/null @@ -1,62 +0,0 @@ -From bbcbb04329e75fc91e2d9dc015fbb0efc7dd2ddd Mon Sep 17 00:00:00 2001 -From: openEuler Buildteam -Date: Sat, 9 Nov 2019 02:41:28 -0500 -Subject: [PATCH] iscsi-iname -p xxxx resulting in buffer overflow - -if the name is longer than 256 characters, when exec iscsi-iname -p name. -occur buffer overflow - -such as follow: -iscsi-iname -p aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -*** buffer overflow detected ***: iscsi-iname terminated -Aborted (core dumped) - ---- - utils/iscsi-iname.c | 16 ++++++++++++++-- - 1 file changed, 14 insertions(+), 2 deletions(-) - -diff -Nur a/utils/iscsi-iname.c b/utils/iscsi-iname.c ---- a/utils/iscsi-iname.c 2019-12-23 08:00:50.000000000 +0000 -+++ b/utils/iscsi-iname.c 2019-12-23 08:05:09.000000000 +0000 -@@ -50,6 +50,9 @@ - int e; - int fd; - char *prefix; -+ char *prefix_node = ":node"; -+ char *buffer = NULL; -+ int reserved_len; - - /* initialize */ - memset(iname, 0, sizeof (iname)); -@@ -76,6 +79,13 @@ - prefix = "iqn.2012-01.com.openeuler"; - } - -+ if (strlen(prefix) >= (sizeof(iname) - strlen(prefix_node))) { -+ printf("\nInput a unique iSCSI node name error. " -+ "The maximum length is less than %lu\n", -+ sizeof(iname) - strlen(prefix_node)); -+ exit(0); -+ } -+ - /* try to feed some entropy from the pool to MD5 in order to get - * uniqueness properties - */ -@@ -132,8 +142,10 @@ - } - - /* print the prefix followed by 6 bytes of the MD5 hash */ -- sprintf(iname, "%s:node", prefix); -- -+ buffer = iname; -+ reserved_len = strlen(prefix_node); -+ snprintf(buffer, sizeof(iname) - reserved_len, "%s", prefix); -+ strncat(buffer, prefix_node, reserved_len); - - iname[sizeof (iname) - 1] = '\0'; - printf("%s\n", iname); diff --git a/open-iscsi.spec b/open-iscsi.spec index 20d9bc4..33b3e77 100644 --- a/open-iscsi.spec +++ b/open-iscsi.spec @@ -4,54 +4,56 @@ Name: open-iscsi Version: 2.0.876 -Release: 18 +Release: 19 Summary: ISCSI software initiator daemon and utility programs License: GPLv2+ and BSD URL: http://www.open-iscsi.org Source0: https://github.com/open-iscsi/open-iscsi/archive/f3c8e90fc0894c088950a15ee6618b427f9e2457.tar.gz#/open-iscsi-f3c8e90.tar.gz -Patch6000: 6000-Plugging-a-memory-leak-from-discovery.patch -Patch6001: 6001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch -Patch6002: 6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch -Patch6003: 6003-Fix-possible-discovery-hang-when-timing-out.patch -Patch6004: 6004-Resource-leak-returning-without-freeing-netdev.patch -Patch6005: 6005-Out-of-bounds-write-Overrunning-array-link_target.patch -Patch6006: 6006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch -Patch6007: 6007-Out-of-bounds-write-Overrunning-array-link_target.patch -Patch6008: 6008-Buffer-not-null-terminated-Calling-strncpy.patch -Patch6009: 6009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch -Patch6010: 6010-Buffer-not-null-terminated-Calling-strncpy.patch -Patch6011: 6011-Uninitialized-scalar-variable.patch -Patch6012: 6012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch -Patch6013: 6013-Resource-leak-Variable-chap_info-going-out-of-scope.patch -Patch6014: 6014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch -Patch6015: 6015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch -Patch6016: 6016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch -Patch6017: 6017-Out-of-bounds-read.patch -Patch6018: 6018-fwparam_pcc-mulitple-resource-leaks.patch -Patch6019: 6019-Resource-leak-Handl-variable-fd.patch -Patch6020: 6020-Resource-leak-Variable-raw.patch -Patch6021: 6021-Allow-reading-sysfs-port-to-fail-gracefully.patch -Patch6022: 6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch -Patch6023: 6023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch -Patch6024: 6024-Added-service-file-for-iscsi-logins.patch -Patch6025: 6025-Fixed-iscsi.service-considering-every-signal-and-exi.patch +Patch0000: 0000-Plugging-a-memory-leak-from-discovery.patch +Patch0001: 0001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch +Patch0002: 0002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch +Patch0003: 0003-Fix-possible-discovery-hang-when-timing-out.patch +Patch0004: 0004-Resource-leak-returning-without-freeing-netdev.patch +Patch0005: 0005-Out-of-bounds-write-Overrunning-array-link_target.patch +Patch0006: 0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch +Patch0007: 0007-Out-of-bounds-write-Overrunning-array-link_target.patch +Patch0008: 0008-Buffer-not-null-terminated-Calling-strncpy.patch +Patch0009: 0009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch +Patch0010: 0010-Buffer-not-null-terminated-Calling-strncpy.patch +Patch0011: 0011-Uninitialized-scalar-variable.patch +Patch0012: 0012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch +Patch0013: 0013-Resource-leak-Variable-chap_info-going-out-of-scope.patch +Patch0014: 0014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch +Patch0015: 0015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch +Patch0016: 0016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch +Patch0017: 0017-Out-of-bounds-read.patch +Patch0018: 0018-fwparam_pcc-mulitple-resource-leaks.patch +Patch0019: 0019-Resource-leak-Handl-variable-fd.patch +Patch0020: 0020-Resource-leak-Variable-raw.patch +Patch0021: 0021-Allow-reading-sysfs-port-to-fail-gracefully.patch +Patch0022: 0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch +Patch0023: 0023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch +Patch0024: 0024-Added-service-file-for-iscsi-logins.patch +Patch0025: 0025-Fixed-iscsi.service-considering-every-signal-and-exi.patch -Patch9000: 9000-change-iscsi-iqn-default-value.patch -Patch9001: 9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch -Patch9002: 9002-add-sleep-for-service.patch -Patch9003: 9003-not-send-stop-message-if-iscsid-absent.patch -Patch9004: 9004-iscsid-SIGTERM-syncprocess-hang.patch -Patch9005: 9005-fix-timeout-setting-on-session-commands.patch -Patch9006: 9006-restart-log-daemon-when-exited-abnormally.patch -Patch9007: 9007-check-initiator-name-out-of-range.patch -Patch9008: 9008-do-not-sync-session-when-a-session-is-already-created.patch -Patch9009: 9009-fix-default-file-corrupt.patch -Patch9010: 9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch -Patch9011: 9011-fix-iscsiadm-logout-timeout.patch -Patch9012: 9012-default-file-zero-after-power-outage.patch -Patch9013: 9013-modify-utils-iscsi-iname.patch -Patch9014: 9014-iscsi-iname-p-name-occur-buffer-overflow.patch +Patch0026: 0026-change-iscsi-iqn-default-value.patch +Patch0027: 0027-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch +Patch0028: 0028-add-sleep-for-service.patch +Patch0029: 0029-not-send-stop-message-if-iscsid-absent.patch +Patch0030: 0030-iscsid-SIGTERM-syncprocess-hang.patch +Patch0031: 0031-fix-timeout-setting-on-session-commands.patch +Patch0032: 0032-restart-log-daemon-when-exited-abnormally.patch +Patch0033: 0033-check-initiator-name-out-of-range.patch +Patch0034: 0034-do-not-sync-session-when-a-session-is-already-created.patch +Patch0035: 0035-fix-default-file-corrupt.patch +Patch0036: 0036-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch +Patch0037: 0037-fix-iscsiadm-logout-timeout.patch +Patch0038: 0038-default-file-zero-after-power-outage.patch +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 BuildRequires: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config gdb @@ -184,6 +186,12 @@ fi %{_mandir}/man8/* %changelog +* 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. + Fix issuse where 'iscsi-iname -p' core dumps. + modify iSCSI shared memory permissions for log. + * Sat Mar 21 2020 sunguoshuai - 2.0.876-18 - Fix upgrade problem and add gdb buildrequire.