From nobody Wed May 22 13:23:19 2024 X-Original-To: dev-commits-src-all@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 4VksSR53cnz5LjPq; Wed, 22 May 2024 13:23:19 +0000 (UTC) (envelope-from git@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 4VksSR2zxDz43Jl; Wed, 22 May 2024 13:23:19 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716384199; 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=hVg6YTZAbgtmLwFgLMHiXM9X24xWPpFWxQrJzlmIkdg=; b=Tta4IPV8EcoPSV3yd1plLG0ntcU4bADk+KbJ6BCsRWmsQVxsrD92XFCJb3JilJ9zz8qu+2 P5mumBELrXnNdtnBpGzMM4i2Wanu67FnOLHASK8IjW4bMsbOhw4OVgOe63ZIVRtm6kVEiR YTAeFSbHKqnrdLuBq+ust/e1SGdXq17HGc7RG6kE7OEEx1bAr1E8h7Ts0Swt54Fsa4qib0 hq4ksAXKR8lTZZ0xRjIiWEh9qe/cU9rQIw72FzEPLPc3A4O5TAc0nJfaujjoCW9mkb6agw BRNKx61M3YJyAb7hiVPU9F7ubIkZah2+661aSR2Z27yZXj1vdU4BwwmdtBncPw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1716384199; a=rsa-sha256; cv=none; b=W8Jx9+iSn8M6S0HZyxYmwOW7f1Ri8ON8DdaYa/yQtvtaSNdVwktz8Sutbl08raTP5rEsdr q82pvirdhxK7JxkrsuGysaRNdB2ycA82Z/BRFOLCbbeVmZrhjMZjeHKRosErKplFVuS4mP tca7pwyZ5GULUHpxtI3AvU0TqLzW+fhgWi3HLeEM5l1CawBhc2CJby0jhtq8CGBAHVf230 MayY4l7UvB03UPgUjSjaXvCE1JiLrMtuiS/EhGFbxZfzs5itxIPoA9QZqyjTwHoU3KzSwR Bx2I4MTJGrhJTDPev8zGfU72EsILbP/w3MJyWRatPSE5yGwAiJhNp1E6P82fEg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1716384199; 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=hVg6YTZAbgtmLwFgLMHiXM9X24xWPpFWxQrJzlmIkdg=; b=U6TQr4Siy+Q2yH/WbqVE8Lgeclact6KxOMQCJkfeHVRquX0PRcYOGDWcyx/I1q/LcStJF1 c6NYD7sN5bnVug7bYfpWmElHFMwcPk5xyHBjBgJVJmZQ5qsGYfZUEGTIeK17NpOain76g7 +SGj4PACUp0e19MBdOTSyz6TC1ugJHDYfE9Jr4ivPdXxkSN9bBok3vNs9eowTiu6nMuOLH vjzRm/XxEr7rrL3yitpadMWSqueNX6RphK+4RbJGyJ9KdI3I+DHMckYxNieiBwC5/kh+L4 Mh67UuufsTFkhKFte35JKoVBuT9qLp1YwKMhvaICe3L/BXEoHP9Xs+5ZL084hg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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 4VksSR2bGyz16pG; Wed, 22 May 2024 13:23:19 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 44MDNJ3i098755; Wed, 22 May 2024 13:23:19 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 44MDNJaM098752; Wed, 22 May 2024 13:23:19 GMT (envelope-from git) Date: Wed, 22 May 2024 13:23:19 GMT Message-Id: <202405221323.44MDNJaM098752@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Christos Margiolis Subject: git: 18f80d6d4634 - releng/14.1 - sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS* List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: christos X-Git-Repository: src X-Git-Refname: refs/heads/releng/14.1 X-Git-Reftype: branch X-Git-Commit: 18f80d6d463495703f9eb2ccfd92bae93c7889a3 Auto-Submitted: auto-generated The branch releng/14.1 has been updated by christos: URL: https://cgit.FreeBSD.org/src/commit/?id=18f80d6d463495703f9eb2ccfd92bae93c7889a3 commit 18f80d6d463495703f9eb2ccfd92bae93c7889a3 Author: Christos Margiolis AuthorDate: 2024-05-20 14:18:28 +0000 Commit: Christos Margiolis CommitDate: 2024-05-22 13:22:26 +0000 sound: Check user-supplied size passed to SNDSTIOC_ADD_USER_DEVS* SNDSTIOC_ADD_USER_DEVS* expects a user-supplied sndstioc_nv_arg->nbytes, however we currently do not check whether this size is actually valid, which results in a panic when SNDSTIOC_ADD_USER_DEVS* is called with an invalid size. sndstat_add_user_devs() calls sndstat_unpack_user_nvlbuf(), which then calls malloc() with that size. PR: 266142 Sponsored by: The FreeBSD Foundation MFC after: 1 day Reviewed by: brooks Differential Revision: https://reviews.freebsd.org/D45236 (cherry picked from commit 074d337ad618f9cc2a1d5ab18b484928e57bd72b) (cherry picked from commit 5830a00c2c5485ec17900558e4f29c459c6a1f3e) Approved by: re (cperciva) --- sys/dev/sound/pcm/sndstat.c | 5 +++++ sys/sys/sndstat.h | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/sys/dev/sound/pcm/sndstat.c b/sys/dev/sound/pcm/sndstat.c index ef006a580d40..eb5c68c7c519 100644 --- a/sys/dev/sound/pcm/sndstat.c +++ b/sys/dev/sound/pcm/sndstat.c @@ -865,6 +865,11 @@ sndstat_add_user_devs(struct sndstat_file *pf, caddr_t data) goto done; } + if (arg->nbytes > SNDST_UNVLBUF_MAX) { + err = ENOMEM; + goto done; + } + err = sndstat_unpack_user_nvlbuf(arg->buf, arg->nbytes, &nvl); if (err != 0) goto done; diff --git a/sys/sys/sndstat.h b/sys/sys/sndstat.h index f0e4d352242f..8a49042b0453 100644 --- a/sys/sys/sndstat.h +++ b/sys/sys/sndstat.h @@ -74,6 +74,11 @@ struct sndstioc_nv_arg { #define SNDST_DSPS_SOUND4_PVCHAN "pvchan" #define SNDST_DSPS_SOUND4_RVCHAN "rvchan" +/* + * Maximum user-specified nvlist buffer size + */ +#define SNDST_UNVLBUF_MAX 65535 + #define SNDSTIOC_REFRESH_DEVS \ _IO('D', 100) #define SNDSTIOC_GET_DEVS \