[smartmontools-support] memory corruption problem on NetBSD

Christian Franke Christian.Franke at t-online.de
Wed Jun 12 06:48:42 CEST 2019


Alexander Nasonov wrote:
> Christian Franke wrote:
>> Alexander Nasonov wrote:
>>> netbsd_smart_interface::get_dev_names()  doesn't return a failure
>>> early when no devices match a prefix (n == 0) and leads to a memory
>>> corruption later. The patch below fixes this problem.
>>>
>> Thanks for the patch. Did you actually see any memory corruption (or crash)
>> ?
> It started happening after a new version of jemalloc was imported
> into the tree:
>
> # /usr/pkg/sbin/smartd
> <jemalloc>:
> /home/alnsn/netbsd-current/sljit/src/external/bsd/jemalloc/lib/../dist/src/arena.c:271:
> Failed assertion: "bitmap_get(slab_data->bitmap, &bin_info->bitmap_info,
> regind)"
> Abort
>

Thanks for the info. If possible, please try the attached patch.

Thanks,
Christian

-------------- next part --------------
Index: os_netbsd.cpp
===================================================================
--- os_netbsd.cpp	(revision 4918)
+++ os_netbsd.cpp	(working copy)
@@ -602,7 +602,13 @@
     sprintf(mp[n], "%s%s%c", net_dev_raw_prefix, p, 'a' + getrawpartition());
     n++;
   }
+  free(disknames);
 
+  if (n == 0) {
+    free(mp);
+    return 0;
+  }
+
   char ** tmp = (char **)realloc(mp, n * (sizeof(char *)));
   if (NULL == tmp) {
     pout("Out of memory constructing scan device list\n");


More information about the Smartmontools-support mailing list