bin/137656: [geom][patch] gpart drops core when adding partition to non-existent geom

Andrey V. Elsukov bu7cher at yandex.ru
Tue Aug 11 06:20:03 UTC 2009


>Number:         137656
>Category:       bin
>Synopsis:       [geom][patch] gpart drops core when adding partition to non-existent geom
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Aug 11 06:20:02 UTC 2009
>Closed-Date:
>Last-Modified:
>Originator:     Andrey V. Elsukov
>Release:        8.0-BETA2
>Organization:
>Environment:
8.0-BETA2 FreeBSD 8.0-BETA2 #0: Wed Jul 15 21:48:41 UTC 2009     root at mason.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

>Description:
gpart crashes when adding partitions to non-existent geom.
Problem is in gpart_autofill function. It doesn't check returned value after calling find_geom(). And next function doing access to NULL pointer.

>How-To-Repeat:
> gpart show
=>       34  312581741  ad4  GPT  (149G)
         34        256    1  freebsd-boot  (128K)
        290    4194304    2  freebsd-swap  (2.0G)
    4194594  125829120    3  freebsd-zfs  (60G)
  130023714  182558061       - free -  (87G)
> sudo gpart add -t freebsd-zfs ad6
Segmentation fault (core dumped)

>Fix:
After my patch:
> sudo ./gpart add -t freebsd-zfs ad6
gpart: No such geom: ad6.


Patch attached with submission follows:

--- src/sbin/geom/class/part/geom_part.c	2009-07-14 12:54:23.444482747 +0400
+++ src/sbin/geom/class/part/geom_part.c	2009-08-11 09:58:13.246739711 +0400
@@ -275,7 +275,10 @@
 	if (error)
 		return (error);
 	cp = find_class(&mesh, gctl_get_ascii(req, "class"));
-	gp = find_geom(cp, gctl_get_ascii(req, "geom"));
+	s = gctl_get_ascii(req, "geom");
+	gp = find_geom(cp, s);
+	if (gp == NULL)
+		errx(EXIT_FAILURE, "No such geom: %s.", s);
 	first = atoll(find_geomcfg(gp, "first"));
 	last = atoll(find_geomcfg(gp, "last"));
 	grade = ~0ULL;


>Release-Note:
>Audit-Trail:
>Unformatted:


More information about the freebsd-bugs mailing list