Date: Wed, 31 Aug 2022 20:54:03 +0000 From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 266144] bug in sndstat_unpack_user_nvlbuf() Message-ID: <bug-266144-227@https.bugs.freebsd.org/bugzilla/>
next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D266144 Bug ID: 266144 Summary: bug in sndstat_unpack_user_nvlbuf() Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Some People Priority: --- Component: kern Assignee: bugs@FreeBSD.org Reporter: rtm@lcs.mit.edu In this code in sndstat_unpack_user_nvlbuf() in sys/dev/sound/pcm/sndstat.c: *nvl =3D nvlist_unpack(nvlbuf, nbytes, 0); free(nvlbuf, M_DEVBUF); if (nvl =3D=3D NULL) { return (EINVAL); } I believe it should be if (*nvl =3D=3D NULL) { Without this fix, if nvlist_unpack() returns NULL, subsequent code will panic when it tries to use a NULL *nvl. A demo: int main() { char *dev =3D "/dev/sndstat"; int fd =3D open(dev, 2); if(fd < 0) { perror(dev); exit(1); } char buf2[64]; memset(buf2, 0, sizeof(buf2)); char buf1[128]; memset(buf1, 0, sizeof(buf1)); *(int*)(buf1+0) =3D sizeof(buf2); *(char**)(buf1+8) =3D buf2; ioctl(fd, 0xc0104466, buf1); // SNDSTIOC_ADD_USER_DEVS } panic: Assertion (nvl) !=3D ((void *)0) failed at /usr/rtm/symbsd/src/sys/contrib/libnv/nvlist.c:387=20=20=20=20=20=20=20=20= =20=20=20 panic() at panic+0x2a nvlist_find() at nvlist_find+0xd4 nvlist_exists_nvlist_array() at nvlist_exists_nvlist_array+0x10 sndstat_add_user_devs() at sndstat_add_user_devs+0x4e sndstat_ioctl() at sndstat_ioctl+0x9e devfs_ioctl() at devfs_ioctl+0xbe VOP_IOCTL_APV() at VOP_IOCTL_APV+0x30 VOP_IOCTL() at VOP_IOCTL+0x36 vn_ioctl() at vn_ioctl+0xba devfs_ioctl_f() at devfs_ioctl_f+0x20 fo_ioctl() at fo_ioctl+0xa kern_ioctl() at kern_ioctl+0x242 sys_ioctl() at sys_ioctl+0x120 syscallenter() at syscallenter+0xec ecall_handler() at ecall_handler+0x18 do_trap_user() at do_trap_user+0xea cpu_exception_handler_user() at cpu_exception_handler_user+0x72 --=20 You are receiving this mail because: You are the assignee for the bug.=
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-266144-227>