public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64
@ 2022-11-23  5:09 Xiaolong Huang
  2022-11-23  6:55 ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: Xiaolong Huang @ 2022-11-23  5:09 UTC (permalink / raw)
  To: perex, tiwai, baolin.wang; +Cc: alsa-devel, linux-kernel, Xiaolong Huang

The compat_status is declared off of the stack, so it needs to
be zeroed out before copied back to userspace to prevent any
unintentional data leakage.

Fixes: d9e5582c4bb2 ("ALSA: Avoid using timespec for struct snd_rawmidi_status")
Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>

---

Reason for resend:
1. add Fixes line.
---
 sound/core/rawmidi_compat.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
index 68a93443583c..6afa68165b17 100644
--- a/sound/core/rawmidi_compat.c
+++ b/sound/core/rawmidi_compat.c
@@ -80,6 +80,7 @@ static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
 	if (err < 0)
 		return err;
 
+	memset(&compat_status, 0, sizeof(compat_status));
 	compat_status = (struct compat_snd_rawmidi_status64) {
 		.stream = status.stream,
 		.tstamp_sec = status.tstamp_sec,

base-commit: eb7081409f94a9a8608593d0fb63a1aa3d6f95d8
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64
  2022-11-23  5:09 [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64 Xiaolong Huang
@ 2022-11-23  6:55 ` Takashi Iwai
  2022-11-23  7:06   ` butt3rflyh4ck
  0 siblings, 1 reply; 4+ messages in thread
From: Takashi Iwai @ 2022-11-23  6:55 UTC (permalink / raw)
  To: Xiaolong Huang; +Cc: perex, tiwai, baolin.wang, alsa-devel, linux-kernel

On Wed, 23 Nov 2022 06:09:11 +0100,
Xiaolong Huang wrote:
> 
> The compat_status is declared off of the stack, so it needs to
> be zeroed out before copied back to userspace to prevent any
> unintentional data leakage.
> 
> Fixes: d9e5582c4bb2 ("ALSA: Avoid using timespec for struct snd_rawmidi_status")
> Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
> 
> ---
> 
> Reason for resend:
> 1. add Fixes line.
> ---
>  sound/core/rawmidi_compat.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
> index 68a93443583c..6afa68165b17 100644
> --- a/sound/core/rawmidi_compat.c
> +++ b/sound/core/rawmidi_compat.c
> @@ -80,6 +80,7 @@ static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
>  	if (err < 0)
>  		return err;
>  
> +	memset(&compat_status, 0, sizeof(compat_status));
>  	compat_status = (struct compat_snd_rawmidi_status64) {
>  		.stream = status.stream,
>  		.tstamp_sec = status.tstamp_sec,

Here at the line just after your addition, compat_status is fully
initialized by substitution, so I believe the memset is superfluous.

Or have you verified that it really leaks the uninitialized memory?


thanks,

Takashi

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64
  2022-11-23  6:55 ` Takashi Iwai
@ 2022-11-23  7:06   ` butt3rflyh4ck
  2022-11-23  7:17     ` Takashi Iwai
  0 siblings, 1 reply; 4+ messages in thread
From: butt3rflyh4ck @ 2022-11-23  7:06 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: perex, tiwai, baolin.wang, alsa-devel, linux-kernel

Hi, the compat_status structure is struct compat_snd_rawmidi_status64 {
s32 stream;
u8 rsvd[4]; /* alignment */
s64 tstamp_sec;
s64 tstamp_nsec;
u32 avail;
u32 xruns;
unsigned char reserved[16];
} __attribute__((packed));
The rsvd[4] and reserved[16] are not  initialized.


Regards,
 butt3rflyh4ck.

On Wed, Nov 23, 2022 at 2:55 PM Takashi Iwai <tiwai@suse.de> wrote:
>
> On Wed, 23 Nov 2022 06:09:11 +0100,
> Xiaolong Huang wrote:
> >
> > The compat_status is declared off of the stack, so it needs to
> > be zeroed out before copied back to userspace to prevent any
> > unintentional data leakage.
> >
> > Fixes: d9e5582c4bb2 ("ALSA: Avoid using timespec for struct snd_rawmidi_status")
> > Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
> >
> > ---
> >
> > Reason for resend:
> > 1. add Fixes line.
> > ---
> >  sound/core/rawmidi_compat.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
> > index 68a93443583c..6afa68165b17 100644
> > --- a/sound/core/rawmidi_compat.c
> > +++ b/sound/core/rawmidi_compat.c
> > @@ -80,6 +80,7 @@ static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
> >       if (err < 0)
> >               return err;
> >
> > +     memset(&compat_status, 0, sizeof(compat_status));
> >       compat_status = (struct compat_snd_rawmidi_status64) {
> >               .stream = status.stream,
> >               .tstamp_sec = status.tstamp_sec,
>
> Here at the line just after your addition, compat_status is fully
> initialized by substitution, so I believe the memset is superfluous.
>
> Or have you verified that it really leaks the uninitialized memory?
>
>
> thanks,
>
> Takashi



-- 
Active Defense Lab of Venustech

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64
  2022-11-23  7:06   ` butt3rflyh4ck
@ 2022-11-23  7:17     ` Takashi Iwai
  0 siblings, 0 replies; 4+ messages in thread
From: Takashi Iwai @ 2022-11-23  7:17 UTC (permalink / raw)
  To: butt3rflyh4ck; +Cc: perex, tiwai, baolin.wang, alsa-devel, linux-kernel

On Wed, 23 Nov 2022 08:06:16 +0100,
butt3rflyh4ck wrote:
> 
> Hi, the compat_status structure is struct compat_snd_rawmidi_status64 {
> s32 stream;
> u8 rsvd[4]; /* alignment */
> s64 tstamp_sec;
> s64 tstamp_nsec;
> u32 avail;
> u32 xruns;
> unsigned char reserved[16];
> } __attribute__((packed));
> The rsvd[4] and reserved[16] are not  initialized.

Other members are initialized with zero.
  https://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.html


Takashi

> 
> 
> Regards,
>  butt3rflyh4ck.
> 
> On Wed, Nov 23, 2022 at 2:55 PM Takashi Iwai <tiwai@suse.de> wrote:
> >
> > On Wed, 23 Nov 2022 06:09:11 +0100,
> > Xiaolong Huang wrote:
> > >
> > > The compat_status is declared off of the stack, so it needs to
> > > be zeroed out before copied back to userspace to prevent any
> > > unintentional data leakage.
> > >
> > > Fixes: d9e5582c4bb2 ("ALSA: Avoid using timespec for struct snd_rawmidi_status")
> > > Signed-off-by: Xiaolong Huang <butterflyhuangxx@gmail.com>
> > >
> > > ---
> > >
> > > Reason for resend:
> > > 1. add Fixes line.
> > > ---
> > >  sound/core/rawmidi_compat.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > >
> > > diff --git a/sound/core/rawmidi_compat.c b/sound/core/rawmidi_compat.c
> > > index 68a93443583c..6afa68165b17 100644
> > > --- a/sound/core/rawmidi_compat.c
> > > +++ b/sound/core/rawmidi_compat.c
> > > @@ -80,6 +80,7 @@ static int snd_rawmidi_ioctl_status_compat64(struct snd_rawmidi_file *rfile,
> > >       if (err < 0)
> > >               return err;
> > >
> > > +     memset(&compat_status, 0, sizeof(compat_status));
> > >       compat_status = (struct compat_snd_rawmidi_status64) {
> > >               .stream = status.stream,
> > >               .tstamp_sec = status.tstamp_sec,
> >
> > Here at the line just after your addition, compat_status is fully
> > initialized by substitution, so I believe the memset is superfluous.
> >
> > Or have you verified that it really leaks the uninitialized memory?
> >
> >
> > thanks,
> >
> > Takashi
> 
> 
> 
> -- 
> Active Defense Lab of Venustech
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-11-23  7:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-23  5:09 [RESEND PATCH] ALSA: rawmidi: fix infoleak in snd_rawmidi_ioctl_status_compat64 Xiaolong Huang
2022-11-23  6:55 ` Takashi Iwai
2022-11-23  7:06   ` butt3rflyh4ck
2022-11-23  7:17     ` Takashi Iwai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox