Date: Mon, 26 Apr 2010 23:07:31 +0300 From: Mikolaj Golub <to.my.trociny@gmail.com> To: freebsd-fs <freebsd-fs@freebsd.org> Subject: hastd segfaults reading metadata from not initialized provider Message-ID: <86iq7ex9j0.fsf@kopusha.onet>
next in thread | raw e-mail | index | archive | help
--=-=-=
Hi,
When configuring a new provider if one forgets to do
hastctl create tank
before
hastctl role primary tank
the worker core dumps on reading metadata:
(gdb) bt
#0 strcmp () at /usr/src/lib/libc/i386/string/strcmp.S:61
#1 0x0804fa18 in metadata_read (res=0x284cb600, openrw=true) at /usr/src/sbin/hastd/metadata.c:120
#2 0x080570ac in init_local (res=0x284cb600) at /usr/src/sbin/hastd/primary.c:425
#3 0x08057f88 in hastd_primary (res=0x284cb600) at /usr/src/sbin/hastd/primary.c:754
#4 0x0804e270 in child_exit () at /usr/src/sbin/hastd/hastd.c:145
#5 0x0804edd1 in main_loop () at /usr/src/sbin/hastd/hastd.c:389
#6 0x0804f3d8 in main (argc=0, argv=0xbfbfed84) at /usr/src/sbin/hastd/hastd.c:520
Current language: auto; currently asm
(gdb) fr 1
#1 0x0804fa18 in metadata_read (res=0x284cb600, openrw=true) at /usr/src/sbin/hastd/metadata.c:120
120 if (strcmp(str, res->hr_name) != 0) {
Current language: auto; currently c
(gdb) list
115 ebuf_free(eb);
116 goto fail;
117 }
118
119 str = nv_get_string(nv, "resource");
120 if (strcmp(str, res->hr_name) != 0) {
121 pjdlog_error("Provider %s is not part of resource %s.",
122 res->hr_localpath, res->hr_name);
123 nv_free(nv);
124 goto fail;
(gdb) p str
$1 = 0x0
In the attached patch the check for str is added so we would have a
termination with the error message instead of a core dump:
Apr 26 22:46:06 hasta hastd: [tank] (primary) Metadata read from /dev/ad6 is invalid.
Apr 26 22:46:06 hasta hastd: [tank] (primary) Worker process failed (pid=6196, status=66).
--
Mikolaj Golub
--=-=-=
Content-Type: text/x-diff
Content-Disposition: inline; filename=hastd.metadata.c.patch
Index: sbin/hastd/metadata.c
===================================================================
--- sbin/hastd/metadata.c (revision 207245)
+++ sbin/hastd/metadata.c (working copy)
@@ -117,6 +117,12 @@ metadata_read(struct hast_resource *res, bool open
}
str = nv_get_string(nv, "resource");
+ if (str == NULL) {
+ pjdlog_error("Metadata read from %s is invalid.",
+ res->hr_localpath);
+ nv_free(nv);
+ goto fail;
+ }
if (strcmp(str, res->hr_name) != 0) {
pjdlog_error("Provider %s is not part of resource %s.",
res->hr_localpath, res->hr_name);
--=-=-=--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?86iq7ex9j0.fsf>
