diff --git a/tgt-handle-access-of-a-target-that-has-been-removed b/tgt-handle-access-of-a-target-that-has-been-removed new file mode 100644 index 0000000..032c9f5 --- /dev/null +++ b/tgt-handle-access-of-a-target-that-has-been-removed @@ -0,0 +1,55 @@ +From: Lee Duncan +Date: Wed, 28 Oct 2015 14:16:13 +0900 +Subject: Handle access of a target that has been removed +Git-commit: 2791ed243ab2a2fcfe48aea4a0cc23f4ad8467dc +Patch-mainline: v1.0.61 + +I recently got a report of a tgtd core dump from our opencloud +group. The stack trace showed that a strcmp against a NULL was causing +the failure: + +---------------------------------------------------------------- +Program terminated with signal 11, Segmentation fault. +(gdb) bt + name=0x6ac16f "iqn.2010-10.org.openstack:volume-e812c705-80bc-4064-a84c-5559cda8b1ca") at iscsi/target.c:216 + at iscsi/iscsid.c:654 + events=1, data=0x63a480 ) at iscsi/iscsi_tcp.c:158 +---------------------------------------------------------------- + +It looks like target_find_by_name() uses tgt_targetname(), but doesn't +account for the fact that it can return a NULL when the target being +looked up does not (now) exist: + +---------------------------------------------------------------- +char *tgt_targetname(int tid) +{ + struct target *target; + + target = target_lookup(tid); + if (!target) + return NULL; + + return target->name; +} + +Signed-off-by: FUJITA Tomonori +Acked-by: Lee Duncan +--- + usr/iscsi/target.c | 4 +++- + 1 file changed, 3 insertions(+), 1 deletion(-) + +--- a/usr/iscsi/target.c ++++ b/usr/iscsi/target.c +@@ -369,9 +369,11 @@ void target_list_build(struct iscsi_conn + struct iscsi_target *target_find_by_name(const char *name) + { + struct iscsi_target *target; ++ char *tname; + + list_for_each_entry(target, &iscsi_targets_list, tlist) { +- if (!strcmp(tgt_targetname(target->tid), name)) ++ tname = tgt_targetname(target->tid); ++ if (tname && !strcmp(tname, name)) + return target; + } + diff --git a/tgt-missing-module-directory-not-an-error b/tgt-missing-module-directory-not-an-error new file mode 100644 index 0000000..32630aa --- /dev/null +++ b/tgt-missing-module-directory-not-an-error @@ -0,0 +1,26 @@ +From: Lee Duncan +Date: Mon Nov 16 08:49:57 PST 2015 +Subject: backing-store modules directory not present is not an error + +The backing-store modules directory, normally +/usr/lib/tgt/backing-store, is not created, needed, or used when there +are no backing store modules. So change the error message printed when +the directory is not present to a debug message. + +Signed-off-by: Lee Duncan +--- + usr/bs.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +--- a/usr/bs.c ++++ b/usr/bs.c +@@ -263,7 +263,8 @@ static int bs_init_signalfd(void) + + dir = opendir(BSDIR); + if (dir == NULL) { +- eprintf("could not open backing-store module directory %s\n", ++ /* not considered an error if there are no modules */ ++ dprintf("could not open backing-store module directory %s\n", + BSDIR); + } else { + struct dirent *dirent; diff --git a/tgt.changes b/tgt.changes index e0b9d80..edb8072 100644 --- a/tgt.changes +++ b/tgt.changes @@ -1,3 +1,18 @@ +------------------------------------------------------------------- +Mon Nov 16 16:43:18 UTC 2015 - lduncan@suse.com + +- Adding upstream patch to silence bogus error + message when backing-store directory not present + (bsc#954801), adding patch: + * tgt-missing-module-directory-not-an-error + +------------------------------------------------------------------- +Mon Nov 16 00:54:26 UTC 2015 - lduncan@suse.com + +- Added upstream patch to handle possible target removal + while accessing it (bsc#922526), adding patch: + * tgt-handle-access-of-a-target-that-has-been-removed + ------------------------------------------------------------------- Fri Sep 18 09:52:28 UTC 2015 - p.drouand@gmail.com diff --git a/tgt.spec b/tgt.spec index 2bdae68..e715b82 100644 --- a/tgt.spec +++ b/tgt.spec @@ -29,6 +29,8 @@ Source3: %{name}.services Source4: sysconfig.%{name} Patch2: %{name}-fix-build Patch3: setup-tgt-conf-d.patch +Patch4: %{name}-handle-access-of-a-target-that-has-been-removed +Patch5: %{name}-missing-module-directory-not-an-error BuildRequires: docbook-xsl-stylesheets BuildRequires: libaio-devel BuildRequires: libxslt @@ -51,6 +53,8 @@ user-space daemon and tools (i.e. they completely runs in user space). %setup -q %patch2 -p1 %patch3 -p1 +%patch4 -p1 +%patch5 -p1 %build %ifarch ppc ppc64 ppc64le @@ -93,4 +97,4 @@ ln -sf service %{buildroot}/%{_sbindir}/rc%{name}d %doc doc/README.mmc doc/README.passthrough doc/README.sbcjukebox doc/README.ssc %{_mandir}/man8/* -%changelog \ No newline at end of file +%changelog