ALSA: info: Check for integer overflow in snd_info_entry_write()
Subsystems (2)
PATCH 1/1 ALSA: info: Check for integer overflow in snd_info_entry_write()
Commit 4adb7bcbcb69 ("ALSA: core: Use seq_file for text proc file reads") heavily refactored ALSA procfs and fixed the overflow as a side-effect, so this fix only applies to kernels < 4.2 and there is no upstream equivalent
snd_info_entry_write() resizes the buffer with an unsigned long size argument that gets truncated because resize_info_buffer() takes the size parameter as an unsigned int. On 64-bit kernels, this causes the following copy_to_user() to write out-of-bounds if (pos + count) can't be represented by an unsigned int.
--- sound/core/info.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/info.c +3 -1
@@ -253,6 +253,7 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *bufferstruct snd_info_buffer *buf;ssize_t size =0 ;loff_t pos; +unsigned long realloc_size; data = file->private_data;if (snd_BUG_ON (!data))
@@ -261,7 +262,8 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer pos = *offset;if (pos <0 || (long ) pos != pos || (ssize_t ) count <0 )return -EIO ; -if ((unsigned long ) pos + (unsigned long ) count < (unsigned long ) pos) + realloc_size = (unsigned long ) pos + (unsigned long ) count; +if (realloc_size < (unsigned long ) pos || realloc_size >UINT_MAX )return -EIO ;switch (entry->content) {case SNDRV_INFO_CONTENT_TEXT :
Signature · 1 line
2.18.0.865.gffc8e1a3cd6-goog
Greg KH
maintainerQuoted 4 lines · Erick Reyes
Commit
4adb7bcbcb69("ALSA: core: Useseq_filefor text proc file reads") heavily refactored ALSA procfs and fixed the overflow as a side-effect, so this fix only applies to kernels < 4.2 and there is no upstream equivalent
Thanks for the patch. I'll queue this up for 3.18.
greg k-h
Patch "ALSA: info: Check for integer overflow in snd_info_entry_write()" has been added to the 3.18-stable tree
In reply to Erick ReyesThis is a note to let you know that I've just added the patch titled
ALSA: info: Check for integer overflow in snd_info_entry_write()
to the 3.18-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
The filename of the patch is:
alsa-info-check-for-integer-overflow-in-snd_info_entry_write.patch
and it can be found in the queue-3.18 subdirectory.
If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
Quoted 1 line
From [email protected] Thu Aug 16 12:07:22 2018
From: Erick Reyes <[email protected]>
Date: Wed, 15 Aug 2018 17:55:48 -0700
Subject: ALSA: info: Check for integer overflow in snd_info_entry_write()
To: [email protected]
Cc: [email protected], Jaroslav Kysela <[email protected]>, Takashi Iwai <[email protected]>, [email protected], Vinod Koul <[email protected]>, Joe Perches <[email protected]>, Al Viro <[email protected]>, [email protected], Erick Reyes <[email protected]>, Siqi Lin <[email protected]>
Message-ID: <[email protected]>
From: Erick Reyes <[email protected]>
Commit 4adb7bcbcb69 ("ALSA: core: Use seq_file for text proc file reads") heavily refactored ALSA procfs and fixed the overflow as a side-effect, so this fix only applies to kernels < 4.2 and there is no upstream equivalent
snd_info_entry_write() resizes the buffer with an unsigned long size argument that gets truncated because resize_info_buffer() takes the size parameter as an unsigned int. On 64-bit kernels, this causes the following copy_to_user() to write out-of-bounds if (pos + count) can't be represented by an unsigned int.
--- sound/core/info.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/core/info.c +3 -1
@@ -253,6 +253,7 @@ static ssize_t snd_info_entry_write(strustruct snd_info_buffer *buf;ssize_t size =0 ;loff_t pos; +unsigned long realloc_size; data = file->private_data;if (snd_BUG_ON (!data))
@@ -261,7 +262,8 @@ static ssize_t snd_info_entry_write(stru pos = *offset;if (pos <0 || (long ) pos != pos || (ssize_t ) count <0 )return -EIO ; -if ((unsigned long ) pos + (unsigned long ) count < (unsigned long ) pos) + realloc_size = (unsigned long ) pos + (unsigned long ) count; +if (realloc_size < (unsigned long ) pos || realloc_size >UINT_MAX )return -EIO ;switch (entry->content) {case SNDRV_INFO_CONTENT_TEXT :
Patches currently in stable-queue which might be from [email protected] are
queue-3.18/alsa-info-check-for-integer-overflow-in-snd_info_entry_write.patch