From 0047874487fd0e71129f2a681ee2c9f3697a5957 Mon Sep 17 00:00:00 2001 From: Chris Leech Date: Mon, 17 Nov 2014 22:10:40 -0800 Subject: [PATCH] segfault from unexpected netlink event during discovery Resolves: #1040343 --- ...LL-ptr-during-discovery-from-unexpec.patch | 34 +++++++++++++++++++ 0171-iscsiuio-strict-aliasing.patch | 26 ++++++++++++++ ...ion-string-to-match-RPM-package-vers.patch | 2 +- iscsi-initiator-utils.spec | 10 +++++- 4 files changed, 70 insertions(+), 2 deletions(-) create mode 100644 0130-guard-against-NULL-ptr-during-discovery-from-unexpec.patch create mode 100644 0171-iscsiuio-strict-aliasing.patch diff --git a/0130-guard-against-NULL-ptr-during-discovery-from-unexpec.patch b/0130-guard-against-NULL-ptr-during-discovery-from-unexpec.patch new file mode 100644 index 0000000..fb9d7ec --- /dev/null +++ b/0130-guard-against-NULL-ptr-during-discovery-from-unexpec.patch @@ -0,0 +1,34 @@ +From 46bc7ff0091af95735c03995be7d6002b03944dd Mon Sep 17 00:00:00 2001 +From: Chris Leech +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 +--- + 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 + diff --git a/0171-iscsiuio-strict-aliasing.patch b/0171-iscsiuio-strict-aliasing.patch new file mode 100644 index 0000000..1a0eb68 --- /dev/null +++ b/0171-iscsiuio-strict-aliasing.patch @@ -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, diff --git a/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch b/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch index cda6f98..747c9da 100644 --- a/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch +++ b/0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch @@ -16,7 +16,7 @@ index a090522..aef0c3d 100644 * some other maintainer could merge a patch without going through us */ -#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" #endif diff --git a/iscsi-initiator-utils.spec b/iscsi-initiator-utils.spec index e1f665d..8308b74 100644 --- a/iscsi-initiator-utils.spec +++ b/iscsi-initiator-utils.spec @@ -4,7 +4,7 @@ Summary: iSCSI daemon and utility programs Name: iscsi-initiator-utils Version: 6.%{open_iscsi_version}.%{open_iscsi_build} -Release: 23%{?dist} +Release: 24%{?dist} Group: System Environment/Daemons License: GPLv2+ 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 # 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 Patch143: 0143-idmb_rec_write-check-for-tpgt-first.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 Patch169: 0169-update-iscsi.service-for-boot-session-recovery.patch Patch170: 0170-fix-systemd-unit-wants.patch +Patch171: 0171-iscsiuio-strict-aliasing.patch # version string, needs to be updated with each build Patch199: 0199-use-Red-Hat-version-string-to-match-RPM-package-vers.patch @@ -242,6 +244,7 @@ developing applications that use %{name}. %patch83 -p1 %patch84 -p1 # pending upstream merge +%patch130 -p1 %patch140 -p1 %patch143 -p1 %patch145 -p1 @@ -268,6 +271,7 @@ developing applications that use %{name}. %patch168 -p1 %patch169 -p1 %patch170 -p1 +%patch171 -p1 # version string %patch199 -p1 @@ -448,6 +452,10 @@ fi %{_includedir}/libiscsi.h %changelog +* Tue Nov 18 2014 Chris Leech - 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 - 6.2.0.873-23 - make sure to pass --with-security=no to isns configure (#1088020)