From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1FA484E73B9; Thu, 17 Sep 2026 15:48:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789660113; cv=none; b=QZ6+BNlQ1Chdd14M0O1xVU9QRp+XMFtzIQT11UfEZ8LlwVMGc96yfLdNSHRhgISi7c/QozruvgblKrN0sOSbmid9NnIKJZEtMPSBX8dtNeJiOJKAubMNSCA1ZW1UjH3EP1MMo+eMPzs4hHM4yfgcfUODGyg/G7i5ZmtZduFBY98= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789660113; c=relaxed/simple; bh=7vSQGY0ShxwesZruRGPDu8IqgWJ9nm500eI5cvQdqDE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=GHoYli+5tIHr8nIE3GgWuHbr+FNooKVMifYy1eO4pRefqj6VG8jj9y/Bh/oAi7WTM+WWg2jmXGmWlfvw9qPxgAvKh/narxGnr0zg98ywB5NlCZaMpB+oRNhtFP85aohW3x/+qfBvvzbVOxEJtc4n5EVJWhES9Zx5ovau8AV0KSg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=ukUQ9dtD; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="ukUQ9dtD" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CD0121F00899; Thu, 17 Sep 2026 15:48:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789660109; bh=bQIb9k2JJNJDB6+Cz0do388LfEyRFZTFLfFkoznnezI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ukUQ9dtDl2jb2VF0kGtyb0LMaD7QVlkOdiMFsP7dkaI83xnFDekHuRr/bzKwQ4QCO o6LzUAYkyTI32KtaJUqkpe2wKY+3bImCCXLkiyy0Yj+ulE0unRjhJFvhFXP8T6RdpU 0FRSxzTdzsMkRhZAdVSbbc2LJVHD2uT54j2OABno= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Kazuki Hanai , Takashi Iwai Subject: [PATCH 7.2 481/733] ALSA: us122l: Prevent write upgrades for read mappings Date: Thu, 17 Sep 2026 16:13:09 +0100 Message-ID: <20260917151404.007128488@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151350.597953846@linuxfoundation.org> References: <20260917151350.597953846@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 7.2-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kazuki Hanai commit 71c610aeb1770302ac9c9e0b9a4ecd37f1311928 upstream. The hwdep mmap callback rejects read-buffer mappings that are initially writable, but leaves VM_MAYWRITE set on mappings created with PROT_READ. A process that can open the hwdep node O_RDWR can later use mprotect() to make the mapping writable. The read allocation begins with struct usb_stream. Its read_size member is used by the fault handler to decide which pages belong to the read buffer. The read VMA intentionally remains expandable because pcm_usb_stream uses mremap() after reading that size. Changing read_size first can therefore map and access pages beyond the allocation. The same member is also consumed by usb_stream_free(), where changing it can make free_pages_exact() release pages outside the allocation. Clear VM_MAYWRITE for read-buffer mappings after rejecting an initially writable VMA. This keeps the separate output-buffer mapping writable while preventing later permission upgrades. Fixes: 030a07e44129 ("ALSA: Add USB US122L driver") Cc: stable@vger.kernel.org Signed-off-by: Kazuki Hanai Link: https://patch.msgid.link/20260908110053.2950767-1-hnkz.64@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/usx2y/us122l.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) --- a/sound/usb/usx2y/us122l.c +++ b/sound/usb/usx2y/us122l.c @@ -180,8 +180,11 @@ static int usb_stream_hwdep_mmap(struct guard(mutex)(&us122l->mutex); s = us122l->sk.s; read = offset < s->read_size; - if (read && area->vm_flags & VM_WRITE) - return -EPERM; + if (read) { + if (area->vm_flags & VM_WRITE) + return -EPERM; + vm_flags_clear(area, VM_MAYWRITE); + } /* if userspace tries to mmap beyond end of our buffer, fail */ if (size > PAGE_ALIGN(read ? s->read_size : s->write_size)) { dev_warn(hw->card->dev, "%s: size %lu > %u\n", __func__,