Skip to content

Commit a04dae6

Browse files
Dan Carpentertiwai
authored andcommitted
ALSA: silence integer wrapping warning
This patch doesn't change runtime at all, it's just for kernel hardening. The "count" here comes from the user and on 32bit systems, it leads to integer wrapping when we pass it to compute_user_elem_size(): alloc_size = compute_user_elem_size(private_size, count); However, the integer over is harmless because later "count" is checked when we pass it to snd_ctl_new(): err = snd_ctl_new(&kctl, count, access, file); These days as part of kernel hardening we're trying to avoid integer overflows when they affect size_t type. So to avoid the integer overflow copy the check from snd_ctl_new() and do it at the start of the snd_ctl_elem_add() function as well. Signed-off-by: Dan Carpenter <[email protected]> Reviewed-by: Jaroslav Kysela <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 8a193d8 commit a04dae6

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/core/control.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1641,6 +1641,8 @@ static int snd_ctl_elem_add(struct snd_ctl_file *file,
16411641
count = info->owner;
16421642
if (count == 0)
16431643
count = 1;
1644+
if (count > MAX_CONTROL_COUNT)
1645+
return -EINVAL;
16441646

16451647
/* Arrange access permissions if needed. */
16461648
access = info->access;

0 commit comments

Comments
 (0)