* [PATCH 1/2] ALSA: info: Avoid leaking kernel memory
@ 2013-03-13 16:36 Takashi Iwai
2013-03-13 16:36 ` [PATCH 2/2] ALSA: info: Small refactoring and a sanity check in snd_info_get_line() Takashi Iwai
2013-03-14 6:15 ` [PATCH 1/2] ALSA: info: Avoid leaking kernel memory David Henningsson
0 siblings, 2 replies; 4+ messages in thread
From: Takashi Iwai @ 2013-03-13 16:36 UTC (permalink / raw)
To: alsa-devel
Make sure that the allocated buffer for reading the proc file won't
expose the uncleared kernel memory.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/info.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index db308db..58e97b3 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
char *nbuf;
nsize = PAGE_ALIGN(nsize);
- nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL);
+ nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO);
if (! nbuf)
return -ENOMEM;
@@ -353,7 +353,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
goto __nomem;
data->rbuffer = buffer;
buffer->len = PAGE_SIZE;
- buffer->buffer = kmalloc(buffer->len, GFP_KERNEL);
+ buffer->buffer = kzalloc(buffer->len, GFP_KERNEL);
if (buffer->buffer == NULL)
goto __nomem;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH 2/2] ALSA: info: Small refactoring and a sanity check in snd_info_get_line()
2013-03-13 16:36 [PATCH 1/2] ALSA: info: Avoid leaking kernel memory Takashi Iwai
@ 2013-03-13 16:36 ` Takashi Iwai
2013-03-14 6:15 ` [PATCH 1/2] ALSA: info: Avoid leaking kernel memory David Henningsson
1 sibling, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2013-03-13 16:36 UTC (permalink / raw)
To: alsa-devel
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
sound/core/info.c | 21 ++++++++-------------
1 file changed, 8 insertions(+), 13 deletions(-)
diff --git a/sound/core/info.c b/sound/core/info.c
index 58e97b3..c9042b4 100644
--- a/sound/core/info.c
+++ b/sound/core/info.c
@@ -700,26 +700,21 @@ int snd_info_get_line(struct snd_info_buffer *buffer, char *line, int len)
{
int c = -1;
+ if (snd_BUG_ON(!buffer || !buffer->buffer))
+ return 1;
if (len <= 0 || buffer->stop || buffer->error)
return 1;
- while (--len > 0) {
+ while (!buffer->stop) {
c = buffer->buffer[buffer->curr++];
- if (c == '\n') {
- if (buffer->curr >= buffer->size)
- buffer->stop = 1;
- break;
- }
- *line++ = c;
- if (buffer->curr >= buffer->size) {
+ if (buffer->curr >= buffer->size)
buffer->stop = 1;
+ if (c == '\n')
break;
+ if (len) {
+ len--;
+ *line++ = c;
}
}
- while (c != '\n' && !buffer->stop) {
- c = buffer->buffer[buffer->curr++];
- if (buffer->curr >= buffer->size)
- buffer->stop = 1;
- }
*line = '\0';
return 0;
}
--
1.8.1.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ALSA: info: Avoid leaking kernel memory
2013-03-13 16:36 [PATCH 1/2] ALSA: info: Avoid leaking kernel memory Takashi Iwai
2013-03-13 16:36 ` [PATCH 2/2] ALSA: info: Small refactoring and a sanity check in snd_info_get_line() Takashi Iwai
@ 2013-03-14 6:15 ` David Henningsson
2013-03-14 6:49 ` Takashi Iwai
1 sibling, 1 reply; 4+ messages in thread
From: David Henningsson @ 2013-03-14 6:15 UTC (permalink / raw)
To: Takashi Iwai; +Cc: alsa-devel
On 03/13/2013 05:36 PM, Takashi Iwai wrote:
> Make sure that the allocated buffer for reading the proc file won't
> expose the uncleared kernel memory.
This should go to stable too, due to the security implications of
leaking possibly sensitive information to userspace?
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> ---
> sound/core/info.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/sound/core/info.c b/sound/core/info.c
> index db308db..58e97b3 100644
> --- a/sound/core/info.c
> +++ b/sound/core/info.c
> @@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
> char *nbuf;
>
> nsize = PAGE_ALIGN(nsize);
> - nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL);
> + nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO);
> if (! nbuf)
> return -ENOMEM;
>
> @@ -353,7 +353,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
> goto __nomem;
> data->rbuffer = buffer;
> buffer->len = PAGE_SIZE;
> - buffer->buffer = kmalloc(buffer->len, GFP_KERNEL);
> + buffer->buffer = kzalloc(buffer->len, GFP_KERNEL);
> if (buffer->buffer == NULL)
> goto __nomem;
> }
>
--
David Henningsson, Canonical Ltd.
https://launchpad.net/~diwic
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/2] ALSA: info: Avoid leaking kernel memory
2013-03-14 6:15 ` [PATCH 1/2] ALSA: info: Avoid leaking kernel memory David Henningsson
@ 2013-03-14 6:49 ` Takashi Iwai
0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2013-03-14 6:49 UTC (permalink / raw)
To: David Henningsson; +Cc: alsa-devel
At Thu, 14 Mar 2013 07:15:28 +0100,
David Henningsson wrote:
>
> On 03/13/2013 05:36 PM, Takashi Iwai wrote:
> > Make sure that the allocated buffer for reading the proc file won't
> > expose the uncleared kernel memory.
>
> This should go to stable too, due to the security implications of
> leaking possibly sensitive information to userspace?
It's no problem as long as the driver formats the proc output properly
via snd_iprintf(), thus no actual exposure happens in the codes we
have for now, AFAIK.
The patch is just to be sure on the ground level.
Takashi
>
> >
> > Signed-off-by: Takashi Iwai <tiwai@suse.de>
> > ---
> > sound/core/info.c | 4 ++--
> > 1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/sound/core/info.c b/sound/core/info.c
> > index db308db..58e97b3 100644
> > --- a/sound/core/info.c
> > +++ b/sound/core/info.c
> > @@ -89,7 +89,7 @@ static int resize_info_buffer(struct snd_info_buffer *buffer,
> > char *nbuf;
> >
> > nsize = PAGE_ALIGN(nsize);
> > - nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL);
> > + nbuf = krealloc(buffer->buffer, nsize, GFP_KERNEL | __GFP_ZERO);
> > if (! nbuf)
> > return -ENOMEM;
> >
> > @@ -353,7 +353,7 @@ static int snd_info_entry_open(struct inode *inode, struct file *file)
> > goto __nomem;
> > data->rbuffer = buffer;
> > buffer->len = PAGE_SIZE;
> > - buffer->buffer = kmalloc(buffer->len, GFP_KERNEL);
> > + buffer->buffer = kzalloc(buffer->len, GFP_KERNEL);
> > if (buffer->buffer == NULL)
> > goto __nomem;
> > }
> >
>
>
>
> --
> David Henningsson, Canonical Ltd.
> https://launchpad.net/~diwic
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2013-03-14 6:49 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-13 16:36 [PATCH 1/2] ALSA: info: Avoid leaking kernel memory Takashi Iwai
2013-03-13 16:36 ` [PATCH 2/2] ALSA: info: Small refactoring and a sanity check in snd_info_get_line() Takashi Iwai
2013-03-14 6:15 ` [PATCH 1/2] ALSA: info: Avoid leaking kernel memory David Henningsson
2013-03-14 6:49 ` Takashi Iwai
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.