linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 4.4.y] ALSA: pcm: Add missing copy ops check before clearing buffer
@ 2020-01-29  9:40 Takashi Iwai
  2020-01-29  9:55 ` Greg Kroah-Hartman
  0 siblings, 1 reply; 2+ messages in thread
From: Takashi Iwai @ 2020-01-29  9:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman; +Cc: Andreas Schneider, stable, linux-kernel

[ this is a fix specific to 4.4.y and 4.9.y stable trees;
  4.14.y and older already contain the right fix ]

The stable 4.4.y and 4.9.y backports of the upstream commit
add9d56d7b37 ("ALSA: pcm: Avoid possible info leaks from PCM stream
buffers") dropped the check of substream->ops->copy_user as copy_user
is a new member that isn't present in the older kernels.
Although upstream drivers should work without this NULL check, it may
cause a regression with a downstream driver that sets some
inaccessible address to runtime->dma_area, leading to a crash at
worst.

Since such drivers must have ops->copy member on older kernels instead
of ops->copy_user, this patch adds the missing check of ops->copy for
fixing the regression.

Reported-and-tested-by: Andreas Schneider <asn@cryptomilk.org>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/core/pcm_native.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c
index b9bfbf394959..59423576b1cc 100644
--- a/sound/core/pcm_native.c
+++ b/sound/core/pcm_native.c
@@ -588,7 +588,7 @@ static int snd_pcm_hw_params(struct snd_pcm_substream *substream,
 		runtime->boundary *= 2;
 
 	/* clear the buffer for avoiding possible kernel info leaks */
-	if (runtime->dma_area)
+	if (runtime->dma_area && !substream->ops->copy)
 		memset(runtime->dma_area, 0, runtime->dma_bytes);
 
 	snd_pcm_timer_resolution_change(substream);
-- 
2.16.4


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

* Re: [PATCH 4.4.y] ALSA: pcm: Add missing copy ops check before clearing buffer
  2020-01-29  9:40 [PATCH 4.4.y] ALSA: pcm: Add missing copy ops check before clearing buffer Takashi Iwai
@ 2020-01-29  9:55 ` Greg Kroah-Hartman
  0 siblings, 0 replies; 2+ messages in thread
From: Greg Kroah-Hartman @ 2020-01-29  9:55 UTC (permalink / raw)
  To: Takashi Iwai; +Cc: Andreas Schneider, stable, linux-kernel

On Wed, Jan 29, 2020 at 10:40:41AM +0100, Takashi Iwai wrote:
> [ this is a fix specific to 4.4.y and 4.9.y stable trees;
>   4.14.y and older already contain the right fix ]
> 
> The stable 4.4.y and 4.9.y backports of the upstream commit
> add9d56d7b37 ("ALSA: pcm: Avoid possible info leaks from PCM stream
> buffers") dropped the check of substream->ops->copy_user as copy_user
> is a new member that isn't present in the older kernels.
> Although upstream drivers should work without this NULL check, it may
> cause a regression with a downstream driver that sets some
> inaccessible address to runtime->dma_area, leading to a crash at
> worst.
> 
> Since such drivers must have ops->copy member on older kernels instead
> of ops->copy_user, this patch adds the missing check of ops->copy for
> fixing the regression.
> 
> Reported-and-tested-by: Andreas Schneider <asn@cryptomilk.org>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>

Thanks for the fix!

greg k-h

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

end of thread, other threads:[~2020-01-29  9:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-29  9:40 [PATCH 4.4.y] ALSA: pcm: Add missing copy ops check before clearing buffer Takashi Iwai
2020-01-29  9:55 ` Greg Kroah-Hartman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).