init package
This commit is contained in:
parent
8370651e8f
commit
08550c303d
32
6000-Plugging-a-memory-leak-from-discovery.patch
Normal file
32
6000-Plugging-a-memory-leak-from-discovery.patch
Normal file
@ -0,0 +1,32 @@
|
||||
From c388d9adae20b835731ac98776082c884617467d Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Thu, 30 Aug 2018 15:58:10 -0700
|
||||
Subject: [PATCH 45/91] Plugging a memory leak from discovery.
|
||||
|
||||
During discovery the function get_op_params_text_keys()
|
||||
can allocate a target_alias, but this is never freed.
|
||||
|
||||
Discovered-by: zhangzujian.7@gmail.com
|
||||
---
|
||||
usr/discovery.c | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/usr/discovery.c b/usr/discovery.c
|
||||
index 8001af6..2147deb 100644
|
||||
--- a/usr/discovery.c
|
||||
+++ b/usr/discovery.c
|
||||
@@ -1055,6 +1055,11 @@ static void iscsi_destroy_session(struct iscsi_session *session)
|
||||
log_error("Could not safely destroy session %d (err %d)",
|
||||
session->id, rc);
|
||||
done:
|
||||
+ if (session->target_alias) {
|
||||
+ free(session->target_alias);
|
||||
+ session->target_alias = NULL;
|
||||
+ }
|
||||
+
|
||||
if (conn->socket_fd >= 0) {
|
||||
ipc->ctldev_close();
|
||||
conn->socket_fd = -1;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,28 @@
|
||||
From 8bf04a094e572c56d4f8bd30ff064c84c75a0247 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Tue, 25 Sep 2018 09:53:55 -0700
|
||||
Subject: [PATCH 54/91] Fix bug in error message when reading sysfs numbers.
|
||||
|
||||
The message printed when ENOENT was returned for
|
||||
a number-type sysfs value was missing the attribute
|
||||
name parameter.
|
||||
---
|
||||
libopeniscsiusr/sysfs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/libopeniscsiusr/sysfs.c b/libopeniscsiusr/sysfs.c
|
||||
index c4f89a3..5e6532e 100644
|
||||
--- a/libopeniscsiusr/sysfs.c
|
||||
+++ b/libopeniscsiusr/sysfs.c
|
||||
@@ -237,7 +237,7 @@ static int iscsi_sysfs_prop_get_ll(struct iscsi_context *ctx,
|
||||
"Failed to read '%s': "
|
||||
"File '%s' does not exists, using ",
|
||||
"default value %lld",
|
||||
- file_path, default_value);
|
||||
+ prop_name, file_path, default_value);
|
||||
*val = default_value;
|
||||
goto out;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
37
6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch
Normal file
37
6002-Do-not-allow-multiple-sessions-when-nr_sessions-1.patch
Normal file
@ -0,0 +1,37 @@
|
||||
From a37c4295a2e3f8712921a52db0d35d3506efb19b Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Thu, 4 Oct 2018 16:26:26 -0700
|
||||
Subject: [PATCH 60/91] Do not allow multiple sessions when nr_sessions=1
|
||||
|
||||
If a request is made to login to a target, creating
|
||||
a session, then another request is submitted so quickly
|
||||
that the first one has not completed, both requests
|
||||
can succeed, despite having nr_sessions=1 configured.
|
||||
|
||||
Only allow multiple login requests if nr_sessions is
|
||||
greater than 1.
|
||||
---
|
||||
usr/session_mgmt.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/usr/session_mgmt.c b/usr/session_mgmt.c
|
||||
index 596085b..0500f15 100644
|
||||
--- a/usr/session_mgmt.c
|
||||
+++ b/usr/session_mgmt.c
|
||||
@@ -189,9 +189,11 @@ int iscsi_login_portal(void *data, struct list_head *list, struct node_rec *rec)
|
||||
|
||||
/*
|
||||
* Ensure the record's 'multiple' flag is set so __iscsi_login_portal
|
||||
- * will allow multiple logins.
|
||||
+ * will allow multiple logins, but only if configured for more
|
||||
+ * than one
|
||||
*/
|
||||
- rec->session.multiple = 1;
|
||||
+ if (rec->session.nr_sessions > 1)
|
||||
+ rec->session.multiple = 1;
|
||||
for (i = session_count; i < rec->session.nr_sessions; ++i) {
|
||||
log_debug(1, "%s: Creating session %d/%d", rec->iface.name,
|
||||
i + 1, rec->session.nr_sessions);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
28
6003-Fix-possible-discovery-hang-when-timing-out.patch
Normal file
28
6003-Fix-possible-discovery-hang-when-timing-out.patch
Normal file
@ -0,0 +1,28 @@
|
||||
From 4ee991b81194a7e3ebd7ff6ec4efc5509932389d Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Tue, 14 May 2019 14:12:25 -0700
|
||||
Subject: [PATCH 91/91] Fix possible discovery hang when timing out
|
||||
|
||||
If session reopening failed during discovery, the CPU
|
||||
could peg at 100% because the code that gives up when
|
||||
tretires are exhausted was not setting an error
|
||||
return value.
|
||||
---
|
||||
usr/discovery.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/usr/discovery.c b/usr/discovery.c
|
||||
index 2147deb..199c160 100644
|
||||
--- a/usr/discovery.c
|
||||
+++ b/usr/discovery.c
|
||||
@@ -1355,6 +1355,7 @@ reconnect:
|
||||
if (--session->reopen_cnt < 0) {
|
||||
log_error("connection login retries (reopen_max) %d exceeded",
|
||||
config->reopen_max);
|
||||
+ rc = ISCSI_ERR_PDU_TIMEOUT;
|
||||
goto login_failed;
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
35
6004-Resource-leak-returning-without-freeing-netdev.patch
Normal file
35
6004-Resource-leak-returning-without-freeing-netdev.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From e13d2fe2b39d6a69b7a7c82cdc3185996bceaca2 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 11:06:07 -0700
|
||||
Subject: [PATCH 18/43] Resource leak: returning without freeing netdev
|
||||
|
||||
---
|
||||
usr/iscsi_net_util.c | 6 ++++--
|
||||
1 file changed, 4 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c
|
||||
index 6339082..a32b49c 100644
|
||||
--- a/usr/iscsi_net_util.c
|
||||
+++ b/usr/iscsi_net_util.c
|
||||
@@ -271,7 +271,8 @@ int net_setup_netdev(char *netdev, char *local_ip, char *mask, char *gateway,
|
||||
if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) == -1) {
|
||||
log_error("Could not open socket to manage network "
|
||||
"(err %d - %s)", errno, strerror(errno));
|
||||
- return errno;
|
||||
+ ret = errno;
|
||||
+ goto done;
|
||||
}
|
||||
|
||||
/* Bring up NIC with correct address - unless it
|
||||
@@ -389,7 +390,8 @@ int net_setup_netdev(char *netdev, char *local_ip, char *mask, char *gateway,
|
||||
ret = 0;
|
||||
|
||||
done:
|
||||
- close(sock);
|
||||
+ if (sock >= 0)
|
||||
+ close(sock);
|
||||
if (vlan_id)
|
||||
free(netdev);
|
||||
return ret;
|
||||
--
|
||||
2.21.0
|
||||
25
6005-Out-of-bounds-write-Overrunning-array-link_target.patch
Normal file
25
6005-Out-of-bounds-write-Overrunning-array-link_target.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 007d7832c631409e41bf5c473ca5dc7d114a67cb Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 11:13:44 -0700
|
||||
Subject: [PATCH 19/43] Out-of-bounds-write: Overrunning array link_target
|
||||
|
||||
---
|
||||
usr/sysfs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/sysfs.c b/usr/sysfs.c
|
||||
index 48f3825..b3102f0 100644
|
||||
--- a/usr/sysfs.c
|
||||
+++ b/usr/sysfs.c
|
||||
@@ -134,7 +134,7 @@ int sysfs_resolve_link(char *devpath, size_t size)
|
||||
|
||||
strlcpy(link_path, sysfs_path, sizeof(link_path));
|
||||
strlcat(link_path, devpath, sizeof(link_path));
|
||||
- len = readlink(link_path, link_target, sizeof(link_target));
|
||||
+ len = readlink(link_path, link_target, sizeof(link_target) - 1);
|
||||
if (len <= 0)
|
||||
return -1;
|
||||
link_target[len] = '\0';
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
From 0db12353efea69309a6a92f30f4e063b142359c4 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 11:27:07 -0700
|
||||
Subject: [PATCH 20/43] Resource leak: Variable rec going out of scope leaks
|
||||
the storage it points to
|
||||
|
||||
---
|
||||
usr/iscsiadm.c | 3 ++-
|
||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
||||
index 8de7a41..2ce6ae7 100644
|
||||
--- a/usr/iscsiadm.c
|
||||
+++ b/usr/iscsiadm.c
|
||||
@@ -1044,7 +1044,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
|
||||
if (rc) {
|
||||
log_error("Could not read iface %s. Error %d",
|
||||
iface->name, rc);
|
||||
- return rc;
|
||||
+ goto free_drec;
|
||||
}
|
||||
|
||||
iface_copy(&rec->iface, iface);
|
||||
@@ -1057,6 +1057,7 @@ static int add_static_rec(int *found, char *targetname, int tpgt,
|
||||
rec->iface.transport_name, iface_str(&rec->iface),
|
||||
ip, port, tpgt, targetname);
|
||||
}
|
||||
+free_drec:
|
||||
free(drec);
|
||||
free_rec:
|
||||
free(rec);
|
||||
--
|
||||
2.19.1
|
||||
|
||||
43
6007-Out-of-bounds-write-Overrunning-array-link_target.patch
Normal file
43
6007-Out-of-bounds-write-Overrunning-array-link_target.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From c03fbc1a112d3f808512351a62f4c5f593694003 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 11:29:56 -0700
|
||||
Subject: [PATCH 21/43] Out-of-bounds write: Overrunning array link_target
|
||||
|
||||
---
|
||||
usr/sysfs.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/usr/sysfs.c b/usr/sysfs.c
|
||||
index b3102f0..2488160 100644
|
||||
--- a/usr/sysfs.c
|
||||
+++ b/usr/sysfs.c
|
||||
@@ -225,7 +225,7 @@ struct sysfs_device *sysfs_device_get(const char *devpath)
|
||||
strlcpy(link_path, sysfs_path, sizeof(link_path));
|
||||
strlcat(link_path, dev->devpath, sizeof(link_path));
|
||||
strlcat(link_path, "/subsystem", sizeof(link_path));
|
||||
- len = readlink(link_path, link_target, sizeof(link_target));
|
||||
+ len = readlink(link_path, link_target, sizeof(link_target) - 1);
|
||||
if (len > 0) {
|
||||
/* get subsystem from "subsystem" link */
|
||||
link_target[len] = '\0';
|
||||
@@ -255,7 +255,7 @@ struct sysfs_device *sysfs_device_get(const char *devpath)
|
||||
strlcpy(link_path, sysfs_path, sizeof(link_path));
|
||||
strlcat(link_path, dev->devpath, sizeof(link_path));
|
||||
strlcat(link_path, "/driver", sizeof(link_path));
|
||||
- len = readlink(link_path, link_target, sizeof(link_target));
|
||||
+ len = readlink(link_path, link_target, sizeof(link_target) - 1);
|
||||
if (len > 0) {
|
||||
link_target[len] = '\0';
|
||||
dbg("driver link '%s' points to '%s'", link_path, link_target);
|
||||
@@ -363,7 +363,7 @@ char *sysfs_attr_get_value(const char *devpath, const char *attr_name)
|
||||
int len;
|
||||
const char *pos;
|
||||
|
||||
- len = readlink(path_full, link_target, sizeof(link_target));
|
||||
+ len = readlink(path_full, link_target, sizeof(link_target) - 1);
|
||||
if (len > 0) {
|
||||
link_target[len] = '\0';
|
||||
pos = strrchr(link_target, '/');
|
||||
--
|
||||
2.19.1
|
||||
|
||||
27
6008-Buffer-not-null-terminated-Calling-strncpy.patch
Normal file
27
6008-Buffer-not-null-terminated-Calling-strncpy.patch
Normal file
@ -0,0 +1,27 @@
|
||||
From 26bfa31349c410cacd22f9e8ea2ef4a82b221f13 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 11:44:18 -0700
|
||||
Subject: [PATCH 22/43] Buffer not null terminated: Calling strncpy with a
|
||||
maximum size argument on destination array might leave the destination string
|
||||
unterminated
|
||||
|
||||
---
|
||||
usr/iscsi_sysfs.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/iscsi_sysfs.c b/usr/iscsi_sysfs.c
|
||||
index f79a1af..418f51b 100644
|
||||
--- a/usr/iscsi_sysfs.c
|
||||
+++ b/usr/iscsi_sysfs.c
|
||||
@@ -464,7 +464,7 @@ int iscsi_sysfs_get_flashnode_info(struct flashnode_rec *fnode,
|
||||
log_debug(7, "could not get transport name for host%d",
|
||||
host_no);
|
||||
else
|
||||
- strncpy(fnode->transport_name, t->name,
|
||||
+ strlcpy(fnode->transport_name, t->name,
|
||||
ISCSI_TRANSPORT_NAME_MAXLEN);
|
||||
|
||||
snprintf(sess_id, sizeof(sess_id), ISCSI_FLASHNODE_SESS, host_no,
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From 5799a5a711a0347e353cfb61b8ea33eb9d38541e Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 12:03:59 -0700
|
||||
Subject: [PATCH 24/43] Resource leak: Variable startup_cmd going out of scope
|
||||
leaks the storage it point to.
|
||||
|
||||
---
|
||||
usr/iscsid_req.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
|
||||
index b6940db..427e894 100644
|
||||
--- a/usr/iscsid_req.c
|
||||
+++ b/usr/iscsid_req.c
|
||||
@@ -55,6 +55,8 @@ static void iscsid_startup(void)
|
||||
if (system(startup_cmd) < 0)
|
||||
log_error("Could not execute '%s' (err %d)",
|
||||
startup_cmd, errno);
|
||||
+
|
||||
+ free(startup_cmd);
|
||||
}
|
||||
|
||||
#define MAXSLEEP 128
|
||||
--
|
||||
2.21.0
|
||||
|
||||
43
6010-Buffer-not-null-terminated-Calling-strncpy.patch
Normal file
43
6010-Buffer-not-null-terminated-Calling-strncpy.patch
Normal file
@ -0,0 +1,43 @@
|
||||
From aa0e934c3513ca8fac9de463e328b5a150d057f5 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 12:10:27 -0700
|
||||
Subject: [PATCH 25/43] Buffer not null terminated: Calling strncpy with a
|
||||
maximum size argument on destination array
|
||||
|
||||
---
|
||||
usr/iscsi_net_util.c | 6 +++---
|
||||
1 file changed, 3 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c
|
||||
index a32b49c..56d2f69 100644
|
||||
--- a/usr/iscsi_net_util.c
|
||||
+++ b/usr/iscsi_net_util.c
|
||||
@@ -193,7 +193,7 @@ static char *find_vlan_dev(char *netdev, int vlan_id) {
|
||||
|
||||
sockfd = socket(AF_INET, SOCK_DGRAM, 0);
|
||||
|
||||
- strncpy(if_hwaddr.ifr_name, netdev, IFNAMSIZ);
|
||||
+ strlcpy(if_hwaddr.ifr_name, netdev, IFNAMSIZ);
|
||||
ioctl(sockfd, SIOCGIFHWADDR, &if_hwaddr);
|
||||
|
||||
if (if_hwaddr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
|
||||
@@ -201,14 +201,14 @@ static char *find_vlan_dev(char *netdev, int vlan_id) {
|
||||
|
||||
ifni = if_nameindex();
|
||||
for (i = 0; ifni[i].if_index && ifni[i].if_name; i++) {
|
||||
- strncpy(vlan_hwaddr.ifr_name, ifni[i].if_name, IFNAMSIZ);
|
||||
+ strlcpy(vlan_hwaddr.ifr_name, ifni[i].if_name, IFNAMSIZ);
|
||||
ioctl(sockfd, SIOCGIFHWADDR, &vlan_hwaddr);
|
||||
|
||||
if (vlan_hwaddr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
|
||||
continue;
|
||||
|
||||
if (!memcmp(if_hwaddr.ifr_hwaddr.sa_data, vlan_hwaddr.ifr_hwaddr.sa_data, ETH_ALEN)) {
|
||||
- strncpy(vlanrq.device1, ifni[i].if_name, IFNAMSIZ);
|
||||
+ strlcpy(vlanrq.device1, ifni[i].if_name, IFNAMSIZ);
|
||||
rc = ioctl(sockfd, SIOCGIFVLAN, &vlanrq);
|
||||
if ((rc == 0) && (vlanrq.u.VID == vlan_id)) {
|
||||
vlan = strdup(vlanrq.device1);
|
||||
--
|
||||
2.21.0
|
||||
|
||||
25
6011-Uninitialized-scalar-variable.patch
Normal file
25
6011-Uninitialized-scalar-variable.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 65c06d977a012541fd6144d4452f5191081fdd44 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 12:11:42 -0700
|
||||
Subject: [PATCH 26/43] Uninitialized scalar variable
|
||||
|
||||
---
|
||||
usr/host.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/host.c b/usr/host.c
|
||||
index 62bf111..356650c 100644
|
||||
--- a/usr/host.c
|
||||
+++ b/usr/host.c
|
||||
@@ -217,7 +217,7 @@ static int print_host_iface(void *data, struct iface_rec *iface)
|
||||
|
||||
static void print_host_ifaces(struct host_info *hinfo, char *prefix)
|
||||
{
|
||||
- int nr_found;
|
||||
+ int nr_found = 0;
|
||||
|
||||
iscsi_sysfs_for_each_iface_on_host(prefix, hinfo->host_no, &nr_found,
|
||||
print_host_iface);
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From 98738bc389c62cef05bff9e03d5172253ebc82af Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 13:46:37 -0700
|
||||
Subject: [PATCH 29/43] Resource leak: Handle variable sockfd going out of
|
||||
scope leaks the handle.
|
||||
|
||||
---
|
||||
usr/iscsi_net_util.c | 4 +++-
|
||||
1 file changed, 3 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/iscsi_net_util.c b/usr/iscsi_net_util.c
|
||||
index 56d2f69..b5a910f 100644
|
||||
--- a/usr/iscsi_net_util.c
|
||||
+++ b/usr/iscsi_net_util.c
|
||||
@@ -196,8 +196,10 @@ static char *find_vlan_dev(char *netdev, int vlan_id) {
|
||||
strlcpy(if_hwaddr.ifr_name, netdev, IFNAMSIZ);
|
||||
ioctl(sockfd, SIOCGIFHWADDR, &if_hwaddr);
|
||||
|
||||
- if (if_hwaddr.ifr_hwaddr.sa_family != ARPHRD_ETHER)
|
||||
+ if (if_hwaddr.ifr_hwaddr.sa_family != ARPHRD_ETHER) {
|
||||
+ close(sockfd);
|
||||
return NULL;
|
||||
+ }
|
||||
|
||||
ifni = if_nameindex();
|
||||
for (i = 0; ifni[i].if_index && ifni[i].if_name; i++) {
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,26 @@
|
||||
From 020d46c3cb95d627bd1246e6212981cf22adf651 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 13:50:22 -0700
|
||||
Subject: [PATCH 30/43] Resource leak: Variable chap_info going out of scope
|
||||
leaks the storage it points to.
|
||||
|
||||
---
|
||||
usr/iscsiadm.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
||||
index 2ce6ae7..efc9f43 100644
|
||||
--- a/usr/iscsiadm.c
|
||||
+++ b/usr/iscsiadm.c
|
||||
@@ -1734,7 +1734,7 @@ static int set_host_chap_info(uint32_t host_no, uint64_t chap_index,
|
||||
rc = ISCSI_ERR;
|
||||
}
|
||||
|
||||
- goto exit_set_chap;
|
||||
+ goto free_iovec;
|
||||
}
|
||||
|
||||
ipc->ctldev_close();
|
||||
--
|
||||
2.19.1
|
||||
|
||||
@ -0,0 +1,34 @@
|
||||
From 096fc3ca10492c0810f1aaf76266006a2a803109 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 13:54:27 -0700
|
||||
Subject: [PATCH 31/43] Resource leak: Variable matched_ses going out of scope
|
||||
leaks the storage it points to.
|
||||
|
||||
---
|
||||
usr/host.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/usr/host.c b/usr/host.c
|
||||
index 356650c..c94b6d1 100644
|
||||
--- a/usr/host.c
|
||||
+++ b/usr/host.c
|
||||
@@ -262,14 +262,14 @@ static int host_info_print_tree(void *data, struct host_info *hinfo)
|
||||
matched_ses[matched_se_count++] = ses[i];
|
||||
|
||||
if (!matched_se_count)
|
||||
- return 0;
|
||||
+ goto out;
|
||||
|
||||
printf("\t*********\n");
|
||||
printf("\tSessions:\n");
|
||||
printf("\t*********\n");
|
||||
session_info_print_tree(matched_ses, matched_se_count, "\t",
|
||||
session_info_flags, 0/* don't show password */);
|
||||
-
|
||||
+out:
|
||||
free(matched_ses);
|
||||
return 0;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,29 @@
|
||||
From ca6eb221321c0e24b94f667ecc75a5fc17aa2018 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 13:59:31 -0700
|
||||
Subject: [PATCH 32/43] Resource leak: Handle variable fd going out of scope
|
||||
leaks the handle.
|
||||
|
||||
This is comming up in places where the error handling assumes that on a
|
||||
failure there is no file descriptor to worry about. I don't think we
|
||||
need to keep fd around when indicating a connection error.
|
||||
---
|
||||
usr/iscsid_req.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
|
||||
index 427e894..d872eb7 100644
|
||||
--- a/usr/iscsid_req.c
|
||||
+++ b/usr/iscsid_req.c
|
||||
@@ -97,6 +97,8 @@ static int ipc_connect(int *fd, char *unix_sock_name, int start_iscsid)
|
||||
if (nsec <= MAXSLEEP/2)
|
||||
sleep(nsec);
|
||||
}
|
||||
+ close(*fd);
|
||||
+ *fd = -1;
|
||||
log_error("can not connect to iSCSI daemon (%d)!", errno);
|
||||
return ISCSI_ERR_ISCSID_NOTCONN;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
||||
@ -0,0 +1,25 @@
|
||||
From 1a17ffcc07ff7021d66940f58f42bfaa78e763bf Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 14:08:57 -0700
|
||||
Subject: [PATCH 33/43] Resource leak: Handle variable fd going out of scope
|
||||
leaks the handle.
|
||||
|
||||
---
|
||||
usr/iscsi_util.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/usr/iscsi_util.c b/usr/iscsi_util.c
|
||||
index 0570dd5..fd8fc0c 100644
|
||||
--- a/usr/iscsi_util.c
|
||||
+++ b/usr/iscsi_util.c
|
||||
@@ -62,6 +62,7 @@ void daemon_init(void)
|
||||
setsid();
|
||||
if (chdir("/") < 0)
|
||||
log_debug(1, "Could not chdir to /: %s", strerror(errno));
|
||||
+ close(fd);
|
||||
}
|
||||
|
||||
#define ISCSI_OOM_PATH_LEN 48
|
||||
--
|
||||
2.21.0
|
||||
|
||||
35
6017-Out-of-bounds-read.patch
Normal file
35
6017-Out-of-bounds-read.patch
Normal file
@ -0,0 +1,35 @@
|
||||
From de0680b4f46f767c34a4a503dadcb24135c21cb6 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Wed, 30 Oct 2019 14:12:16 -0700
|
||||
Subject: [PATCH 34/43] Out-of-bounds read: Overrunning array of 4 bytes at
|
||||
byte offset 7 by dereferencing pointer
|
||||
|
||||
---
|
||||
iscsiuio/src/unix/libs/qedi.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/iscsiuio/src/unix/libs/qedi.c b/iscsiuio/src/unix/libs/qedi.c
|
||||
index b7595d5..3414cb5 100644
|
||||
--- a/iscsiuio/src/unix/libs/qedi.c
|
||||
+++ b/iscsiuio/src/unix/libs/qedi.c
|
||||
@@ -442,7 +442,7 @@ static int qedi_open(nic_t *nic)
|
||||
qedi_t *bp = NULL;
|
||||
struct stat uio_stat;
|
||||
int i, rc;
|
||||
- int count;
|
||||
+ size_t count;
|
||||
uint32_t bus;
|
||||
uint32_t slot;
|
||||
uint32_t func;
|
||||
@@ -666,7 +666,7 @@ static int qedi_open(nic_t *nic)
|
||||
nic->mac_addr[0], nic->mac_addr[1], nic->mac_addr[2],
|
||||
nic->mac_addr[3], nic->mac_addr[4], nic->mac_addr[5]);
|
||||
|
||||
- qedi_get_library_name(&nic->library_name, (size_t *)&count);
|
||||
+ qedi_get_library_name(&nic->library_name, &count);
|
||||
LOG_INFO("%s: qedi initialized", nic->log_name);
|
||||
|
||||
bp->flags |= QEDI_OPENED;
|
||||
--
|
||||
2.21.0
|
||||
|
||||
39
6018-fwparam_pcc-mulitple-resource-leaks.patch
Normal file
39
6018-fwparam_pcc-mulitple-resource-leaks.patch
Normal file
@ -0,0 +1,39 @@
|
||||
From f7d92a5f0a788179bf804dd898d2b5238da5d2d1 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Thu, 31 Oct 2019 14:24:53 -0700
|
||||
Subject: [PATCH 39/43] fwparam_pcc mulitple resource leaks
|
||||
|
||||
Resource Leak: Variable mac_file going out of scope leaks the storage it points to.
|
||||
Resource Leak: Handle variable mac_fd going out of scope leaks the storage it points to.
|
||||
---
|
||||
utils/fwparam_ibft/fwparam_ppc.c | 3 +--
|
||||
1 file changed, 1 insertion(+), 2 deletions(-)
|
||||
|
||||
diff --git a/utils/fwparam_ibft/fwparam_ppc.c b/utils/fwparam_ibft/fwparam_ppc.c
|
||||
index 52a5c50..429d45c 100644
|
||||
--- a/utils/fwparam_ibft/fwparam_ppc.c
|
||||
+++ b/utils/fwparam_ibft/fwparam_ppc.c
|
||||
@@ -132,6 +132,7 @@ static int locate_mac(const char *devtree, struct ofw_dev *ofwdev)
|
||||
error = errno;
|
||||
fprintf(stderr, "%s: open %s, %s\n", __func__, mac_file,
|
||||
strerror(errno));
|
||||
+ free(mac_file);
|
||||
goto lpm_bail;
|
||||
}
|
||||
|
||||
@@ -140,12 +141,10 @@ static int locate_mac(const char *devtree, struct ofw_dev *ofwdev)
|
||||
error = EIO;
|
||||
fprintf(stderr, "%s: read %s, %s\n", __func__, mac_file,
|
||||
strerror(errno));
|
||||
- goto lpm_bail;
|
||||
}
|
||||
free(mac_file);
|
||||
close(mac_fd);
|
||||
|
||||
-
|
||||
lpm_bail:
|
||||
return error;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
||||
25
6019-Resource-leak-Handl-variable-fd.patch
Normal file
25
6019-Resource-leak-Handl-variable-fd.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 504b990bc886d708ae673ac1fa0e09e7911c2823 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Thu, 31 Oct 2019 15:08:40 -0700
|
||||
Subject: [PATCH 40/43] Resource leak: Handle variable fd going out of scope
|
||||
leaks the handle.
|
||||
|
||||
---
|
||||
iscsiuio/src/unix/main.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/iscsiuio/src/unix/main.c b/iscsiuio/src/unix/main.c
|
||||
index 5168e4e..5e3f66c 100644
|
||||
--- a/iscsiuio/src/unix/main.c
|
||||
+++ b/iscsiuio/src/unix/main.c
|
||||
@@ -196,6 +196,7 @@ static void daemon_init()
|
||||
dup2(fd, 2);
|
||||
setsid();
|
||||
chdir("/");
|
||||
+ close(fd);
|
||||
}
|
||||
|
||||
#define ISCSI_OOM_PATH_LEN 48
|
||||
--
|
||||
2.21.0
|
||||
|
||||
25
6020-Resource-leak-Variable-raw.patch
Normal file
25
6020-Resource-leak-Variable-raw.patch
Normal file
@ -0,0 +1,25 @@
|
||||
From 860187423092ba43112f4c2d303978dda7254c58 Mon Sep 17 00:00:00 2001
|
||||
From: Chris Leech <cleech@redhat.com>
|
||||
Date: Thu, 31 Oct 2019 15:22:02 -0700
|
||||
Subject: [PATCH 42/43] Resource leak: Variable raw going out of scope leaks
|
||||
the storage it points to.
|
||||
|
||||
---
|
||||
iscsiuio/src/unix/nic_utils.c | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/iscsiuio/src/unix/nic_utils.c b/iscsiuio/src/unix/nic_utils.c
|
||||
index aad679e..84ffc5c 100644
|
||||
--- a/iscsiuio/src/unix/nic_utils.c
|
||||
+++ b/iscsiuio/src/unix/nic_utils.c
|
||||
@@ -245,6 +245,7 @@ int nic_discover_iscsi_hosts()
|
||||
"space for NIC %s "
|
||||
"during scan", raw);
|
||||
|
||||
+ free(raw);
|
||||
rc = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
--
|
||||
2.21.0
|
||||
|
||||
29
6021-Allow-reading-sysfs-port-to-fail-gracefully.patch
Normal file
29
6021-Allow-reading-sysfs-port-to-fail-gracefully.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From d8298fc54eb69d3989878be46e9c7d6ec2055650 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Mon, 24 Sep 2018 16:22:18 -0700
|
||||
Subject: [PATCH 05/87] Allow reading sysfs "port" to fail gracefully.
|
||||
|
||||
Do not consider it a fatal error if reading sysfs value
|
||||
for "port" fails, since we allow failure for "address".
|
||||
---
|
||||
libopeniscsiusr/session.c | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c
|
||||
index a833939..f8c89c3 100644
|
||||
--- a/libopeniscsiusr/session.c
|
||||
+++ b/libopeniscsiusr/session.c
|
||||
@@ -205,8 +205,8 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
|
||||
_sysfs_prop_get_str(ctx, sysfs_con_dir_path, "address", (*se)->address,
|
||||
sizeof((*se)->address) / sizeof(char), "");
|
||||
|
||||
- _good(_sysfs_prop_get_i32(ctx, sysfs_con_dir_path, "port",
|
||||
- &((*se)->port), -1, false), rc, out);
|
||||
+ _sysfs_prop_get_i32(ctx, sysfs_con_dir_path, "port",
|
||||
+ &((*se)->port), -1, true);
|
||||
|
||||
if ((strcmp((*se)->address, "") == 0) &&
|
||||
(strcmp((*se)->persistent_address, "") != 0))
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
50
6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch
Normal file
50
6022-Fix-incorrect-sysfs-logic-for-port-and-ip-address.patch
Normal file
@ -0,0 +1,50 @@
|
||||
From 7df5edbb427c79337bdd651c2bcdda8eb05f077b Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Mon, 24 Sep 2018 16:30:34 -0700
|
||||
Subject: [PATCH 06/87] Fix incorrect sysfs logic for port and ip address.
|
||||
|
||||
If "port" is available and "persistent_port" is not, then
|
||||
correctly use the one that is present for both values.
|
||||
Likewise for "address" and "persistent_address".
|
||||
---
|
||||
libopeniscsiusr/session.c | 18 ++++++++----------
|
||||
1 file changed, 8 insertions(+), 10 deletions(-)
|
||||
|
||||
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c
|
||||
index f8c89c3..98601dc 100644
|
||||
--- a/libopeniscsiusr/session.c
|
||||
+++ b/libopeniscsiusr/session.c
|
||||
@@ -208,22 +208,20 @@ int iscsi_session_get(struct iscsi_context *ctx, uint32_t sid,
|
||||
_sysfs_prop_get_i32(ctx, sysfs_con_dir_path, "port",
|
||||
&((*se)->port), -1, true);
|
||||
|
||||
- if ((strcmp((*se)->address, "") == 0) &&
|
||||
- (strcmp((*se)->persistent_address, "") != 0))
|
||||
- _strncpy((*se)->persistent_address, (*se)->address,
|
||||
- sizeof((*se)->persistent_address) / sizeof(char));
|
||||
-
|
||||
if ((strcmp((*se)->address, "") != 0) &&
|
||||
(strcmp((*se)->persistent_address, "") == 0))
|
||||
+ _strncpy((*se)->persistent_address, (*se)->address,
|
||||
+ sizeof((*se)->persistent_address) / sizeof(char));
|
||||
+ else if ((strcmp((*se)->address, "") == 0) &&
|
||||
+ (strcmp((*se)->persistent_address, "") != 0))
|
||||
_strncpy((*se)->address, (*se)->persistent_address,
|
||||
sizeof((*se)->address) / sizeof(char));
|
||||
|
||||
- if (((*se)->persistent_port != -1) &&
|
||||
- ((*se)->port == -1))
|
||||
+ if (((*se)->persistent_port == -1) &&
|
||||
+ ((*se)->port != -1))
|
||||
(*se)->persistent_port = (*se)->port;
|
||||
-
|
||||
- if (((*se)->persistent_port != -1) &&
|
||||
- ((*se)->port == -1))
|
||||
+ else if (((*se)->persistent_port != -1) &&
|
||||
+ ((*se)->port == -1))
|
||||
(*se)->port = (*se)->persistent_port;
|
||||
|
||||
_good(_iscsi_host_id_of_session(ctx, sid, &host_id), rc, out);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,65 @@
|
||||
From ae0b2ceb620e2bf527c06d21c110791d1e0e8bf4 Mon Sep 17 00:00:00 2001
|
||||
From: Lee Duncan <lduncan@suse.com>
|
||||
Date: Tue, 25 Sep 2018 09:57:46 -0700
|
||||
Subject: [PATCH 10/87] Handle ENOTCONN error separately when reading sysfs
|
||||
values.
|
||||
|
||||
This error happens when the daemon is attempting to
|
||||
reconnect a session when starting up, so should not
|
||||
be considered an internal error.
|
||||
---
|
||||
libopeniscsiusr/sysfs.c | 31 +++++++++++++++++++++++++++++++
|
||||
1 file changed, 31 insertions(+)
|
||||
|
||||
diff --git a/libopeniscsiusr/sysfs.c b/libopeniscsiusr/sysfs.c
|
||||
index 5e6532e..2c3f077 100644
|
||||
--- a/libopeniscsiusr/sysfs.c
|
||||
+++ b/libopeniscsiusr/sysfs.c
|
||||
@@ -184,6 +184,21 @@ int _sysfs_prop_get_str(struct iscsi_context *ctx, const char *dir_path,
|
||||
_error(ctx, "Failed to read '%s': "
|
||||
"permission deny when reading '%s'", prop_name,
|
||||
file_path);
|
||||
+ } else if (errno_save == ENOTCONN) {
|
||||
+ if (default_value == NULL) {
|
||||
+ rc = LIBISCSI_ERR_SYSFS_LOOKUP;
|
||||
+ _error(ctx, "Failed to read '%s': "
|
||||
+ "error when reading '%s': "
|
||||
+ "Target unavailable",
|
||||
+ prop_name, file_path);
|
||||
+ } else {
|
||||
+ _info(ctx, "Failed to read '%s': "
|
||||
+ "error when reading '%s': "
|
||||
+ "Target unavailable, using default value '%s'",
|
||||
+ prop_name, file_path, default_value);
|
||||
+ memcpy(buff, (void *) default_value,
|
||||
+ strlen(default_value) + 1);
|
||||
+ }
|
||||
} else {
|
||||
rc = LIBISCSI_ERR_BUG;
|
||||
_error(ctx, "Failed to read '%s': "
|
||||
@@ -246,6 +261,22 @@ static int iscsi_sysfs_prop_get_ll(struct iscsi_context *ctx,
|
||||
_error(ctx, "Permission deny when reading '%s'",
|
||||
file_path);
|
||||
goto out;
|
||||
+ } else if (errno_save == ENOTCONN) {
|
||||
+ if (!ignore_error) {
|
||||
+ rc = LIBISCSI_ERR_SYSFS_LOOKUP;
|
||||
+ _error(ctx, "Failed to read '%s': "
|
||||
+ "error when reading '%s': "
|
||||
+ "Target unavailable",
|
||||
+ prop_name, file_path);
|
||||
+ goto out;
|
||||
+ } else {
|
||||
+ _info(ctx, "Failed to read '%s': "
|
||||
+ "error when reading '%s': "
|
||||
+ "Target unavailable, using default value %lld",
|
||||
+ prop_name, file_path, default_value);
|
||||
+ *val = default_value;
|
||||
+ goto out;
|
||||
+ }
|
||||
} else {
|
||||
rc = LIBISCSI_ERR_BUG;
|
||||
_error(ctx, "Error when reading '%s': %d", file_path,
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
123
6024-update-service-files.patch
Normal file
123
6024-update-service-files.patch
Normal file
@ -0,0 +1,123 @@
|
||||
From 74df2457ac1f91fa752d3143e2e6b6f99b67a0a8 Mon Sep 17 00:00:00 2001
|
||||
From: openEuler Buildteam <buildteam@openeuler.org>
|
||||
Date: Wed, 8 Jan 2020 03:26:02 -0500
|
||||
Subject: [PATCH] update service files
|
||||
|
||||
---
|
||||
etc/systemd/iscsi.service | 18 ++++++++++++++++++
|
||||
etc/systemd/iscsid.service | 14 +++++++++-----
|
||||
etc/systemd/iscsid.socket | 2 +-
|
||||
etc/systemd/iscsiuio.service | 19 +++++++++++++++++++
|
||||
etc/systemd/iscsiuio.socket | 9 +++++++++
|
||||
5 files changed, 56 insertions(+), 6 deletions(-)
|
||||
create mode 100644 etc/systemd/iscsi.service
|
||||
create mode 100644 etc/systemd/iscsiuio.service
|
||||
create mode 100644 etc/systemd/iscsiuio.socket
|
||||
|
||||
diff --git a/etc/systemd/iscsi.service b/etc/systemd/iscsi.service
|
||||
new file mode 100644
|
||||
index 0000000..e475888
|
||||
--- /dev/null
|
||||
+++ b/etc/systemd/iscsi.service
|
||||
@@ -0,0 +1,18 @@
|
||||
+[Unit]
|
||||
+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
|
||||
+ConditionPathExists=/etc/iscsi/initiatorname.iscsi
|
||||
+
|
||||
+[Service]
|
||||
+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
|
||||
+RemainAfterExit=true
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=remote-fs.target
|
||||
diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
|
||||
index 028e0b3..4fef168 100644
|
||||
--- a/etc/systemd/iscsid.service
|
||||
+++ b/etc/systemd/iscsid.service
|
||||
@@ -1,13 +1,17 @@
|
||||
[Unit]
|
||||
Description=Open-iSCSI
|
||||
Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
|
||||
-After=network.target NetworkManager-wait-online.service iscsiuio.service tgtd.service targetcli.service
|
||||
+DefaultDependencies=no
|
||||
+DefaultDependencies=no
|
||||
+After=network.target iscsiuio.service
|
||||
+Before=remote-fs-pre.target
|
||||
|
||||
[Service]
|
||||
-Type=forking
|
||||
-PIDFile=/var/run/iscsid.pid
|
||||
-ExecStart=/usr/sbin/iscsid
|
||||
-ExecStop=/sbin/iscsiadm -k 0 2
|
||||
+Type=notify
|
||||
+NotifyAccess=main
|
||||
+ExecStart=/sbin/iscsid -f
|
||||
+KillMode=mixed
|
||||
+Restart=on-failure
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
+Also=iscsid.socket
|
||||
diff --git a/etc/systemd/iscsid.socket b/etc/systemd/iscsid.socket
|
||||
index 832451d..58a8d12 100644
|
||||
--- a/etc/systemd/iscsid.socket
|
||||
+++ b/etc/systemd/iscsid.socket
|
||||
@@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=Open-iSCSI iscsid Socket
|
||||
-Documentation=man:iscsid(8) man:iscsiuio(8) man:iscsiadm(8)
|
||||
+Documentation=man:iscsid(8) man:iscsiadm(8)
|
||||
|
||||
[Socket]
|
||||
ListenStream=@ISCSIADM_ABSTRACT_NAMESPACE
|
||||
diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service
|
||||
new file mode 100644
|
||||
index 0000000..e4d9fd0
|
||||
--- /dev/null
|
||||
+++ b/etc/systemd/iscsiuio.service
|
||||
@@ -0,0 +1,19 @@
|
||||
+[Unit]
|
||||
+Description=iSCSI UserSpace I/O driver
|
||||
+Documentation=man:iscsiuio(8)
|
||||
+DefaultDependencies=no
|
||||
+Conflicts=shutdown.target
|
||||
+Requires=iscsid.service
|
||||
+BindTo=iscsid.service
|
||||
+After=network.target
|
||||
+Before=remote-fs-pre.target iscsid.service
|
||||
+
|
||||
+[Service]
|
||||
+Type=notify
|
||||
+NotifyAccess=main
|
||||
+ExecStart=/sbin/iscsiuio -f
|
||||
+KillMode=mixed
|
||||
+Restart=on-failure
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=multi-user.target
|
||||
diff --git a/etc/systemd/iscsiuio.socket b/etc/systemd/iscsiuio.socket
|
||||
new file mode 100644
|
||||
index 0000000..d42cedc
|
||||
--- /dev/null
|
||||
+++ b/etc/systemd/iscsiuio.socket
|
||||
@@ -0,0 +1,9 @@
|
||||
+[Unit]
|
||||
+Description=Open-iSCSI iscsiuio Socket
|
||||
+Documentation=man:iscsiuio(8)
|
||||
+
|
||||
+[Socket]
|
||||
+ListenStream=@ISCSID_UIP_ABSTRACT_NAMESPACE
|
||||
+
|
||||
+[Install]
|
||||
+WantedBy=sockets.target
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
41
9000-change-iscsi-iqn-default-value.patch
Normal file
41
9000-change-iscsi-iqn-default-value.patch
Normal file
@ -0,0 +1,41 @@
|
||||
From 2fb5d2dbcfdc052881749e22268c06b1402257a7 Mon Sep 17 00:00:00 2001
|
||||
From: pengyeqing <pengyeqing@huawei.com>
|
||||
Date: Sat, 26 Jan 2019 22:09:24 +0800
|
||||
Subject: [PATCH] iscsi-initiator-utils: change iscsi iqn default value
|
||||
|
||||
reason:change iscsi iqn default value
|
||||
|
||||
Signed-off-by: pengyeqing <pengyeqing@huawei.com>
|
||||
---
|
||||
doc/iscsi-iname.8 | 2 +-
|
||||
utils/iscsi-iname.c | 2 +-
|
||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/doc/iscsi-iname.8 b/doc/iscsi-iname.8
|
||||
index a55d666d1af3..dd77ed9f3165 100644
|
||||
--- a/doc/iscsi-iname.8
|
||||
+++ b/doc/iscsi-iname.8
|
||||
@@ -14,7 +14,7 @@ generates a unique iSCSI node name on every invocation.
|
||||
Display help
|
||||
.TP
|
||||
.BI [-p=]\fIprefix\fP
|
||||
-Use the prefix passed in instead of the default "iqn.2005-03.org.open-iscsi"
|
||||
+Use the prefix passed in instead of the default "iqn.2012-01.com.openeuler"
|
||||
|
||||
.SH AUTHORS
|
||||
Open-iSCSI project <http://www.open-iscsi.com/>
|
||||
diff --git a/utils/iscsi-iname.c b/utils/iscsi-iname.c
|
||||
index cb2f6c8..926bf3a 100644
|
||||
--- a/utils/iscsi-iname.c
|
||||
+++ b/utils/iscsi-iname.c
|
||||
@@ -73,7 +73,7 @@ main(int argc, char *argv[])
|
||||
exit(0);
|
||||
}
|
||||
} else {
|
||||
- prefix = "iqn.2005-03.org.open-iscsi";
|
||||
+ prefix = "iqn.2012-01.com.openeuler";
|
||||
}
|
||||
|
||||
/* try to feed some entropy from the pool to MD5 in order to get
|
||||
--
|
||||
1.8.3.1
|
||||
109
9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch
Normal file
109
9001-iscsid-Check-nr_sessions-when-creating-a-copy-of-exi.patch
Normal file
@ -0,0 +1,109 @@
|
||||
From 47849daf73c1978491c05e9619063ff8a529ca48 Mon Sep 17 00:00:00 2001
|
||||
From: Tang Chen <tang.chen@huawei.com>
|
||||
Date: Thu, 12 Oct 2017 04:56:16 +0800
|
||||
Subject: [PATCH 1/1] iscsid: Check nr_sessions when creating a copy of
|
||||
existing session
|
||||
|
||||
For multipath configurations, you may want more than one session to be
|
||||
created on each iface record. If node.session.nr_sessions is greater
|
||||
than 1, performing a 'login' for that node will ensure that the
|
||||
appropriate number of sessions is created.
|
||||
|
||||
node.session.nr_sessions = 1
|
||||
|
||||
In iscsiadm command, we set session.multiple to 1, which means we can
|
||||
create multiple copies of an existing session.
|
||||
|
||||
iscsi_login_portal()
|
||||
|--> rec->session.multiple = 1
|
||||
|
||||
But in iscsid, we didn't check nr_sessions when executing login task.
|
||||
|
||||
__session_login_task()
|
||||
|--> session_is_running()
|
||||
|--> iscsi_sysfs_for_each_session()
|
||||
|--> if (rec->session.multiple)
|
||||
log_debug(2, "Adding a copy of an existing session");
|
||||
|
||||
So this patch adds a checking to iscsid login task.
|
||||
|
||||
Signed-off-by: Tang Chen <tang.chen@huawei.com>
|
||||
|
||||
---
|
||||
usr/initiator.c | 31 ++++++++++++++++++-------------
|
||||
1 files changed, 18 insertions(+), 13 deletions(-)
|
||||
|
||||
diff --git a/usr/initiator.c b/usr/initiator.c
|
||||
index a86d1e6..9248962 100644
|
||||
--- a/usr/initiator.c
|
||||
+++ b/usr/initiator.c
|
||||
@@ -1754,10 +1754,11 @@ static int iscsi_sched_ev_context(struct iscsi_ev_context *ev_context,
|
||||
return 0;
|
||||
}
|
||||
|
||||
-static iscsi_session_t* session_find_by_rec(node_rec_t *rec)
|
||||
+static int session_find_by_rec(node_rec_t *rec)
|
||||
{
|
||||
struct iscsi_transport *t;
|
||||
iscsi_session_t *session;
|
||||
+ int nr_found = 0;
|
||||
|
||||
list_for_each_entry(t, &transports, list) {
|
||||
list_for_each_entry(session, &t->sessions, list) {
|
||||
@@ -1766,24 +1767,23 @@ static iscsi_session_t* session_find_by_rec(node_rec_t *rec)
|
||||
session->nrec.conn[0].port,
|
||||
&session->nrec.iface,
|
||||
MATCH_ANY_SID))
|
||||
- return session;
|
||||
+ nr_found++;
|
||||
}
|
||||
}
|
||||
- return NULL;
|
||||
+ return nr_found;
|
||||
}
|
||||
|
||||
/*
|
||||
* a session could be running in the kernel but not in iscsid
|
||||
* due to a resync or because some other app started the session
|
||||
*/
|
||||
-static int session_is_running(node_rec_t *rec)
|
||||
+static int session_is_running(node_rec_t *rec, int *nr_found)
|
||||
{
|
||||
- int nr_found = 0;
|
||||
-
|
||||
- if (session_find_by_rec(rec))
|
||||
+ *nr_found = session_find_by_rec(rec);
|
||||
+ if (*nr_found)
|
||||
return 1;
|
||||
|
||||
- if (iscsi_sysfs_for_each_session(rec, &nr_found, iscsi_match_session,
|
||||
+ if (iscsi_sysfs_for_each_session(rec, nr_found, iscsi_match_session,
|
||||
0))
|
||||
return 1;
|
||||
|
||||
@@ -1795,12 +1795,17 @@ static int __session_login_task(node_rec_t *rec, queue_task_t *qtask)
|
||||
iscsi_session_t *session;
|
||||
iscsi_conn_t *conn;
|
||||
struct iscsi_transport *t;
|
||||
- int rc;
|
||||
-
|
||||
- if (session_is_running(rec)) {
|
||||
- if (rec->session.multiple)
|
||||
+ int rc, nr_found = 0;
|
||||
+
|
||||
+ if (session_is_running(rec, &nr_found)) {
|
||||
+ if (rec->session.multiple) {
|
||||
+ if (nr_found >= rec->session.nr_sessions) {
|
||||
+ log_debug(2, "Cannot add more copy of session,"
|
||||
+ " %d found.\n", nr_found);
|
||||
+ return ISCSI_ERR_SESS_EXISTS;
|
||||
+ }
|
||||
log_debug(2, "Adding a copy of an existing session");
|
||||
- else
|
||||
+ } else
|
||||
return ISCSI_ERR_SESS_EXISTS;
|
||||
}
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
23
9002-add-sleep-for-service.patch
Normal file
23
9002-add-sleep-for-service.patch
Normal file
@ -0,0 +1,23 @@
|
||||
From 8badb69eb47e3c93619fccf5667a0d681b5a34a6 Mon Sep 17 00:00:00 2001
|
||||
From: openEuler Buildteam <buildteam@openeuler.org>
|
||||
Date: Wed, 8 Jan 2020 03:33:14 -0500
|
||||
Subject: [PATCH] iscsi-initiator-utils: add sleep for service
|
||||
|
||||
---
|
||||
etc/systemd/iscsid.service | 1 +
|
||||
1 file changed, 1 insertion(+)
|
||||
|
||||
diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
|
||||
index 4fef168..8df224e 100644
|
||||
--- a/etc/systemd/iscsid.service
|
||||
+++ b/etc/systemd/iscsid.service
|
||||
@@ -9,6 +9,7 @@ Before=remote-fs-pre.target
|
||||
Type=notify
|
||||
NotifyAccess=main
|
||||
ExecStart=/sbin/iscsid -f
|
||||
+ExecStartPost=/usr/bin/sleep 1
|
||||
KillMode=mixed
|
||||
Restart=on-failure
|
||||
|
||||
--
|
||||
1.8.3.1
|
||||
148
9003-not-send-stop-message-if-iscsid-absent.patch
Normal file
148
9003-not-send-stop-message-if-iscsid-absent.patch
Normal file
@ -0,0 +1,148 @@
|
||||
From 17764fc96f0ece0dca472d7f9b6105c62b4d7701 Mon Sep 17 00:00:00 2001
|
||||
From: openEuler Buildteam <buildteam@openeuler.org>
|
||||
Date: Wed, 8 Jan 2020 03:43:16 -0500
|
||||
Subject: [PATCH] iscsi-initiator-utils: not send stop message if iscsid absent
|
||||
|
||||
---
|
||||
etc/systemd/iscsid.service | 1 +
|
||||
etc/systemd/iscsiuio.service | 3 +-
|
||||
usr/iscsiadm.c | 71 ++++++++++++++++++++++++++++++++++++++++++++
|
||||
3 files changed, 74 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/etc/systemd/iscsid.service b/etc/systemd/iscsid.service
|
||||
index 8df224e..fd85d52 100644
|
||||
--- a/etc/systemd/iscsid.service
|
||||
+++ b/etc/systemd/iscsid.service
|
||||
@@ -12,6 +12,7 @@ ExecStart=/sbin/iscsid -f
|
||||
ExecStartPost=/usr/bin/sleep 1
|
||||
KillMode=mixed
|
||||
Restart=on-failure
|
||||
+RestartSec=2s
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
diff --git a/etc/systemd/iscsiuio.service b/etc/systemd/iscsiuio.service
|
||||
index e4d9fd0..6bae65b 100644
|
||||
--- a/etc/systemd/iscsiuio.service
|
||||
+++ b/etc/systemd/iscsiuio.service
|
||||
@@ -4,7 +4,7 @@ Documentation=man:iscsiuio(8)
|
||||
DefaultDependencies=no
|
||||
Conflicts=shutdown.target
|
||||
Requires=iscsid.service
|
||||
-BindTo=iscsid.service
|
||||
+BindsTo=iscsid.service
|
||||
After=network.target
|
||||
Before=remote-fs-pre.target iscsid.service
|
||||
|
||||
@@ -14,6 +14,7 @@ NotifyAccess=main
|
||||
ExecStart=/sbin/iscsiuio -f
|
||||
KillMode=mixed
|
||||
Restart=on-failure
|
||||
+TimeoutStopSec=1
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
||||
index 4796c2f..8b5d5fe 100644
|
||||
--- a/usr/iscsiadm.c
|
||||
+++ b/usr/iscsiadm.c
|
||||
@@ -69,6 +69,8 @@ static char program_name[] = "iscsiadm";
|
||||
static char config_file[TARGET_NAME_MAXLEN];
|
||||
extern struct iscsi_ipc *ipc;
|
||||
|
||||
+#define ISCSIPID_LEN 256
|
||||
+
|
||||
enum iscsiadm_mode {
|
||||
MODE_DISCOVERY,
|
||||
MODE_DISCOVERYDB,
|
||||
@@ -267,11 +269,52 @@ str_to_portal_type(char *str)
|
||||
return ptype;
|
||||
}
|
||||
|
||||
+/**
|
||||
+ * get_content() - Utility function to read hex values from sysfs
|
||||
+ * @param pidfile - path to use
|
||||
+ * @parm buf - this is the value returned from the entry
|
||||
+ * @return 0 on success <0 on failure
|
||||
+ * @note: buf[] return without '\0'
|
||||
+ */
|
||||
+static int get_file_content(const char *pidfile, char buf[], int buflen)
|
||||
+{
|
||||
+ int rc = 0;
|
||||
+ FILE *fp = NULL;
|
||||
+ size_t chars_read = 0;
|
||||
+
|
||||
+ fp = fopen(pidfile, "r");
|
||||
+ if (fp == NULL) {
|
||||
+ log_error("Could not open path: %s [%s]",
|
||||
+ pidfile, strerror(errno));
|
||||
+ rc = -EIO;
|
||||
+ goto error_fopen;
|
||||
+ }
|
||||
+
|
||||
+ chars_read = fread(buf, 1, buflen, fp);
|
||||
+ if ((chars_read <= 0) && ferror(fp)) {
|
||||
+ log_error("Could not read from: %s [%s]",
|
||||
+ pidfile, strerror(ferror(fp)));
|
||||
+ rc = -EIO;
|
||||
+ goto error;
|
||||
+ }
|
||||
+
|
||||
+error:
|
||||
+ fclose(fp);
|
||||
+
|
||||
+error_fopen:
|
||||
+ return rc;
|
||||
+}
|
||||
+
|
||||
static void kill_iscsid(int priority, int tmo)
|
||||
{
|
||||
iscsiadm_req_t req;
|
||||
iscsiadm_rsp_t rsp;
|
||||
int rc;
|
||||
+ char *pTmp = NULL;
|
||||
+ char iscsidpid[ISCSIPID_LEN] = {0};
|
||||
+ char procpid[ISCSIPID_LEN] = {0};
|
||||
+ char cmdline[ISCSIPID_LEN] = {0};
|
||||
+ char iscsidcmdline[ISCSIPID_LEN] = {0};
|
||||
|
||||
/*
|
||||
* We only support SIGTERM like stoppage of iscsid for now.
|
||||
@@ -287,6 +330,34 @@ static void kill_iscsid(int priority, int tmo)
|
||||
return;
|
||||
}
|
||||
|
||||
+ /* if pid of iscsid is present, go on; or return directly */
|
||||
+ rc = get_file_content(PID_FILE, iscsidpid, ISCSIPID_LEN);
|
||||
+ if (rc != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(procpid, ISCSIPID_LEN, "/proc/%ld/cmdline", atol(iscsidpid));
|
||||
+
|
||||
+ rc = get_file_content(procpid, cmdline, ISCSIPID_LEN);
|
||||
+ if (rc != 0) {
|
||||
+ return;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(iscsidcmdline, ISCSIPID_LEN, "%s", cmdline);
|
||||
+
|
||||
+ pTmp = strstr(iscsidcmdline, "iscsid");
|
||||
+ if (NULL == pTmp) {
|
||||
+ log_error("iscsid pid mismatch proc cmdline, pid:%ld, cmdline:%s.\n", atol(iscsidpid), iscsidcmdline);
|
||||
+ return;
|
||||
+ } else {
|
||||
+ rc = kill(atol(iscsidpid), 0);
|
||||
+ if (ESRCH == rc) {
|
||||
+ log_error("iscsid %d maybe in zombie.\n", atol(iscsidpid));
|
||||
+ return;
|
||||
+ }
|
||||
+ }
|
||||
+ /* end */
|
||||
+
|
||||
memset(&req, 0, sizeof(req));
|
||||
req.command = MGMT_IPC_IMMEDIATE_STOP;
|
||||
rc = iscsid_exec_req(&req, &rsp, 0, tmo);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
76
9004-iscsid-SIGTERM-syncprocess-hang.patch
Normal file
76
9004-iscsid-SIGTERM-syncprocess-hang.patch
Normal file
@ -0,0 +1,76 @@
|
||||
From 1f4eb61f62a4f4245ddfd61440eb679f65ae8194 Mon Sep 17 00:00:00 2001
|
||||
From: pengyeqing <pengyeqing@huawei.com>
|
||||
Date: Sat, 26 Jan 2019 23:41:05 +0800
|
||||
Subject: [PATCH] iscsi-initiator-utils: iscsid SIGTERM syncprocess hang
|
||||
|
||||
reason:iscsid SIGTERM syncprocess hang
|
||||
|
||||
Signed-off-by: pengyeqing <pengyeqing@huawei.com>
|
||||
---
|
||||
usr/iscsid.c | 2 ++
|
||||
usr/iscsid_req.c | 10 ++++++++++
|
||||
usr/iscsid_req.h | 1 +
|
||||
3 files changed, 13 insertions(+)
|
||||
|
||||
diff --git a/usr/iscsid.c b/usr/iscsid.c
|
||||
index b95917d..48d0f52 100644
|
||||
--- a/usr/iscsid.c
|
||||
+++ b/usr/iscsid.c
|
||||
@@ -39,6 +39,7 @@
|
||||
#include "mgmt_ipc.h"
|
||||
#include "event_poll.h"
|
||||
#include "iscsi_ipc.h"
|
||||
+#include "iscsid_req.h"
|
||||
#include "log.h"
|
||||
#include "iscsi_util.h"
|
||||
#include "initiator.h"
|
||||
@@ -314,6 +315,7 @@ static void catch_signal(int signo)
|
||||
switch (signo) {
|
||||
case SIGTERM:
|
||||
event_loop_exit(NULL);
|
||||
+ signal_term_in();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
|
||||
index d18b14d..76aa035 100644
|
||||
--- a/usr/iscsid_req.c
|
||||
+++ b/usr/iscsid_req.c
|
||||
@@ -37,6 +37,13 @@
|
||||
#include "iscsid_req.h"
|
||||
#include "uip_mgmt_ipc.h"
|
||||
|
||||
+static int sigterm_in;
|
||||
+
|
||||
+void signal_term_in()
|
||||
+{
|
||||
+ sigterm_in= 1;
|
||||
+}
|
||||
+
|
||||
static void iscsid_startup(void)
|
||||
{
|
||||
char *startup_cmd;
|
||||
@@ -145,6 +152,9 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp,
|
||||
while (len) {
|
||||
struct pollfd pfd;
|
||||
|
||||
+ if (sigterm_in)
|
||||
+ return ISCSI_ERR_ISCSID_COMM_ERR;
|
||||
+
|
||||
pfd.fd = fd;
|
||||
pfd.events = POLLIN;
|
||||
err = poll(&pfd, 1, timeout);
|
||||
diff --git a/usr/iscsid_req.h b/usr/iscsid_req.h
|
||||
index d580ed2..6f139a8 100644
|
||||
--- a/usr/iscsid_req.h
|
||||
+++ b/usr/iscsid_req.h
|
||||
@@ -41,5 +41,6 @@ extern int iscsid_req_by_sid(iscsiadm_cmd_e cmd, int sid);
|
||||
|
||||
extern int uip_broadcast(void *buf, size_t buf_len, int fd_flags,
|
||||
uint32_t *status);
|
||||
+extern void signal_term_in(void);
|
||||
|
||||
#endif
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
29
9005-fix-timeout-setting-on-session-commands.patch
Normal file
29
9005-fix-timeout-setting-on-session-commands.patch
Normal file
@ -0,0 +1,29 @@
|
||||
From 3de6ac0237bf10e6ba60e72faa4c06cfb469e070 Mon Sep 17 00:00:00 2001
|
||||
From: pengyeqing <pengyeqing@huawei.com>
|
||||
Date: Sat, 26 Jan 2019 23:53:37 +0800
|
||||
Subject: [PATCH] iscsi-initiator-utils: fix timeout setting on session
|
||||
commands
|
||||
|
||||
reason:fix timeout setting on session commands
|
||||
|
||||
Signed-off-by: pengyeqing <pengyeqing@huawei.com>
|
||||
---
|
||||
usr/iscsiadm.c | 2 ++
|
||||
1 file changed, 2 insertions(+)
|
||||
|
||||
diff --git a/usr/iscsiadm.c b/usr/iscsiadm.c
|
||||
index a6b9605..5d432cd 100644
|
||||
--- a/usr/iscsiadm.c
|
||||
+++ b/usr/iscsiadm.c
|
||||
@@ -4018,6 +4018,8 @@ main(int argc, char **argv)
|
||||
goto out;
|
||||
}
|
||||
|
||||
+ info->iscsid_req_tmo = -1;
|
||||
+
|
||||
rc = iscsi_sysfs_get_sessioninfo_by_id(info, session);
|
||||
if (rc) {
|
||||
log_error("Could not get session info for sid "
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
296
9006-restart-log-daemon-when-exited-abnormally.patch
Normal file
296
9006-restart-log-daemon-when-exited-abnormally.patch
Normal file
@ -0,0 +1,296 @@
|
||||
From 10886ac1cf645b7eefb113a03eb31ef7a49f5910 Mon Sep 17 00:00:00 2001
|
||||
From: wangjufeng <wangjufeng@huawei.com>
|
||||
Date: Sat, 20 Oct 2018 14:50:28 +0800
|
||||
Subject: [PATCH] tt
|
||||
|
||||
---
|
||||
usr/event_poll.c | 17 +++++++-
|
||||
usr/iscsid.c | 2 +-
|
||||
usr/log.c | 120 ++++++++++++++++++++++++++++++++++++++++++++++++++++++-
|
||||
usr/log.h | 6 +++
|
||||
4 files changed, 140 insertions(+), 5 deletions(-)
|
||||
|
||||
diff --git a/usr/event_poll.c b/usr/event_poll.c
|
||||
index ac25044..a3a3676 100644
|
||||
--- a/usr/event_poll.c
|
||||
+++ b/usr/event_poll.c
|
||||
@@ -134,8 +134,11 @@ void event_loop_exit(queue_task_t *qtask)
|
||||
|
||||
void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
|
||||
{
|
||||
- struct pollfd poll_array[POLL_MAX];
|
||||
+ struct pollfd poll_array[POLL_MAX + 1];
|
||||
int res, has_shutdown_children = 0;
|
||||
+ int log_timerfd = log_get_timerfd();
|
||||
+ int pool_count = POLL_MAX;
|
||||
+ int poll_timerfd_index = -1;
|
||||
sigset_t sigset;
|
||||
int sig_fd;
|
||||
|
||||
@@ -157,6 +160,13 @@ void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
|
||||
poll_array[POLL_ALARM].fd = sig_fd;
|
||||
poll_array[POLL_ALARM].events = POLLIN;
|
||||
|
||||
+ if (log_timerfd >= 0) {
|
||||
+ poll_array[POLL_MAX].fd = log_timerfd;
|
||||
+ poll_array[POLL_MAX].events = POLLIN;
|
||||
+ poll_timerfd_index = POLL_MAX;
|
||||
+ pool_count += 1;
|
||||
+ }
|
||||
+
|
||||
event_loop_stop = 0;
|
||||
while (1) {
|
||||
if (event_loop_stop) {
|
||||
@@ -171,7 +181,7 @@ void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
|
||||
/* Runs actors and may set alarm for future actors */
|
||||
actor_poll();
|
||||
|
||||
- res = poll(poll_array, POLL_MAX, reap_count ? REAP_WAKEUP : -1);
|
||||
+ res = poll(poll_array, pool_count, reap_count ? REAP_WAKEUP : -1);
|
||||
|
||||
if (res > 0) {
|
||||
log_debug(6, "poll result %d", res);
|
||||
@@ -181,6 +191,9 @@ void event_loop(struct iscsi_ipc *ipc, int control_fd, int mgmt_ipc_fd)
|
||||
if (poll_array[POLL_IPC].revents)
|
||||
mgmt_ipc_handle(mgmt_ipc_fd);
|
||||
|
||||
+ if(log_timerfd >= 0 && poll_array[poll_timerfd_index].revents)
|
||||
+ log_watchdog_handle();
|
||||
+
|
||||
if (poll_array[POLL_ALARM].revents) {
|
||||
struct signalfd_siginfo si;
|
||||
|
||||
diff --git a/usr/iscsid.c b/usr/iscsid.c
|
||||
index 8202bc9..6329644 100644
|
||||
--- a/usr/iscsid.c
|
||||
+++ b/usr/iscsid.c
|
||||
@@ -59,7 +59,6 @@ struct iscsi_daemon_config daemon_config;
|
||||
struct iscsi_daemon_config *dconfig = &daemon_config;
|
||||
|
||||
static char program_name[] = "iscsid";
|
||||
-static pid_t log_pid;
|
||||
static gid_t gid;
|
||||
static int daemonize = 1;
|
||||
static int mgmt_ipc_fd;
|
||||
@@ -302,6 +301,7 @@ static void iscsid_shutdown(void)
|
||||
log_debug(1, "daemon stopping");
|
||||
log_close(log_pid);
|
||||
}
|
||||
+ log_close_watchdog_timer();
|
||||
}
|
||||
|
||||
static void catch_signal(int signo)
|
||||
diff --git a/usr/log.c b/usr/log.c
|
||||
index b730642..35d5564 100644
|
||||
--- a/usr/log.c
|
||||
+++ b/usr/log.c
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <sys/types.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
+#include <sys/timerfd.h>
|
||||
|
||||
#include "iscsi_util.h"
|
||||
#include "log.h"
|
||||
@@ -33,6 +34,13 @@
|
||||
|
||||
char *log_name;
|
||||
int log_level = 0;
|
||||
+pid_t log_pid = -1;
|
||||
+
|
||||
+static int default_watchdog_timeout = 4;
|
||||
+static char program_name[] = "iscsid";
|
||||
+static int watchdog_timerfd = -1;
|
||||
+static int last_watchdog_count = 0;
|
||||
+static int watchdog_noupdate_count = 0;
|
||||
|
||||
static int log_stop_daemon = 0;
|
||||
static void (*log_func)(int prio, void *priv, const char *fmt, va_list ap);
|
||||
@@ -141,6 +149,7 @@ static int logarea_init (int size)
|
||||
la->shmid_buff = shmid;
|
||||
la->ops[0].sem_num = 0;
|
||||
la->ops[0].sem_flg = 0;
|
||||
+ la->watchdog_count = 0;
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -414,6 +423,105 @@ static void __log_close(void)
|
||||
}
|
||||
}
|
||||
|
||||
+static int log_restart_daemon(void)
|
||||
+{
|
||||
+ log_close(log_pid);
|
||||
+ log_pid = log_init(program_name, DEFAULT_AREA_SIZE, log_do_log_daemon, NULL);
|
||||
+ if (log_pid < 0)
|
||||
+ return -1;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int log_watchdog_setup(void)
|
||||
+{
|
||||
+ int r;
|
||||
+ struct itimerspec new_value;
|
||||
+ uint32_t period_inus = 1 * 1000000; /*1 second*/
|
||||
+ uint32_t seconds;
|
||||
+ uint32_t nanoseconds;
|
||||
+ if (log_stop_daemon || watchdog_timerfd >= 0)
|
||||
+ return 0;
|
||||
+
|
||||
+ watchdog_timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK | TFD_CLOEXEC);
|
||||
+ if (watchdog_timerfd < 0) {
|
||||
+ syslog(LOG_ERR, "Create watchdog timer failed. errno: %d", errno);
|
||||
+ return -1;
|
||||
+ }
|
||||
+ seconds = period_inus / 1000000;
|
||||
+ nanoseconds = (period_inus - (seconds * 1000000)) * 1000;
|
||||
+ new_value.it_interval.tv_sec = seconds;
|
||||
+ new_value.it_interval.tv_nsec = nanoseconds;
|
||||
+ new_value.it_value.tv_sec = seconds;
|
||||
+ new_value.it_value.tv_nsec = nanoseconds;
|
||||
+
|
||||
+ r = timerfd_settime(watchdog_timerfd, 0, &new_value, NULL);
|
||||
+ if (r < 0) {
|
||||
+ syslog(LOG_ERR, "Set watchdog timer failed. errno: %d", errno);
|
||||
+ log_close_watchdog_timer();
|
||||
+ return -1;
|
||||
+ }
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+static int log_read_comm_frpm_pid(pid_t pid, char *buffer, int len)
|
||||
+{
|
||||
+ char comm_file[256];
|
||||
+ char comm_content[1024];
|
||||
+ int r;
|
||||
+ FILE *fd = NULL;
|
||||
+ buffer[0] = '\0';
|
||||
+ snprintf(comm_file, sizeof(comm_file), "/proc/%i/comm", pid);
|
||||
+ fd = fopen(comm_file, "r");
|
||||
+ if (!fd)
|
||||
+ return -1;
|
||||
+ if (!fgets(buffer, len, fd)) {
|
||||
+ log_warning("Can not read file. File:%s.", comm_file);
|
||||
+ fclose(fd);
|
||||
+ fd = NULL;
|
||||
+ return -1;
|
||||
+ }
|
||||
+ fclose(fd);
|
||||
+ fd = NULL;
|
||||
+ return 0;
|
||||
+}
|
||||
+
|
||||
+int log_get_timerfd(void)
|
||||
+{
|
||||
+ return watchdog_timerfd;
|
||||
+}
|
||||
+
|
||||
+void log_close_watchdog_timer(void)
|
||||
+{
|
||||
+ if(watchdog_timerfd >= 0) {
|
||||
+ close(watchdog_timerfd);
|
||||
+ watchdog_timerfd = -1;
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
+void log_watchdog_handle(void)
|
||||
+{
|
||||
+ uint64_t expir = 0;
|
||||
+ int len;
|
||||
+ int new_watchdog_count;
|
||||
+ len = read(watchdog_timerfd, &expir, sizeof(uint64_t));
|
||||
+ if(len > 0 && expir > 0) {
|
||||
+ if (la && !log_stop_daemon) {
|
||||
+ new_watchdog_count = la->watchdog_count;
|
||||
+ if (new_watchdog_count == last_watchdog_count) {
|
||||
+ watchdog_noupdate_count++;
|
||||
+ if (watchdog_noupdate_count >= default_watchdog_timeout) {
|
||||
+ watchdog_noupdate_count = 0;
|
||||
+ syslog(LOG_ERR, "log daemon is not alive, try to restart.");
|
||||
+ log_restart_daemon();
|
||||
+ }
|
||||
+ } else {
|
||||
+ watchdog_noupdate_count = 0;
|
||||
+ last_watchdog_count = new_watchdog_count;
|
||||
+ }
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
+
|
||||
int log_init(char *program_name, int size,
|
||||
void (*func)(int prio, void *priv, const char *fmt, va_list ap),
|
||||
void *priv)
|
||||
@@ -436,6 +540,8 @@ int log_init(char *program_name, int size,
|
||||
return -1;
|
||||
}
|
||||
|
||||
+ log_watchdog_setup();
|
||||
+
|
||||
pid = fork();
|
||||
if (pid < 0) {
|
||||
syslog(LOG_ERR, "starting logger failed");
|
||||
@@ -456,6 +562,8 @@ int log_init(char *program_name, int size,
|
||||
sigaction(SIGTERM, &sa_new, &sa_old );
|
||||
|
||||
while(1) {
|
||||
+ if (la)
|
||||
+ la->watchdog_count++;
|
||||
log_flush();
|
||||
sleep(1);
|
||||
|
||||
@@ -480,7 +588,15 @@ void log_close(pid_t pid)
|
||||
}
|
||||
|
||||
if (pid > 0) {
|
||||
- kill(pid, SIGTERM);
|
||||
- waitpid(pid, &status, 0);
|
||||
+ char comm[1024];
|
||||
+ int r;
|
||||
+ r = log_read_comm_frpm_pid(pid, comm, sizeof(comm));
|
||||
+ if (!r && strstr(comm, "iscsid")) {
|
||||
+ syslog(LOG_WARNING, "Send SIGTERM to iSCSI logger, pid=%i.", pid);
|
||||
+ kill(pid, SIGTERM);
|
||||
+ waitpid(pid, &status, 0);
|
||||
+ } else {
|
||||
+ syslog(LOG_WARNING, "iSCSI logger with pid=%i already exited.", pid);
|
||||
+ }
|
||||
}
|
||||
}
|
||||
diff --git a/usr/log.h b/usr/log.h
|
||||
index 486a08e..d4f8b80 100644
|
||||
--- a/usr/log.h
|
||||
+++ b/usr/log.h
|
||||
@@ -28,6 +28,7 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <sys/types.h>
|
||||
+#include <stdint.h>
|
||||
#include "iscsid.h"
|
||||
|
||||
union semun {
|
||||
@@ -42,6 +43,7 @@ union semun {
|
||||
#define MAX_MSG_SIZE 256
|
||||
|
||||
extern int log_level;
|
||||
+extern pid_t log_pid;
|
||||
|
||||
struct logmsg {
|
||||
short int prio;
|
||||
@@ -62,10 +64,14 @@ struct logarea {
|
||||
struct sembuf ops[1];
|
||||
int semid;
|
||||
union semun semarg;
|
||||
+ uint64_t watchdog_count;
|
||||
};
|
||||
|
||||
struct logarea *la;
|
||||
|
||||
+extern int log_get_timerfd(void);
|
||||
+extern void log_close_watchdog_timer(void);
|
||||
+extern void log_watchdog_handle(void);
|
||||
extern int log_init(char *program_name, int size,
|
||||
void (*func)(int prio, void *priv, const char *fmt, va_list ap),
|
||||
void *priv);
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
36
9007-check-initiator-name-out-of-range.patch
Normal file
36
9007-check-initiator-name-out-of-range.patch
Normal file
@ -0,0 +1,36 @@
|
||||
From 9d9ca10db994082a58eaf98de3e1e0a4eb7c930c Mon Sep 17 00:00:00 2001
|
||||
From: pengyeqing <pengyeqing@huawei.com>
|
||||
Date: Sun, 27 Jan 2019 00:01:32 +0800
|
||||
Subject: [PATCH] iscsi-initiator-utils: check initiator name out of range
|
||||
|
||||
reason:check initiator name out of range
|
||||
|
||||
Signed-off-by: pengyeqing <pengyeqing@huawei.com>
|
||||
---
|
||||
usr/mgmt_ipc.c | 9 ++++++++-
|
||||
1 file changed, 8 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/mgmt_ipc.c b/usr/mgmt_ipc.c
|
||||
index 1ffcda9..ce4defb 100644
|
||||
--- a/usr/mgmt_ipc.c
|
||||
+++ b/usr/mgmt_ipc.c
|
||||
@@ -168,8 +168,15 @@ mgmt_ipc_session_sync(queue_task_t *qtask)
|
||||
static int
|
||||
mgmt_ipc_cfg_initiatorname(queue_task_t *qtask)
|
||||
{
|
||||
- if (dconfig->initiator_name)
|
||||
+ if (dconfig->initiator_name) {
|
||||
+ if (VALUE_MAXLEN <= strlen(dconfig->initiator_name)){
|
||||
+ log_error("iscsid: len[%d] of initiator name out of range, max len %d.", strlen(dconfig->initiator_name), VALUE_MAXLEN-1);
|
||||
+ return ISCSI_ERR_INVAL;
|
||||
+ }
|
||||
+
|
||||
strcpy(qtask->rsp.u.config.var, dconfig->initiator_name);
|
||||
+ }
|
||||
+
|
||||
mgmt_ipc_write_rsp(qtask, ISCSI_SUCCESS);
|
||||
return ISCSI_SUCCESS;
|
||||
}
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
@ -0,0 +1,46 @@
|
||||
From 93d217ce22e7668abfc5e6dbc015b37b20174b09 Mon Sep 17 00:00:00 2001
|
||||
From: huangkaibin <huangkaibin@huawei.com>
|
||||
Date: Fri, 19 Jan 2018 03:00:17 +0800
|
||||
Subject: [PATCH] iscsid: Do not sync session when a session is already created
|
||||
for a remote device
|
||||
|
||||
Do not sync session when a session is already created for a remote device
|
||||
1. In the following scenarios, two or more sessions will be created and open for one remote device
|
||||
a) two or more sync sessions are requested from the sync process for the same remote device.
|
||||
this may occur when iscsid is restarted, one is requested by the previous started sync process but not handled, and another
|
||||
is requested by the newly started sync process.
|
||||
b) one is created in sync session, the other is created in __session_login_task.
|
||||
2. If two or more sessions are created for one remote device, and there are connection problems on the remote device,
|
||||
these sessions will be reopen again, and will cause one to close the connection while the other to set param for the remote device
|
||||
in kernel, and will cause kernel to panic.
|
||||
3. this patch fix this problem by not sync session when a session is already created for a remote device
|
||||
---
|
||||
usr/initiator.c | 7 +++++++
|
||||
1 file changed, 7 insertions(+)
|
||||
|
||||
diff --git a/usr/initiator.c b/usr/initiator.c
|
||||
index 60bd2b7..4a48bf5 100644
|
||||
--- a/usr/initiator.c
|
||||
+++ b/usr/initiator.c
|
||||
@@ -2097,11 +2097,18 @@ iscsi_sync_session(node_rec_t *rec, queue_task_t *qtask, uint32_t sid)
|
||||
iscsi_session_t *session;
|
||||
struct iscsi_transport *t;
|
||||
int err;
|
||||
+ int nr_found;
|
||||
|
||||
t = iscsi_sysfs_get_transport_by_name(rec->iface.transport_name);
|
||||
if (!t)
|
||||
return ISCSI_ERR_TRANS_NOT_FOUND;
|
||||
|
||||
+ nr_found = session_find_by_rec(rec);
|
||||
+ if(nr_found > 0) {
|
||||
+ log_error("session is already created. sid: %d, name: %s.\n", sid, rec->name);
|
||||
+ return ISCSI_ERR_SESS_EXISTS;
|
||||
+ }
|
||||
+
|
||||
session = __session_create(rec, t, &err);
|
||||
if (!session)
|
||||
return ISCSI_ERR_LOGIN;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
60
9009-fix-default-file-corrupt.patch
Normal file
60
9009-fix-default-file-corrupt.patch
Normal file
@ -0,0 +1,60 @@
|
||||
From 9c5a21d14a2dff91b56574842218cc11e7457dfa Mon Sep 17 00:00:00 2001
|
||||
From: openEuler Buildteam <buildteam@openeuler.org>
|
||||
Date: Wed, 8 Jan 2020 04:13:29 -0500
|
||||
Subject: [PATCH] iscsi-initiator-utils: fix default file corrupt
|
||||
|
||||
---
|
||||
usr/idbm.c | 24 +++++++++++++++++++++++-
|
||||
1 file changed, 23 insertions(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/idbm.c b/usr/idbm.c
|
||||
index 830189f..7ed0ce9 100644
|
||||
--- a/usr/idbm.c
|
||||
+++ b/usr/idbm.c
|
||||
@@ -2006,6 +2006,7 @@ static int idbm_rec_write(node_rec_t *rec)
|
||||
struct stat statb;
|
||||
FILE *f;
|
||||
char *portal;
|
||||
+ char *portalDef = NULL;
|
||||
int rc = 0;
|
||||
|
||||
portal = malloc(PATH_MAX);
|
||||
@@ -2092,7 +2093,7 @@ mkdir_portal:
|
||||
}
|
||||
}
|
||||
|
||||
- snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
|
||||
+ snprintf(portal, PATH_MAX, "%s/%s/%s,%d,%d/%s_bak", NODE_CONFIG_DIR,
|
||||
rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
|
||||
rec->iface.name);
|
||||
open_conf:
|
||||
@@ -2105,6 +2106,27 @@ open_conf:
|
||||
|
||||
idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
|
||||
fclose(f);
|
||||
+
|
||||
+ /* add for default_bak -> default */
|
||||
+ portalDef = malloc(PATH_MAX);
|
||||
+ if (!portalDef) {
|
||||
+ log_error("Could not alloc default\n");
|
||||
+ rc = ISCSI_ERR_IDBM;
|
||||
+ goto free_portal;
|
||||
+ }
|
||||
+
|
||||
+ snprintf(portalDef, PATH_MAX, "%s/%s/%s,%d,%d/%s", NODE_CONFIG_DIR,
|
||||
+ rec->name, rec->conn[0].address, rec->conn[0].port, rec->tpgt,
|
||||
+ rec->iface.name);
|
||||
+ /* Renaming default_bak->default. */
|
||||
+ if (rename(portal, portalDef) < 0) {
|
||||
+ log_error("Cannot rename %s -> %s\n", portal, portalDef);
|
||||
+ rc = ISCSI_ERR_IDBM;
|
||||
+ goto free_portalDef;
|
||||
+ }
|
||||
+
|
||||
+free_portalDef:
|
||||
+ free(portalDef);
|
||||
unlock:
|
||||
idbm_unlock();
|
||||
free_portal:
|
||||
--
|
||||
1.8.3.1
|
||||
30
9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch
Normal file
30
9010-iscsiadm-fix-infinite-loop-while-recv-returns-0.patch
Normal file
@ -0,0 +1,30 @@
|
||||
From d91000561f82b5fd73fa22d23232ed99d647b962 Mon Sep 17 00:00:00 2001
|
||||
From: Wanlong Gao <gaowanlong@huawei.com>
|
||||
Date: Thu, 22 Mar 2018 13:16:47 +0000
|
||||
Subject: [PATCH] iscsiadm: fix infinite loop while recv() returns 0
|
||||
|
||||
[Changelog]: fix infinite loop while recv() returns 0
|
||||
[Author]: Jiao Jianbing
|
||||
|
||||
Signed-off-by: Jiao Jianbing <jiaojianbing@huawei.com>
|
||||
Signed-off-by: Wanlong Gao <gaowanlong@huawei.com>
|
||||
---
|
||||
usr/iscsid_req.c | 2 +-
|
||||
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||
|
||||
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
|
||||
index f0b474f..808d5fe 100644
|
||||
--- a/usr/iscsid_req.c
|
||||
+++ b/usr/iscsid_req.c
|
||||
@@ -173,7 +173,7 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp,
|
||||
return ISCSI_ERR_ISCSID_COMM_ERR;
|
||||
} else if (pfd.revents & POLLIN) {
|
||||
err = recv(fd, rsp, sizeof(*rsp), MSG_WAITALL);
|
||||
- if (err < 0) {
|
||||
+ if (err <= 0) {
|
||||
log_error("read error (%d/%d), daemon died?",
|
||||
err, errno);
|
||||
break;
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
48
9011-fix-iscsiadm-logout-timeout.patch
Normal file
48
9011-fix-iscsiadm-logout-timeout.patch
Normal file
@ -0,0 +1,48 @@
|
||||
From 521637e6e1274fbecd8c588681b24f628e2eec97 Mon Sep 17 00:00:00 2001
|
||||
From: pengyeqing <pengyeqing@huawei.com>
|
||||
Date: Sun, 27 Jan 2019 00:16:18 +0800
|
||||
Subject: [PATCH] iscsi-initiator-utils: fix iscsiadm logout timeout
|
||||
|
||||
reason:fix iscsiadm logout timeout
|
||||
|
||||
Signed-off-by: pengyeqing <pengyeqing@huawei.com>
|
||||
---
|
||||
usr/iscsid_req.c | 7 +++++--
|
||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/usr/iscsid_req.c b/usr/iscsid_req.c
|
||||
index 78000f4..18bb9db 100644
|
||||
--- a/usr/iscsid_req.c
|
||||
+++ b/usr/iscsid_req.c
|
||||
@@ -64,6 +64,7 @@ static void iscsid_startup(void)
|
||||
}
|
||||
|
||||
#define MAXSLEEP 128
|
||||
+#define ISCSID_IPC_WAIT_RESPOND 300
|
||||
|
||||
static int ipc_connect(int *fd, char *unix_sock_name, int start_iscsid)
|
||||
{
|
||||
@@ -147,7 +148,7 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp,
|
||||
|
||||
if (timeout == -1) {
|
||||
timeout = ISCSID_REQ_TIMEOUT;
|
||||
- poll_wait = 1;
|
||||
+ poll_wait = ISCSID_IPC_WAIT_RESPOND;
|
||||
}
|
||||
while (len) {
|
||||
struct pollfd pfd;
|
||||
@@ -159,8 +160,10 @@ int iscsid_response(int fd, iscsiadm_cmd_e cmd, iscsiadm_rsp_t *rsp,
|
||||
pfd.events = POLLIN;
|
||||
err = poll(&pfd, 1, timeout);
|
||||
if (!err) {
|
||||
- if (poll_wait)
|
||||
+ if (poll_wait--)
|
||||
continue;
|
||||
+ log_warning("wait %d seconds timeout, try again?",
|
||||
+ ISCSID_IPC_WAIT_RESPOND);
|
||||
return ISCSI_ERR_ISCSID_NOTCONN;
|
||||
} else if (err < 0) {
|
||||
if (errno == EINTR)
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
49
9012-default-file-zero-after-power-outage.patch
Normal file
49
9012-default-file-zero-after-power-outage.patch
Normal file
@ -0,0 +1,49 @@
|
||||
From afc39d6f627f1e870883e8a6851f7a20f9700801 Mon Sep 17 00:00:00 2001
|
||||
From: sangxu <sangxu@huawei.com>
|
||||
Date: Wed, 30 May 2018 15:54:53 +0800
|
||||
Subject: [PATCH]fix default file zero after power outage, fsync file immediately and use correct parameters info when removing old file.
|
||||
|
||||
---
|
||||
usr/idbm.c | 23 ++++++++++++++++++++---
|
||||
1 file changed, 20 insertions(+), 3 deletions(-)
|
||||
|
||||
diff --git a/usr/idbm.c b/usr/idbm.c
|
||||
index 5437f45..c01c4fe 100644
|
||||
--- a/usr/idbm.c
|
||||
+++ b/usr/idbm.c
|
||||
@@ -2074,6 +2074,23 @@ mkdir_portal:
|
||||
}
|
||||
|
||||
idbm_print(IDBM_PRINT_TYPE_NODE, rec, 1, f);
|
||||
+
|
||||
+ rc = fflush(f);
|
||||
+ if (rc){
|
||||
+ log_error("Could not fflush %s: %s\n", portal, strerror(errno));
|
||||
+ rc = ISCSI_ERR_IDBM;
|
||||
+ fclose(f);
|
||||
+ goto free_portal;
|
||||
+
|
||||
+ }
|
||||
+
|
||||
+ if (fsync(fileno(f)) < 0){
|
||||
+ log_error("Could not fsync %s: %s\n", portal, strerror(errno));
|
||||
+ rc = ISCSI_ERR_IDBM;
|
||||
+ fclose(f);
|
||||
+ goto free_portal;
|
||||
+ }
|
||||
+
|
||||
fclose(f);
|
||||
|
||||
/* add for default_bak -> default */
|
||||
@@ -2392,7 +2409,7 @@ int idbm_add_node(node_rec_t *newrec, discovery_rec_t *drec, int overwrite)
|
||||
if (!overwrite)
|
||||
return 0;
|
||||
|
||||
- rc = idbm_delete_node(&rec);
|
||||
+ rc = idbm_delete_node(newrec);
|
||||
if (rc)
|
||||
return rc;
|
||||
log_debug(7, "overwriting existing record");
|
||||
--
|
||||
1.8.3.1
|
||||
|
||||
27
9013-modify-utils-iscsi-iname.patch
Normal file
27
9013-modify-utils-iscsi-iname.patch
Normal file
@ -0,0 +1,27 @@
|
||||
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
|
||||
|
||||
62
9014-iscsi-iname-p-name-occur-buffer-overflow.patch
Normal file
62
9014-iscsi-iname-p-name-occur-buffer-overflow.patch
Normal file
@ -0,0 +1,62 @@
|
||||
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);
|
||||
BIN
open-iscsi-f3c8e90.tar.gz
Normal file
BIN
open-iscsi-f3c8e90.tar.gz
Normal file
Binary file not shown.
220
open-iscsi.spec
Normal file
220
open-iscsi.spec
Normal file
@ -0,0 +1,220 @@
|
||||
%global _hardened_build 1
|
||||
%global service_enable() /bin/systemctl enable %1.service >/dev/null 2>&1 || :
|
||||
%global socket_enable() /bin/systemctl enable %1.socket >/dev/null 2>&1 || :
|
||||
|
||||
Name: open-iscsi
|
||||
Version: 2.0.876
|
||||
Release: 13
|
||||
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-update-service-files.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
|
||||
|
||||
BuildRequires: flex bison doxygen kmod-devel systemd-units gcc git isns-utils-devel
|
||||
BuildRequires: autoconf automake libtool libmount-devel openssl-devel pkg-config
|
||||
|
||||
Provides: iscsi-initiator-utils
|
||||
Obsoletes: iscsi-initiator-utils
|
||||
Provides: iscsi-initiator-utils-iscsiuio
|
||||
Obsoletes: iscsi-initiator-utils-iscsiuio
|
||||
Provides: libbopeniscsiusr
|
||||
Obsoletes: libbopeniscsiusr
|
||||
Obsoletes: %{name}-devel < %{version}-%{release}
|
||||
%{?systemd_requires}
|
||||
|
||||
%description
|
||||
The Open-iSCSI project is a high-performance, transport independent,
|
||||
multi-platform implementation of RFC3720 iSCSI.
|
||||
|
||||
Open-iSCSI is partitioned into user and kernel parts.
|
||||
|
||||
The kernel portion of Open-iSCSI is a from-scratch code
|
||||
licensed under GPL. The kernel part implements iSCSI data path
|
||||
(that is, iSCSI Read and iSCSI Write), and consists of three
|
||||
loadable modules: scsi_transport_iscsi.ko, libiscsi.ko and iscsi_tcp.ko.
|
||||
|
||||
User space contains the entire control plane: configuration
|
||||
manager, iSCSI Discovery, Login and Logout processing,
|
||||
connection-level error processing, Nop-In and Nop-Out handling,
|
||||
and (in the future:) Text processing, iSNS, SLP, Radius, etc.
|
||||
|
||||
The user space Open-iSCSI consists of a daemon process called
|
||||
iscsid, and a management utility iscsiadm.
|
||||
|
||||
%package devel
|
||||
Summary: Development files for %{name}
|
||||
Provides: libopeniscsiusr-devel
|
||||
Obsoletes: libopeniscsiusr-devel
|
||||
Requires: %{name} = %{version}-%{release}
|
||||
|
||||
%description devel
|
||||
This package contains libraries and include files for %{name}.
|
||||
|
||||
%package help
|
||||
Summary: Including man files for %{name}.
|
||||
Requires: man
|
||||
|
||||
%description help
|
||||
This contains man files for the using of %{name}.
|
||||
|
||||
%prep
|
||||
%autosetup -n open-iscsi-f3c8e90fc0894c088950a15ee6618b427f9e2457 -p1
|
||||
perl -i -pe 's|^exec_prefix = /$|exec_prefix = %{_exec_prefix}|' Makefile
|
||||
|
||||
%build
|
||||
cd iscsiuio
|
||||
touch AUTHORS NEWS
|
||||
autoreconf --install
|
||||
%{configure}
|
||||
cd ..
|
||||
|
||||
%make_build OPTFLAGS="%{optflags} %{?__global_ldflags} -DUSE_KMOD -lkmod" LIB_DIR=%{_libdir}
|
||||
|
||||
|
||||
%install
|
||||
make DESTDIR=%{?buildroot} LIB_DIR=%{_libdir} \
|
||||
install_programs \
|
||||
install_doc \
|
||||
install_etc \
|
||||
install_iname \
|
||||
install_iface \
|
||||
install_libopeniscsiusr
|
||||
|
||||
install -pm 755 usr/iscsistart $RPM_BUILD_ROOT%{_sbindir}
|
||||
install -d $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
|
||||
install -pm 644 iscsiuio/iscsiuiolog $RPM_BUILD_ROOT%{_sysconfdir}/logrotate.d
|
||||
install -d $RPM_BUILD_ROOT%{_sharedstatedir}/{iscsi,iscsi/nodes,iscsi/send_targets,iscsi/static,iscsi/isns,iscsi/slp,iscsi/ifaces}
|
||||
install -d $RPM_BUILD_ROOT/var/lock/iscsi
|
||||
touch $RPM_BUILD_ROOT/var/lock/iscsi/lock
|
||||
|
||||
install -d $RPM_BUILD_ROOT%{_unitdir}
|
||||
install -d $RPM_BUILD_ROOT%{_libexecdir}
|
||||
install -d $RPM_BUILD_ROOT%{_libdir}
|
||||
install -d $RPM_BUILD_ROOT%{_includedir}
|
||||
install -d $RPM_BUILD_ROOT%{_tmpfilesdir}
|
||||
install -pm 644 etc/systemd/*.service $RPM_BUILD_ROOT%{_unitdir}
|
||||
install -pm 644 etc/systemd/*.socket $RPM_BUILD_ROOT%{_unitdir}
|
||||
|
||||
|
||||
%post
|
||||
/sbin/ldconfig
|
||||
%systemd_post iscsi.service iscsi-shutdown.service iscsid.service iscsiuio.service iscsid.socket iscsiuio.socket
|
||||
|
||||
if [ $1 -eq 1 ]; then
|
||||
if [ ! -f %{_sysconfdir}/iscsi/initiatorname.iscsi ]; then
|
||||
echo "InitiatorName=`%{_sbindir}/iscsi-iname`" > %{_sysconfdir}/iscsi/initiatorname.iscsi
|
||||
fi
|
||||
%service_enable iscsi
|
||||
%socket_enable iscsid
|
||||
fi
|
||||
|
||||
%preun
|
||||
%systemd_preun iscsi.service
|
||||
%systemd_preun iscsi-shutdown.service >/dev/null 2>&1
|
||||
%systemd_preun iscsid.service iscsiuio.service iscsid.socket iscsiuio.socket
|
||||
|
||||
%postun
|
||||
/sbin/ldconfig
|
||||
%systemd_postun iscsi.service iscsi-shutdown.service iscsid.service iscsiuio.service iscsid.socket iscsiuio.socket
|
||||
|
||||
%files
|
||||
%doc README COPYING
|
||||
%dir %{_sharedstatedir}/iscsi
|
||||
%dir %{_sharedstatedir}/iscsi/*
|
||||
%ghost %{_var}/lock/iscsi
|
||||
%{_unitdir}/*
|
||||
%{_sbindir}/*
|
||||
%{_libdir}/libopeniscsiusr.so.*
|
||||
|
||||
%dir %{_sysconfdir}/iscsi
|
||||
%attr(0600,root,root) %config(noreplace) %{_sysconfdir}/iscsi/iscsid.conf
|
||||
%config(noreplace) %{_sysconfdir}/logrotate.d/iscsiuiolog
|
||||
%config %{_sysconfdir}/iscsi/ifaces/iface.example
|
||||
%ghost %{_sysconfdir}/iscsi/initiatorname.iscsi
|
||||
|
||||
%files devel
|
||||
%{_includedir}/*.h
|
||||
%{_libdir}/libopeniscsiusr.so
|
||||
%{_libdir}/pkgconfig/libopeniscsiusr.pc
|
||||
|
||||
%files help
|
||||
%{_mandir}/man8/*
|
||||
|
||||
%changelog
|
||||
* Wed Jan 9 2020 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-13
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:update package
|
||||
|
||||
* Tue Dec 31 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-12
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:use openEuler version to match RPM package version
|
||||
|
||||
* Mon Dec 30 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-11
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:change iscsi iqn default value
|
||||
|
||||
* Sun Dec 29 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-10
|
||||
- Type:enhancement
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:do not display the fail info while uninstalling
|
||||
|
||||
* Mon Dec 23 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-9
|
||||
- Type:bugfix
|
||||
- ID:NA
|
||||
- SUG:restart
|
||||
- DESC:backport patches for fix bug
|
||||
|
||||
* Tue Oct 29 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-8
|
||||
- Add %systemd_postun parameter.
|
||||
|
||||
* Fri Sep 20 2019 openEuler Buildteam <buildteam@openeuler.org> - 2.0.876-7
|
||||
- Package init
|
||||
Loading…
x
Reference in New Issue
Block a user