diff -Nru mdadm-3.3/debian/changelog mdadm-3.3/debian/changelog --- mdadm-3.3/debian/changelog 2017-10-10 13:22:38.000000000 +0000 +++ mdadm-3.3/debian/changelog 2017-10-09 14:06:22.000000000 +0000 @@ -1,3 +1,11 @@ +mdadm (3.3-2ubuntu7.6) xenial; urgency=medium + + * Prevent segfault when get_md_name() returns NULL + This fixes mdadm segfaults when running inside a container. + (LP: #1617919) + + -- Dan Streetman Mon, 09 Oct 2017 10:06:22 -0400 + mdadm (3.3-2ubuntu7.5) xenial; urgency=medium * Add systemd shutdown script which waits for arrays to be clean during diff -Nru mdadm-3.3/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch mdadm-3.3/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch --- mdadm-3.3/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.3/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch 2017-10-09 14:06:22.000000000 +0000 @@ -0,0 +1,41 @@ +From: Sergey Vidishev +Subject: mdadm: monitor: fix nullptr dereference when get_md_name() returns NULL +Origin: https://github.com/neilbrown/mdadm/commit/1e08717f0b7856b389e9d5eb2dc330d146636183 +Bug-Ubuntu: https://bugs.launchpad.net/bugs/1617919 + +Function add_new_arrays() expects that function get_md_name() should +return pointer to devname, but also get_md_name() may return NULL. So +check the pointer before use it in add_new_arrays(). + +Signed-off-by: Sergey Vidishev +Signed-off-by: NeilBrown +--- + Monitor.c | 10 +++++++++- + 1 file changed, 9 insertions(+), 1 deletion(-) + +--- a/Monitor.c ++++ b/Monitor.c +@@ -657,6 +657,7 @@ + { + struct mdstat_ent *mse; + int new_found = 0; ++ char *name; + + for (mse=mdstat; mse; mse=mse->next) + if (mse->devnm[0] && +@@ -667,7 +668,14 @@ + struct state *st = xcalloc(1, sizeof *st); + mdu_array_info_t array; + int fd; +- st->devname = xstrdup(get_md_name(mse->devnm)); ++ ++ name = get_md_name(mse->devnm); ++ if (!name) { ++ free(st); ++ continue; ++ } ++ ++ st->devname = xstrdup(name); + if ((fd = open(st->devname, O_RDONLY)) < 0 || + ioctl(fd, GET_ARRAY_INFO, &array)< 0) { + /* no such array */ diff -Nru mdadm-3.3/debian/patches/series mdadm-3.3/debian/patches/series --- mdadm-3.3/debian/patches/series 2014-07-16 15:54:32.000000000 +0000 +++ mdadm-3.3/debian/patches/series 2017-10-09 14:06:22.000000000 +0000 @@ -5,3 +5,4 @@ remove-bashism-from-makefile.patch #disable use-external-blkid.diff in ubuntu dmraid-fallback.patch +mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch