Skip to content

Commit 611f538

Browse files
CassivsGabriellistiwai
authored andcommitted
ALSA: seq: oss: Reject reads that cannot fit the next event
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 <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260602-alsa-seq-oss-read-size-check-v1-1-10e59b1742e0@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent f8e357a commit 611f538

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

sound/core/seq/oss/seq_oss_rw.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ snd_seq_oss_read(struct seq_oss_devinfo *dp, char __user *buf, int count)
5757
break;
5858
}
5959
ev_len = ev_length(&rec);
60-
if (ev_len < count) {
60+
if (count < ev_len) {
61+
err = -EINVAL;
6162
snd_seq_oss_readq_unlock(readq, flags);
6263
break;
6364
}

0 commit comments

Comments
 (0)