Skip to content

Commit 05530ef

Browse files
keestiwai
authored andcommitted
ALSA: seq: Fix function prototype mismatch in snd_seq_expand_var_event
With clang's kernel control flow integrity (kCFI, CONFIG_CFI_CLANG), indirect call targets are validated against the expected function pointer prototype to make sure the call target is valid to help mitigate ROP attacks. If they are not identical, there is a failure at run time, which manifests as either a kernel panic or thread getting killed. seq_copy_in_user() and seq_copy_in_kernel() did not have prototypes matching snd_seq_dump_func_t. Adjust this and remove the casts. There are not resulting binary output differences. This was found as a result of Clang's new -Wcast-function-type-strict flag, which is more sensitive than the simpler -Wcast-function-type, which only checks for type width mismatches. Reported-by: kernel test robot <[email protected]> Link: https://lore.kernel.org/lkml/[email protected] Cc: Jaroslav Kysela <[email protected]> Cc: Takashi Iwai <[email protected]> Cc: "Gustavo A. R. Silva" <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Takashi Iwai <[email protected]>
1 parent 1abfd71 commit 05530ef

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

sound/core/seq/seq_memory.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,19 @@ EXPORT_SYMBOL(snd_seq_dump_var_event);
113113
* expand the variable length event to linear buffer space.
114114
*/
115115

116-
static int seq_copy_in_kernel(char **bufptr, const void *src, int size)
116+
static int seq_copy_in_kernel(void *ptr, void *src, int size)
117117
{
118+
char **bufptr = ptr;
119+
118120
memcpy(*bufptr, src, size);
119121
*bufptr += size;
120122
return 0;
121123
}
122124

123-
static int seq_copy_in_user(char __user **bufptr, const void *src, int size)
125+
static int seq_copy_in_user(void *ptr, void *src, int size)
124126
{
127+
char __user **bufptr = ptr;
128+
125129
if (copy_to_user(*bufptr, src, size))
126130
return -EFAULT;
127131
*bufptr += size;
@@ -151,8 +155,7 @@ int snd_seq_expand_var_event(const struct snd_seq_event *event, int count, char
151155
return newlen;
152156
}
153157
err = snd_seq_dump_var_event(event,
154-
in_kernel ? (snd_seq_dump_func_t)seq_copy_in_kernel :
155-
(snd_seq_dump_func_t)seq_copy_in_user,
158+
in_kernel ? seq_copy_in_kernel : seq_copy_in_user,
156159
&buf);
157160
return err < 0 ? err : newlen;
158161
}

0 commit comments

Comments
 (0)