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 D79BC4F85A4; Thu, 17 Sep 2026 16:58:41 +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=1789664323; cv=none; b=A4Mum+kwixaN/SHBvsNDVYAwCbO0EmYUmXOvdcJ4IDsm4HeGIw2Z46Fj9UnPMLRKhfTCeWfsF5A1BySSW853GfTkOVtSS9B7LOBu6bfqBskjgzJ56YRkrJUCl1eoXSjaQqCPG+Fx/cbIz/8J2d6t2HpBrNzJdRDCgGFsS1lGWM0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789664323; c=relaxed/simple; bh=d/jgNqXtHtkS8fLa12fBSYVZ+u1veF9yzRtpGcszyWQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=W+VQ72qQMyoxhMqMb9eCajl5BpP54eJjcBfVkJ0XxKd5uebbYr5JGztyJZrP9AYNK6QT2nBFVj3rekw2JJW7UYnmIMqsRLDoU34yR3XZCvIuIc/fpeLX94P2tOGwuR2gFWHyIXGAw6//Osnfaq93r6LK2W3lZ51AKiPWDKRIfjg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=Ekkmqme6; 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="Ekkmqme6" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B28F01F000FF; Thu, 17 Sep 2026 16:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789664321; bh=Zb3m6lbT/KsKyoDtcq5XH86M8O2rvBj1VhSdGdYuYeY=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Ekkmqme6//77Xe+c2dKKU9POKTWut7U+1OD2yPOmPRcn6JEaJMtlmKIOFafx4hvYs 9CEcJncT/ldqw+MuVttc4KVmdWzVBR8jj9JT3jCTkHFNfnrhkn19x8sCcbxhIoL6hv 8dv6Ac55uGn1Lujzzr9+xiYdFeXsbVGq9kgPtpyk= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, =?UTF-8?q?C=C3=A1ssio=20Gabriel?= , Takashi Iwai , Sasha Levin Subject: [PATCH 6.18 0296/1250] ALSA: seq: oss: Reject reads that cannot fit the next event Date: Thu, 17 Sep 2026 16:01:31 +0100 Message-ID: <20260917151600.147463300@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260917151551.901433442@linuxfoundation.org> References: <20260917151551.901433442@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-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Cássio Gabriel [ Upstream commit 611f538253d970f4d152003841544e875828d015 ] snd_seq_oss_read() checks whether the next queued OSS sequencer event fits in the remaining userspace buffer before removing it from the read queue. The check is inverted. It currently stops when the event is smaller than the remaining buffer, so a normal 4-byte event is not copied for an 8-byte read buffer. Conversely, an 8-byte event can be copied for a smaller read count. Break only when the remaining userspace buffer is smaller than the next event, and report -EINVAL if no complete event has been copied. This prevents an undersized read from looking like end-of-file while leaving the event queued for a later read with a large enough buffer. Signed-off-by: Cássio Gabriel Link: https://patch.msgid.link/20260602-alsa-seq-oss-read-size-check-v1-1-10e59b1742e0@gmail.com Signed-off-by: Takashi Iwai Signed-off-by: Sasha Levin --- sound/core/seq/oss/seq_oss_rw.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sound/core/seq/oss/seq_oss_rw.c b/sound/core/seq/oss/seq_oss_rw.c index 111c792bc72ca..b7147ac78ee8b 100644 --- a/sound/core/seq/oss/seq_oss_rw.c +++ b/sound/core/seq/oss/seq_oss_rw.c @@ -57,7 +57,8 @@ snd_seq_oss_read(struct seq_oss_devinfo *dp, char __user *buf, int count) break; } ev_len = ev_length(&rec); - if (ev_len < count) { + if (count < ev_len) { + err = -EINVAL; snd_seq_oss_readq_unlock(readq, flags); break; } -- 2.53.0