* [PATCH] ALSA: info: Check for integer overflow in snd_info_entry_write()
@ 2018-08-16 0:55 Erick Reyes
2018-08-16 10:07 ` Greg KH
2018-08-16 10:08 ` Patch "ALSA: info: Check for integer overflow in snd_info_entry_write()" has been added to the 3.18-stable tree gregkh
0 siblings, 2 replies; 3+ messages in thread
From: Erick Reyes @ 2018-08-16 0:55 UTC (permalink / raw)
To: stable
Cc: linux-kernel, Jaroslav Kysela, Takashi Iwai, kernel-team,
Vinod Koul, Joe Perches, Al Viro, alsa-devel, Erick Reyes,
Siqi Lin
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.
Signed-off-by: Siqi Lin <siqilin@google.com>
Signed-off-by: Erick Reyes <erickreyes@google.com>
---
sound/core/info.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index 9f404e965ea2..08832c973a53 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -253,6 +253,7 @@ static ssize_t snd_info_entry_write(struct file *file, const char __user *buffer
struct 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:
--
2.18.0.865.gffc8e1a3cd6-goog
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] ALSA: info: Check for integer overflow in snd_info_entry_write()
2018-08-16 0:55 [PATCH] ALSA: info: Check for integer overflow in snd_info_entry_write() Erick Reyes
@ 2018-08-16 10:07 ` Greg KH
2018-08-16 10:08 ` Patch "ALSA: info: Check for integer overflow in snd_info_entry_write()" has been added to the 3.18-stable tree gregkh
1 sibling, 0 replies; 3+ messages in thread
From: Greg KH @ 2018-08-16 10:07 UTC (permalink / raw)
To: Erick Reyes
Cc: stable, linux-kernel, Jaroslav Kysela, Takashi Iwai, kernel-team,
Vinod Koul, Joe Perches, Al Viro, alsa-devel, Siqi Lin
On Wed, Aug 15, 2018 at 05:55:48PM -0700, Erick Reyes wrote:
> 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
Thanks for the patch. I'll queue this up for 3.18.
greg k-h
^ permalink raw reply [flat|nested] 3+ messages in thread
* Patch "ALSA: info: Check for integer overflow in snd_info_entry_write()" has been added to the 3.18-stable tree
2018-08-16 0:55 [PATCH] ALSA: info: Check for integer overflow in snd_info_entry_write() Erick Reyes
2018-08-16 10:07 ` Greg KH
@ 2018-08-16 10:08 ` gregkh
1 sibling, 0 replies; 3+ messages in thread
From: gregkh @ 2018-08-16 10:08 UTC (permalink / raw)
To: alsa-devel, erickreyes, gregkh, joe, kernel-team, perex, siqilin,
tiwai, viro, vkoul
Cc: stable-commits
This 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 <stable@vger.kernel.org> know about it.
>From erickreyes@google.com Thu Aug 16 12:07:22 2018
From: Erick Reyes <erickreyes@google.com>
Date: Wed, 15 Aug 2018 17:55:48 -0700
Subject: ALSA: info: Check for integer overflow in snd_info_entry_write()
To: stable@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>, kernel-team@android.com, Vinod Koul <vkoul@kernel.org>, Joe Perches <joe@perches.com>, Al Viro <viro@zeniv.linux.org.uk>, alsa-devel@alsa-project.org, Erick Reyes <erickreyes@google.com>, Siqi Lin <siqilin@google.com>
Message-ID: <20180816005548.151269-1-erickreyes@google.com>
From: Erick Reyes <erickreyes@google.com>
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.
Signed-off-by: Siqi Lin <siqilin@google.com>
Signed-off-by: Erick Reyes <erickreyes@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
sound/core/info.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -253,6 +253,7 @@ static ssize_t snd_info_entry_write(stru
struct 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 erickreyes@google.com are
queue-3.18/alsa-info-check-for-integer-overflow-in-snd_info_entry_write.patch
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-08-16 10:08 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-16 0:55 [PATCH] ALSA: info: Check for integer overflow in snd_info_entry_write() Erick Reyes
2018-08-16 10:07 ` Greg KH
2018-08-16 10:08 ` Patch "ALSA: info: Check for integer overflow in snd_info_entry_write()" has been added to the 3.18-stable tree gregkh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.