From nobody Wed Aug 31 20:54:03 2022 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4MHxHH5bwQz4bHwM for ; Wed, 31 Aug 2022 20:54:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4MHxHH38tmz3dks for ; Wed, 31 Aug 2022 20:54:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4MHxHH2DF2zFqP for ; Wed, 31 Aug 2022 20:54:03 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 27VKs3gB089758 for ; Wed, 31 Aug 2022 20:54:03 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 27VKs37k089757 for bugs@FreeBSD.org; Wed, 31 Aug 2022 20:54:03 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 266144] bug in sndstat_unpack_user_nvlbuf() Date: Wed, 31 Aug 2022 20:54:03 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: rtm@lcs.mit.edu X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1661979243; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U7EHHAHJ7rnXxr6SxgAC1RKPHsvtVXM4aMgxtBQAEbY=; b=iJw5EfqU9krCbA2BC/LrLaCK82FodEKrLK9idoJ6PzH0b6HSmF0NZBCEh+ilRHb7ovb2hv PrfNz2gmf13ZUTpmNYQfhn6ici0IaIq/R4j1QjsXD9I3xpO22q6Kr4cftgfMfS8LAE8LN/ OevW2qhY2au4ri/ShPUdI22JzLDBPofxU1fwc07AMmzDOhjvycPSpIwuP+Lq3c9XePfPdh wiXX+H6ZBbxg3JEQaFJBdNJrrkqikKvIPoJ/GeZ5gX2q8MsTzOSpehpReL+xuQgwmINYHg Pmy+QNA6Mtyfp0Su7vErzi3LoGF3/9vdCu9qf6uF5cSvsFdsrwvm4Q3NGKF73A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1661979243; a=rsa-sha256; cv=none; b=tbZ05yGp5PPJm9Yb7KQpXO6vPPvHnDK3bNJ4+lQRBN5HRUNwiRSCPxpM09HVn4SfuRt/ru gUjfGIdvEsPIH/81catdPxe6fl6DfgA9wTcWAklqg82XcOaOOH6JbVRosXNmOjURDP0MLh bR+m8KBSShuOtR9BUCn1Z6AHr3Y64jlDHiJ/gN5o/ooOlcAe57TJO1+Z6G0jKleo4tuEfO XQJuWzP9abmVarxgP/1+WDCp2epdgmGpGwKbZTwlygJLCvRnfWZNEHtDM+XfRN6r8+c2Gt uD0fhf81PC1rfDkIfz3Ab3pbwNpwt8O3+1fyH+EDIjR+9z/MqilZOVvOIgRpZg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N 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.=