Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11812723pjo; Thu, 2 Jan 2020 14:43:15 -0800 (PST) X-Google-Smtp-Source: APXvYqw8gOSuWkVj/JoeCR2J0pSSFZVLGRELr/2SQk9eeTHkgwiwSNNf5F5Mzquowcp1ZIxBn0dv X-Received: by 2002:a05:6830:4ca:: with SMTP id s10mr55615283otd.268.1578004995550; Thu, 02 Jan 2020 14:43:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004995; cv=none; d=google.com; s=arc-20160816; b=Tz1D+xW9k2ezSfWEiBMw5p5mxsa17/QB3nUjy/19uslx2UWbqU2ZOmxhr7lomnAsAf p/LYxwrSA5mSe/uHlK0dD8PvX2StKOeQSe2/CGanZODFZMksybyib1GAtnP/JRLVCvdU aNMEMrujpV6/oQVCdboWYy3VsLqgaToz6ZAnUxHKPo9mkdbNibFLChFm4Ajz8NPwT5Gq yq7+5QixcQ6kXJQGmnuMci689kMseq6sEJrjrMNMucPkc8TlomTCrK3Py7WWttsspVL4 HMXij/czRXAD/fU71iYtYwRQjKTnrz00MfAauGy51ofBKnkNFGnyO7j8MSKeOwkG7ZsX 3FeA== 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=b8E2rpEClTkKV1d7a6/RInFtQUxI/J/SWpTQnH+TBtk=; b=nDt28zSa2NlaQcuUiQa42iv05J3nWKdQneDHzBt05rck/y+Mg1V2+DwVrLEnTHPbqu 67V0LQ4oYXTnmRDWCAbctXM6wkrpn0NH6/82QxkQTIniSFbC7WRS7x1Mw+p95hMPtyY4 X0RkxDfnSu3c4AphNIcMn3lwrEEimc5qmM1gI4EMdOs3j/YR3cP1QtdoLbDhImFkvmlo OLtUC11/N0fBhgEQwOBnyNkld8NgZ7uMUAtlTP1ReegGf51mubHZICciowSHw+CpK6Sh x8sFhAMmqy3NyEFDlcSdfOIDH1TJHVoUF+2Jb8GTj5UcPQUpiY870iDvIVJtaeWN1pW/ M9Bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=UXkPWD9U; 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 u16si27807136otq.92.2020.01.02.14.43.03; Thu, 02 Jan 2020 14:43:15 -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=UXkPWD9U; 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 S1730940AbgABWgj (ORCPT + 99 others); Thu, 2 Jan 2020 17:36:39 -0500 Received: from mail.kernel.org ([198.145.29.99]:48056 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730958AbgABWgg (ORCPT ); Thu, 2 Jan 2020 17:36:36 -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 1DD8021D7D; Thu, 2 Jan 2020 22:36:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004595; bh=wQT4xWXNIzsEabQI1mSrwFFkt4xowQeeU7x6mRr+IQY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UXkPWD9UMKSHZU8lvjIVrIAsY/SbyuRHmvYwvNbTYHEffX52Bf5ulUbss8Mrsv+by MF+o5fTQpjzMuqZ2xBqQVTYoDDfvcf0Uomj+z0twdacw5KQKdqOHmnEzDU203clMBo itUl/+NDWIf6PnEbhkYC+Z8GEW731BTWTjxQaQtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lionel Koenig , Takashi Iwai Subject: [PATCH 4.4 072/137] ALSA: pcm: Avoid possible info leaks from PCM stream buffers Date: Thu, 2 Jan 2020 23:07:25 +0100 Message-Id: <20200102220556.320922570@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.618583146@linuxfoundation.org> References: <20200102220546.618583146@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 @@ -587,6 +587,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) + memset(runtime->dma_area, 0, runtime->dma_bytes); + snd_pcm_timer_resolution_change(substream); snd_pcm_set_state(substream, SNDRV_PCM_STATE_SETUP);