diff -Nru mdadm-3.2.5/debian/changelog mdadm-3.2.5/debian/changelog --- mdadm-3.2.5/debian/changelog 2016-05-18 22:49:31.000000000 +0000 +++ mdadm-3.2.5/debian/changelog 2017-10-09 14:06:22.000000000 +0000 @@ -1,3 +1,11 @@ +mdadm (3.2.5-5ubuntu4.4) trusty; 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.2.5-5ubuntu4.3) trusty; urgency=medium * debian/source_mdadm.py: fix bytes versus strings mismatch that diff -Nru mdadm-3.2.5/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch mdadm-3.2.5/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch --- mdadm-3.2.5/debian/patches/mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch 1970-01-01 00:00:00.000000000 +0000 +++ mdadm-3.2.5/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 +@@ -677,6 +677,7 @@ + { + struct mdstat_ent *mse; + int new_found = 0; ++ char *name; + + for (mse=mdstat; mse; mse=mse->next) + if (mse->devnum != INT_MAX && +@@ -689,7 +690,14 @@ + int fd; + if (st == NULL) + continue; +- st->devname = strdup(get_md_name(mse->devnum)); ++ ++ name = get_md_name(mse->devnum); ++ if (!name) { ++ free(st); ++ continue; ++ } ++ ++ st->devname = strdup(name); + if ((fd = open(st->devname, O_RDONLY)) < 0 || + ioctl(fd, GET_ARRAY_INFO, &array)< 0) { + /* no such array */ diff -Nru mdadm-3.2.5/debian/patches/series mdadm-3.2.5/debian/patches/series --- mdadm-3.2.5/debian/patches/series 2014-02-17 13:44:06.000000000 +0000 +++ mdadm-3.2.5/debian/patches/series 2017-10-09 14:06:22.000000000 +0000 @@ -12,3 +12,4 @@ mdmon-fix-arg-parsing.patch mdmon-fix-arg-processing-for-a.patch dmraid-fallback.patch +mdadm-monitor-fix-nullptr-dereference-when-get_md_na.patch