!16 backport bugfix for open-iscsi

Merge pull request !16 from Luis.wu/master
This commit is contained in:
openeuler-ci-bot 2020-05-12 19:34:07 +08:00 committed by Gitee
commit 56048679b5
46 changed files with 254 additions and 131 deletions

View File

@ -0,0 +1,43 @@
From 8576421467835d5c5ff5d48c3ff82ca797274236 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
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 <cleech@redhat.com>
---
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 <prefix>]\n");
--
1.8.3.1

View File

@ -0,0 +1,56 @@
From ed9621a9330c542e73c4290de76644b48e4d5113 Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
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 <cleech@redhat.com>
---
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

View File

@ -0,0 +1,56 @@
From 9cfd62d24ea564c69f09b9f129b39d4460504cec Mon Sep 17 00:00:00 2001
From: Lee Duncan <lduncan@suse.com>
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 <lduncan@suse.com>
---
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 <prefix>]\n");
+ fprintf(stderr, "where <prefix> 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 <prefix>]\n");
+ usage();
exit(0);
}
} else {
--
1.8.3.1

View File

@ -0,0 +1,49 @@
From 3948dec9e2bd50ee3eec9e2288635362eddce171 Mon Sep 17 00:00:00 2001
From: Wu Bo <wubo40@huawei.com>
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 <wubo40@huawei.com>
---
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

View File

@ -1,27 +0,0 @@
From e1d19f028533f5cc20d61121b425891009eddd48 Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
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

View File

@ -1,62 +0,0 @@
From bbcbb04329e75fc91e2d9dc015fbb0efc7dd2ddd Mon Sep 17 00:00:00 2001
From: openEuler Buildteam <buildteam@openeuler.org>
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);

View File

@ -4,54 +4,56 @@
Name: open-iscsi Name: open-iscsi
Version: 2.0.876 Version: 2.0.876
Release: 18 Release: 19
Summary: ISCSI software initiator daemon and utility programs Summary: ISCSI software initiator daemon and utility programs
License: GPLv2+ and BSD License: GPLv2+ and BSD
URL: http://www.open-iscsi.org URL: http://www.open-iscsi.org
Source0: https://github.com/open-iscsi/open-iscsi/archive/f3c8e90fc0894c088950a15ee6618b427f9e2457.tar.gz#/open-iscsi-f3c8e90.tar.gz 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 Patch0000: 0000-Plugging-a-memory-leak-from-discovery.patch
Patch6001: 6001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch Patch0001: 0001-Fix-bug-in-error-message-when-reading-sysfs-numbers.patch
Patch6002: 6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch Patch0002: 0002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch
Patch6003: 6003-Fix-possible-discovery-hang-when-timing-out.patch Patch0003: 0003-Fix-possible-discovery-hang-when-timing-out.patch
Patch6004: 6004-Resource-leak-returning-without-freeing-netdev.patch Patch0004: 0004-Resource-leak-returning-without-freeing-netdev.patch
Patch6005: 6005-Out-of-bounds-write-Overrunning-array-link_target.patch Patch0005: 0005-Out-of-bounds-write-Overrunning-array-link_target.patch
Patch6006: 6006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch Patch0006: 0006-Resource-leak-Variable-rec-going-out-of-scope-leaks.patch
Patch6007: 6007-Out-of-bounds-write-Overrunning-array-link_target.patch Patch0007: 0007-Out-of-bounds-write-Overrunning-array-link_target.patch
Patch6008: 6008-Buffer-not-null-terminated-Calling-strncpy.patch Patch0008: 0008-Buffer-not-null-terminated-Calling-strncpy.patch
Patch6009: 6009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch Patch0009: 0009-Resource-leak-Variable-startup_cmd-going-out-of-scop.patch
Patch6010: 6010-Buffer-not-null-terminated-Calling-strncpy.patch Patch0010: 0010-Buffer-not-null-terminated-Calling-strncpy.patch
Patch6011: 6011-Uninitialized-scalar-variable.patch Patch0011: 0011-Uninitialized-scalar-variable.patch
Patch6012: 6012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch Patch0012: 0012-Resource-leak-Handle-variable-sockfd-going-out-of-scope.patch
Patch6013: 6013-Resource-leak-Variable-chap_info-going-out-of-scope.patch Patch0013: 0013-Resource-leak-Variable-chap_info-going-out-of-scope.patch
Patch6014: 6014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch Patch0014: 0014-Resource-leak-Variable-matched_ses-going-out-of-scope.patch
Patch6015: 6015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch Patch0015: 0015-Resource-leak-Handle-variable-fd-going-out-of-scope.patch
Patch6016: 6016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch Patch0016: 0016-Resource-leak-Handle-variable-fd-going-out-of-scope.patch
Patch6017: 6017-Out-of-bounds-read.patch Patch0017: 0017-Out-of-bounds-read.patch
Patch6018: 6018-fwparam_pcc-mulitple-resource-leaks.patch Patch0018: 0018-fwparam_pcc-mulitple-resource-leaks.patch
Patch6019: 6019-Resource-leak-Handl-variable-fd.patch Patch0019: 0019-Resource-leak-Handl-variable-fd.patch
Patch6020: 6020-Resource-leak-Variable-raw.patch Patch0020: 0020-Resource-leak-Variable-raw.patch
Patch6021: 6021-Allow-reading-sysfs-port-to-fail-gracefully.patch Patch0021: 0021-Allow-reading-sysfs-port-to-fail-gracefully.patch
Patch6022: 6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch Patch0022: 0022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch
Patch6023: 6023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch Patch0023: 0023-Handle-ENOTCONN-error-separately-when-reading-sysfs.patch
Patch6024: 6024-Added-service-file-for-iscsi-logins.patch Patch0024: 0024-Added-service-file-for-iscsi-logins.patch
Patch6025: 6025-Fixed-iscsi.service-considering-every-signal-and-exi.patch Patch0025: 0025-Fixed-iscsi.service-considering-every-signal-and-exi.patch
Patch9000: 9000-change-iscsi-iqn-default-value.patch Patch0026: 0026-change-iscsi-iqn-default-value.patch
Patch9001: 9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch Patch0027: 0027-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch
Patch9002: 9002-add-sleep-for-service.patch Patch0028: 0028-add-sleep-for-service.patch
Patch9003: 9003-not-send-stop-message-if-iscsid-absent.patch Patch0029: 0029-not-send-stop-message-if-iscsid-absent.patch
Patch9004: 9004-iscsid-SIGTERM-syncprocess-hang.patch Patch0030: 0030-iscsid-SIGTERM-syncprocess-hang.patch
Patch9005: 9005-fix-timeout-setting-on-session-commands.patch Patch0031: 0031-fix-timeout-setting-on-session-commands.patch
Patch9006: 9006-restart-log-daemon-when-exited-abnormally.patch Patch0032: 0032-restart-log-daemon-when-exited-abnormally.patch
Patch9007: 9007-check-initiator-name-out-of-range.patch Patch0033: 0033-check-initiator-name-out-of-range.patch
Patch9008: 9008-do-not-sync-session-when-a-session-is-already-created.patch Patch0034: 0034-do-not-sync-session-when-a-session-is-already-created.patch
Patch9009: 9009-fix-default-file-corrupt.patch Patch0035: 0035-fix-default-file-corrupt.patch
Patch9010: 9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch Patch0036: 0036-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch
Patch9011: 9011-fix-iscsiadm-logout-timeout.patch Patch0037: 0037-fix-iscsiadm-logout-timeout.patch
Patch9012: 9012-default-file-zero-after-power-outage.patch Patch0038: 0038-default-file-zero-after-power-outage.patch
Patch9013: 9013-modify-utils-iscsi-iname.patch Patch0039: 0039-iscsi-iname-verify-prefix-length-is-at-most-210.patch
Patch9014: 9014-iscsi-iname-p-name-occur-buffer-overflow.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: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel
BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config gdb BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config gdb
@ -184,6 +186,12 @@ fi
%{_mandir}/man8/* %{_mandir}/man8/*
%changelog %changelog
* Tue May 12 2020 Wu Bo <wubo@huawei.com> - 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 <sunguoshuai@huawei.com> - 2.0.876-18 * Sat Mar 21 2020 sunguoshuai <sunguoshuai@huawei.com> - 2.0.876-18
- Fix upgrade problem and add gdb buildrequire. - Fix upgrade problem and add gdb buildrequire.