segfault from unexpected netlink event during discovery

Resolves: #1040343
This commit is contained in:
Chris Leech 2014-11-17 22:10:40 -08:00
parent df66fcb397
commit 0047874487
4 changed files with 70 additions and 2 deletions

View File

@ -0,0 +1,34 @@
From 46bc7ff0091af95735c03995be7d6002b03944dd Mon Sep 17 00:00:00 2001
From: Chris Leech <cleech@redhat.com>
Date: Mon, 17 Nov 2014 21:34:06 -0800
Subject: [PATCH] guard against NULL ptr during discovery from unexpected event
When demand loading drivers during discovery, iscsiadm can receive an
unexpected netlink event, like a link up, when looking for a discovery
session login status. That could expose krecv_conn_state to a
connection without a valid recv_context pointer.
Guard against that to prevent the NULL dereference.
Signed-off-by: Chris Leech <cleech@redhat.com>
---
usr/netlink.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/usr/netlink.c b/usr/netlink.c
index 1c4b5cc..18be5e5 100644
--- a/usr/netlink.c
+++ b/usr/netlink.c
@@ -1035,6 +1035,10 @@ static int krecv_conn_state(struct iscsi_conn *conn, uint32_t *state)
/* fatal handling error or conn error */
goto exit;
+ /* unexpected event without a receive context */
+ if (!conn->recv_context)
+ return -EAGAIN;
+
*state = *(enum iscsi_conn_state *)conn->recv_context->data;
ipc_ev_clbk->put_ev_context(conn->recv_context);
--
1.9.3

View File

@ -0,0 +1,26 @@
diff --git a/iscsiuio/configure b/iscsiuio/configure
index 50cfd90..c930b67 100755
--- a/iscsiuio/configure
+++ b/iscsiuio/configure
@@ -22782,7 +22782,7 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-CFLAGS="${CFLAGS} -O2 -Wall"
+CFLAGS="${CFLAGS} -O2 -Wall -fno-strict-aliasing"
## check for --enable-debug first before checking CFLAGS before
## so that we don't mix -O and -g
# Check whether --enable-debug was given.
diff --git a/iscsiuio/configure.ac b/iscsiuio/configure.ac
index e4af3b2..551a513 100644
--- a/iscsiuio/configure.ac
+++ b/iscsiuio/configure.ac
@@ -52,7 +52,7 @@ AC_LIBTOOL_DLOPEN
# libtool stuff
AC_PROG_LIBTOOL
-CFLAGS="${CFLAGS} -O2 -Wall"
+CFLAGS="${CFLAGS} -O2 -Wall -fno-strict-aliasing"
## check for --enable-debug first before checking CFLAGS before
## so that we don't mix -O and -g
AC_ARG_ENABLE(debug,

View File

@ -16,7 +16,7 @@ index a090522..aef0c3d 100644
* some other maintainer could merge a patch without going through us * some other maintainer could merge a patch without going through us
*/ */
-#define ISCSI_VERSION_STR "2.0-873" -#define ISCSI_VERSION_STR "2.0-873"
+#define ISCSI_VERSION_STR "6.2.0.873-22" +#define ISCSI_VERSION_STR "6.2.0.873-24"
#define ISCSI_VERSION_FILE "/sys/module/scsi_transport_iscsi/version" #define ISCSI_VERSION_FILE "/sys/module/scsi_transport_iscsi/version"
#endif #endif

View File

@ -4,7 +4,7 @@
Summary: iSCSI daemon and utility programs Summary: iSCSI daemon and utility programs
Name: iscsi-initiator-utils Name: iscsi-initiator-utils
Version: 6.%{open_iscsi_version}.%{open_iscsi_build} Version: 6.%{open_iscsi_version}.%{open_iscsi_build}
Release: 23%{?dist} Release: 24%{?dist}
Group: System Environment/Daemons Group: System Environment/Daemons
License: GPLv2+ License: GPLv2+
URL: http://www.open-iscsi.org URL: http://www.open-iscsi.org
@ -95,6 +95,7 @@ Patch83: 0083-Parse-origin-value-from-iBFT.patch
Patch84: 0084-isns-Add-docs-for-deregistering-discovery-domains.patch Patch84: 0084-isns-Add-docs-for-deregistering-discovery-domains.patch
# not (yet) upstream merged # not (yet) upstream merged
Patch130: 0130-guard-against-NULL-ptr-during-discovery-from-unexpec.patch
Patch140: 0140-add-discovery-as-a-valid-mode-in-iscsiadm.8.patch Patch140: 0140-add-discovery-as-a-valid-mode-in-iscsiadm.8.patch
Patch143: 0143-idmb_rec_write-check-for-tpgt-first.patch Patch143: 0143-idmb_rec_write-check-for-tpgt-first.patch
Patch145: 0145-idbm_rec_write-seperate-old-and-new-style-writes.patch Patch145: 0145-idbm_rec_write-seperate-old-and-new-style-writes.patch
@ -121,6 +122,7 @@ Patch167: 0167-Revert-iscsiadm-return-error-when-login-fails.patch
Patch168: 0168-update-handling-of-boot-sessions.patch Patch168: 0168-update-handling-of-boot-sessions.patch
Patch169: 0169-update-iscsi.service-for-boot-session-recovery.patch Patch169: 0169-update-iscsi.service-for-boot-session-recovery.patch
Patch170: 0170-fix-systemd-unit-wants.patch Patch170: 0170-fix-systemd-unit-wants.patch
Patch171: 0171-iscsiuio-strict-aliasing.patch
# version string, needs to be updated with each build # version string, needs to be updated with each build
Patch199: 0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch Patch199: 0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch
@ -242,6 +244,7 @@ developing applications that use %{name}.
%patch83 -p1 %patch83 -p1
%patch84 -p1 %patch84 -p1
# pending upstream merge # pending upstream merge
%patch130 -p1
%patch140 -p1 %patch140 -p1
%patch143 -p1 %patch143 -p1
%patch145 -p1 %patch145 -p1
@ -268,6 +271,7 @@ developing applications that use %{name}.
%patch168 -p1 %patch168 -p1
%patch169 -p1 %patch169 -p1
%patch170 -p1 %patch170 -p1
%patch171 -p1
# version string # version string
%patch199 -p1 %patch199 -p1
@ -448,6 +452,10 @@ fi
%{_includedir}/libiscsi.h %{_includedir}/libiscsi.h
%changelog %changelog
* Tue Nov 18 2014 Chris Leech <cleech@redhat.com> - 6.2.0.873-24
- 1040343 segfault from unexpected netlink event during discovery
- inhibit strict aliasing optimizations in iscsiuio, rpmdiff error
* Tue Oct 21 2014 Chris Leech <cleech@redhat.com> - 6.2.0.873-23 * Tue Oct 21 2014 Chris Leech <cleech@redhat.com> - 6.2.0.873-23
- make sure to pass --with-security=no to isns configure (#1088020) - make sure to pass --with-security=no to isns configure (#1088020)