DragonFlyBSD Kernel Audit
DF-1072 / verify.log
← back to finding ↓ download raw
=== (1) the clamp only enforces upper bound (no lower bound check) ===
			if (PNP_LRES_NUM(tag) == PNP_TAG_ID_ANSI) {
				if (large_len > sizeof(buf) - 1)
					large_len = sizeof(buf) - 1;
				bcopy(resinfo, buf, large_len);

				/*
				 * Trim trailing spaces.
				 */
				while (buf[large_len-1] == ' ')
					large_len--;
				buf[large_len] = '\0';
				desc = buf;
				if (dev)
					device_set_desc_copy(dev, desc);
				continue;

=== (2) with large_len == 0, buf[large_len-1] evaluates buf[-1] ===
  C: 'A'[large_len-1] with large_len=0 -> 'A'[-1] -> undefined / stack OOB read
  the loop continues decrementing past buf[0] while bytes below buf are 0x20.
  then buf[large_len] = '' writes NUL at the resulting negative index.

=== (3) PNP_TAG_ID_ANSI value and large-tag bit ===
217:#define PNP_RES_TYPE(a)		(a >> 7)
220:#define PNP_LRES_NUM(a)		(a & 0x7f)
238:#define PNP_TAG_ID_ANSI		0x2
sys/bus/isa/pnpreg.h:217:#define PNP_RES_TYPE(a)		(a >> 7)
sys/bus/isa/pnpreg.h:220:#define PNP_LRES_NUM(a)		(a & 0x7f)
sys/bus/isa/pnpreg.h:238:#define PNP_TAG_ID_ANSI		0x2

=== (4) pnp.c is built into the default kernel (device isa is configured) ===
58:device		isa
100:device		adv0	at isa?
151:device		atkbdc0	at isa? port IO_KBD
155:device		vga0	at isa?
179:device		lm0	at isa? port 0x290
180:device		it0	at isa?	port 0x290
181:device		it1	at isa?	port 0xc00
182:device		it2	at isa?	port 0xd00
183:device		it3	at isa?	port 0x228
184:device		wbsio0	at isa? port 0x2e
185:device		wbsio1	at isa? port 0x4e
203:device		sio0	at isa? port IO_COM1 flags 0x10 irq 4
204:device		sio1	at isa? port IO_COM2 irq 3
205:device		sio2	at isa? disable port IO_COM3 irq 5
206:device		sio3	at isa? disable port IO_COM4 irq 9
278:device		lnc0	at isa? disable port 0x280 irq 10 drq 0
279:device		sn0	at isa? disable port 0x300 irq 10

=== (5) no PnP cards present in audit guest, so loop never executes ===

DONE: all five static checks executed.