Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp13471730ybl; Sun, 29 Dec 2019 12:42:44 -0800 (PST) X-Google-Smtp-Source: APXvYqyAYZczdpiEbOkQxkeDRvYF2HqHWZubEQTjuojdzyBxwmQt3iTfbb/9v1XK22BG+Lxdn4vx X-Received: by 2002:a9d:6045:: with SMTP id v5mr65868100otj.252.1577652164685; Sun, 29 Dec 2019 12:42:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1577652164; cv=none; d=google.com; s=arc-20160816; b=bl9PcIeQZuSK75vEfcm29u4wBeSL6AExOrSBzMgKKgRo5wwpJ+oHwrLBpeO35vrNsW poew3VRzkIkoqTxpO7/nQllar3XdsLHRLZ2+aERGMSOxqv51eD4BpSxtqHUvhHCK6OYh LYQACL7J0DwNaTiaXUctWObE1a8TIZ4TgMkJj3jMTCHmRO25GBccZKUs/MqBhcFmRoAo XqIPm9FjEbnlSHm+bnkovUC2OsC3sPLL8AA7o+36qEUcpRgxxgohCFS9XwKIIxhE6VBd kofWJxT73HIbW+8F+Rq+DvMYOAkxrTmwa6ZoJEJ8pi/LvrOCKdPoxBJLq7hqjs5ytN2s Ab5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=G5Ya6NNaH0gbu3p08iOJVXq2z7pYcz9BOB8P7LZ1W6U=; b=FAqQ5iDkuktBMS+45kxPXvgeew30w8r4OBg7TjiNYxw5EmMBlu9/NpoYE4RgGYHPAI gboyqW7/wjZxLb+mw9Lw+6ZsyymRWVaoNe8RGRItHqUi4unWT893+NpHttqZcjOv/d1I Bog70x2KrgPAypx7dUMZoFPZr7nLTKY0pXQ3SzD8SVhSdyCXsUbrKpi07lTXfGqf1yDB VZX6PIUsvR/twMRZPs6c5cNv5DiRMF73Kh0qhWmJqMTlyrumC4yuhsziUoDYLShHCNNz NGTn87G5O7/GKsQNl4PD2coBPx/1mgu5sGWyKWMdv7O7+D1h2vgLCcDm2oi4/0+J4cq4 84ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NwG7/hEP"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z22si14311892otq.94.2019.12.29.12.42.34; Sun, 29 Dec 2019 12:42:44 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="NwG7/hEP"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730403AbfL2RnB (ORCPT + 99 others); Sun, 29 Dec 2019 12:43:01 -0500 Received: from mail.kernel.org ([198.145.29.99]:49692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729136AbfL2Rmz (ORCPT ); Sun, 29 Dec 2019 12:42:55 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8B1F620718; Sun, 29 Dec 2019 17:42:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1577641375; bh=J011jsk8+8CVo/CuBSlInnxf+uzT+GCmNPqICo3oCT8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=NwG7/hEPlb3DAiDNiboaPAISkhEcYImA1VnDaWJceOAABKXIGbmVEGNmSlKeVTo1w q4enMdgruwaIS7U86wS6AD6KL2DL7KD1+RPy85zyV+OzWr2NRkG1CUKMBS5mFQ/f7p jae581v9qTPaC9Aj3T1kMBIWHlAFPL4x45ULLs18= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lionel Koenig , Takashi Iwai Subject: [PATCH 5.4 039/434] ALSA: pcm: Avoid possible info leaks from PCM stream buffers Date: Sun, 29 Dec 2019 18:21:32 +0100 Message-Id: <20191229172704.633648787@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191229172702.393141737@linuxfoundation.org> References: <20191229172702.393141737@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Takashi Iwai commit add9d56d7b3781532208afbff5509d7382fb6efe upstream. The current PCM code doesn't initialize explicitly the buffers allocated for PCM streams, hence it might leak some uninitialized kernel data or previous stream contents by mmapping or reading the buffer before actually starting the stream. Since this is a common problem, this patch simply adds the clearance of the buffer data at hw_params callback. Although this does only zero-clear no matter which format is used, which doesn't mean the silence for some formats, but it should be OK because the intention is just to clear the previous data on the buffer. Reported-by: Lionel Koenig Cc: Link: https://lore.kernel.org/r/20191211155742.3213-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/pcm_native.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c @@ -705,6 +705,10 @@ static int snd_pcm_hw_params(struct snd_ while (runtime->boundary * 2 <= LONG_MAX - runtime->buffer_size) runtime->boundary *= 2; + /* clear the buffer for avoiding possible kernel info leaks */ + if (runtime->dma_area && !substream->ops->copy_user) + memset(runtime->dma_area, 0, runtime->dma_bytes); + snd_pcm_timer_resolution_change(substream); snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);