Skip to content

Commit 7e78a5b

Browse files
CassivsGabriellisgregkh
authored andcommitted
ALSA: seq: Fix UMP group 16 filtering
[ Upstream commit 92429ca ] The sequencer UAPI defines group_filter as an unsigned int bitmap. Bit 0 filters groupless messages and bits 1-16 filter UMP groups 1-16. The internal snd_seq_client storage is only unsigned short, so bit 16 is truncated when userspace sets the filter. The same truncation affects the automatic UMP client filter used to avoid delivery to inactive groups, so events for group 16 cannot be filtered. Store the internal bitmap as unsigned int and keep both userspace-provided and automatically generated values limited to the defined UAPI bits. Fixes: d2b7060 ("ALSA: seq: Add UMP group filter") Cc: stable@vger.kernel.org Signed-off-by: Cássio Gabriel <cassiogabrielcontato@gmail.com> Link: https://patch.msgid.link/20260506-alsa-seq-ump-group16-filter-v1-1-b75160bf6993@gmail.com Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent dbacde3 commit 7e78a5b

3 files changed

Lines changed: 6 additions & 3 deletions

File tree

sound/core/seq/seq_clientmgr.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1333,7 +1333,7 @@ static int snd_seq_ioctl_set_client_info(struct snd_seq_client *client,
13331333
if (client->user_pversion >= SNDRV_PROTOCOL_VERSION(1, 0, 3))
13341334
client->midi_version = client_info->midi_version;
13351335
memcpy(client->event_filter, client_info->event_filter, 32);
1336-
client->group_filter = client_info->group_filter;
1336+
client->group_filter = client_info->group_filter & SND_SEQ_GROUP_FILTER_MASK;
13371337

13381338
/* notify the change */
13391339
snd_seq_system_client_ev_client_change(client->number);

sound/core/seq/seq_clientmgr.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414

1515
/* client manager */
1616

17+
#define SND_SEQ_GROUP_FILTER_MASK GENMASK(SNDRV_UMP_MAX_GROUPS, 0)
18+
#define SND_SEQ_GROUP_FILTER_GROUPS GENMASK(SNDRV_UMP_MAX_GROUPS, 1)
19+
1720
struct snd_seq_user_client {
1821
struct file *file; /* file struct of client */
1922
/* ... */
@@ -40,7 +43,7 @@ struct snd_seq_client {
4043
int number; /* client number */
4144
unsigned int filter; /* filter flags */
4245
DECLARE_BITMAP(event_filter, 256);
43-
unsigned short group_filter;
46+
unsigned int group_filter;
4447
snd_use_lock_t use_lock;
4548
int event_lost;
4649
/* ports */

sound/core/seq/seq_ump_client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ static void setup_client_group_filter(struct seq_ump_client *client)
370370
cptr = snd_seq_kernel_client_get(client->seq_client);
371371
if (!cptr)
372372
return;
373-
filter = ~(1U << 0); /* always allow groupless messages */
373+
filter = SND_SEQ_GROUP_FILTER_GROUPS; /* always allow groupless messages */
374374
for (p = 0; p < SNDRV_UMP_MAX_GROUPS; p++) {
375375
if (client->ump->groups[p].active)
376376
filter &= ~(1U << (p + 1));

0 commit comments

Comments
 (0)