[Bug 266144] bug in sndstat_unpack_user_nvlbuf()
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Reply: bugzilla-noreply_a_freebsd.org: "[Bug 266144] bug in sndstat_unpack_user_nvlbuf()"
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Wed, 31 Aug 2022 20:54:03 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=266144
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 = nvlist_unpack(nvlbuf, nbytes, 0);
free(nvlbuf, M_DEVBUF);
if (nvl == NULL) {
return (EINVAL);
}
I believe it should be
if (*nvl == 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 = "/dev/sndstat";
int fd = 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) = sizeof(buf2);
*(char**)(buf1+8) = buf2;
ioctl(fd, 0xc0104466, buf1); // SNDSTIOC_ADD_USER_DEVS
}
panic: Assertion (nvl) != ((void *)0) failed at
/usr/rtm/symbsd/src/sys/contrib/libnv/nvlist.c:387
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
--
You are receiving this mail because:
You are the assignee for the bug.