NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
kern/39394: ld(4) can crash in some situations
>Number: 39394
>Category: kern
>Synopsis: ld(4) can crash in some situations
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: kern-bug-people
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Sat Aug 23 11:30:00 +0000 2008
>Originator: Juan RP
>Release: Latest and greatest
>Organization:
Not NetBSD
>Environment:
NetBSD sasha 4.99.72 NetBSD 4.99.72 (MASTER) #0: Thu Aug 21 15:52:46 CEST 2008
juan@sasha:/home/juan/build/amd64/obj/sys/arch/amd64/compile/MASTER amd64
>Description:
While working on new ataraid(4) metadata formats, I've encountered something
interesting between the ld(4) frontends.
Let's take a look at the ataraid code in ld_ataraid.c:
struct ld_ataraid_softc {
struct ld_softc sc_ld;
struct ataraid_array_info *sc_aai;
struct vnode *sc_vnodes[ATA_RAID_MAX_DISKS];
void (*sc_iodone)(struct buf *);
};
Here a ''struct ld_softc'' is provided with ataraid's softc... fine. Let's
continue.
ld_ataraid_attach(device_t parent, device_t self, void *aux)
{
struct ld_ataraid_softc *sc = device_private(self);
struct ld_softc *ld = &sc->sc_ld;
...
Ok, we use a pointer for ld_softc that is using the struct that was specified
in ataraid's softc. But a few lines later:
if (ld->sc_start == NULL) {
aprint_error_dev(&ld->sc_dv, "unsupported array type\n");
return;
}
So where is the this struct device (ld->sc_dv) filled in? nowhere.
Well, this part isn't noticed because the path isn't triggered in normal
conditions. The part I noticed is the following:
ld_ataraid_attach() finishes calling ldattach() with the ld_softc specified in
ataraid's softc, let's look what happens now at ldattach():
/* Initialise and attach the disk structure. */
disk_init(&sc->sc_dk, device_xname(&sc->sc_dv), &lddkdriver);
disk_attach(&sc->sc_dk);
as sc->sc_dv hasn't been specified, the name will be NULL... later at
ld_config_interrupts(), dkwedge_discover() is called looking at the dk_name
member of the disk struct, and that ends with a NULL pointer deref causing a
panic.
I hope my analysis has been clear enough.
>How-To-Repeat:
>Fix:
To confirm my analysis the patch I created fixes this issue, but only covers
the ataraid(4) frontend (the one I'm interested on).
To fix completely the issue all ld(4) frontends should be fixed as well.
Anyway here's my patch:
begin 644 ld_device_fix.diff
M26YD97@Z(&QD+F,*/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]
M/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/3T]/0I20U,@9FEL93H@
M+V-V<W)O;W0O<W)C+W-Y<R]D978O;&0N8RQV"G)E=')I979I;F<@<F5V:7-I
M;VX@,2XV,@ID:69F("UB("UU("UR,2XV,B!L9"YC"BTM+2!L9"YC"3$Q($%U
M9R`R,#`X(#`V.C0S.C,W("TP,#`P"3$N-C(**RLK(&QD+F,),C,@075G(#(P
M,#@@,3`Z-3<Z,3$@+3`P,#`*0$`@+3$P,BPQ,B`K,3`R+#$R($!`"B`);75T
M97A?:6YI="@F<V,M/G-C7VUU=&5X+"!-551%6%]$149!54Q4+"!)4$Q?5DTI
M.PH@"B`):68@*"AS8RT^<V-?9FQA9W,@)B!,1$9?14Y!0DQ%1"D@/3T@,"D@
M>PHM"0EA<')I;G1?;F]R;6%L7V1E=B@F<V,M/G-C7V1V+"`B9&ES86)L961<
M;B(I.PHK"0EA<')I;G1?;F]R;6%L7V1E=BAS8RT^<V-?9'8L(")D:7-A8FQE
M9%QN(BD["B`)"7)E='5R;CL*(`E]"B`*(`DO*B!);FET:6%L:7-E(&%N9"!A
M='1A8V@@=&AE(&1I<VL@<W1R=6-T=7)E+B`J+PHM"61I<VM?:6YI="@F<V,M
M/G-C7V1K+"!D979I8V5?>&YA;64H)G-C+3YS8U]D=BDL("9L9&1K9')I=F5R
M*3L**PED:7-K7VEN:70H)G-C+3YS8U]D:RP@9&5V:6-E7WAN86UE*'-C+3YS
M8U]D=BDL("9L9&1K9')I=F5R*3L*(`ED:7-K7V%T=&%C:"@F<V,M/G-C7V1K
M*3L*(`H@"6EF("AS8RT^<V-?;6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