Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp771963ybl; Wed, 11 Dec 2019 07:17:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyjvi9kRL4KHQyfjc0hdAz3BAXZq2KbTChU4Qtz55W9RnubcRTlEPI/5MDWyMuV6ppaIfFF X-Received: by 2002:a9d:6396:: with SMTP id w22mr2705038otk.364.1576077452275; Wed, 11 Dec 2019 07:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576077452; cv=none; d=google.com; s=arc-20160816; b=tsDB/PhpAYTshWT/zmqB3vgNcGZIfsKL6RwHh9r892Zb3hiYr8wfQ7eiBucoOJurLe RR7v18Zq1ChWfxrN0pXq3bBrS/nTnt3UTxAeGmmipKyeCe/IVmhS6JcieSmmHaCFjhvk i7qBhzTNEOMpu3zzD8cn7/Ec2PeLeKBoZ9L8ERtV61zfbV//mI43vO0V2bqbwfqkfHiV +iceI5sm30N/Tw1uFKKyoHNi4Sigmjrp4BG3RCDLsTuoWzJBRTK0y6WEBA98VCq90CVb Lmkk4R/DbS/6b75N3aGSwue568jrw52Bc4NJfj4/zzp5QdwA+wh2McAbZArKmK4+OdB9 4gQw== 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=U6QVAq+dPvNSjjFqJbIm/gXu1marvnGKYgD6JqglpxM=; b=D3tOIlUODSbx8+XnECmk0VDBRUZANCu/ZOxuDLOPAuGOdNuHvTzkuny3guc27CsUK9 u25TJ34jR90thU7BZLR1e6fdlJMbbrC3IK2lpGQ6MJ0Pbw2lH5UT8sHhS/F1/E7OSDxD ijl4i+8YtNsR9UPLDp5yhQi374rQNQaE5L9H8B/tkpioLCKj+jfuu7mKsOAqzM98+M8j lGvGJynDVivpQkVKiD/l6AxuDISzHzzbcjqOC2P8wryp9BTx2ILsET7K2IFkuLfRb7G8 8y88yyieHPp0/QieVEAaQR1TiyR4oEIAj59S29OpnIvKFKRgKISGh6sbIo/lKu26uR7j fv3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=o+3jEwiw; 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 e21si1276418oti.246.2019.12.11.07.17.20; Wed, 11 Dec 2019 07:17:32 -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=o+3jEwiw; 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 S1731814AbfLKPPf (ORCPT + 99 others); Wed, 11 Dec 2019 10:15:35 -0500 Received: from mail.kernel.org ([198.145.29.99]:40552 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731361AbfLKPOw (ORCPT ); Wed, 11 Dec 2019 10:14:52 -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 C5B7224654; Wed, 11 Dec 2019 15:14:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576077292; bh=YOOKKu7KZKalCYc9fcrbvluf+Q6hWobR9h7/kUaryYI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=o+3jEwiwdJ2g0AyOfNiD/Mms1tYw6G1+y8ubosNd1c0Y8fokbNVW86/7/85zfO/un 0aO7ESl2yTE5V4F6J7D+DXOR5OwZH/+BrURFyLYhj7tScRL1AMuSXvSXzkBvv0I8Oy 5z7nZ79by/0y53250TBXGpnnTl8KNs+RLnyeLw8E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+f153bde47a62e0b05f83@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 5.3 052/105] ALSA: pcm: oss: Avoid potential buffer overflows Date: Wed, 11 Dec 2019 16:05:41 +0100 Message-Id: <20191211150242.347949603@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191211150221.153659747@linuxfoundation.org> References: <20191211150221.153659747@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 4cc8d6505ab82db3357613d36e6c58a297f57f7c upstream. syzkaller reported an invalid access in PCM OSS read, and this seems to be an overflow of the internal buffer allocated for a plugin. Since the rate plugin adjusts its transfer size dynamically, the calculation for the chained plugin might be bigger than the given buffer size in some extreme cases, which lead to such an buffer overflow as caught by KASAN. Fix it by limiting the max transfer size properly by checking against the destination size in each plugin transfer callback. Reported-by: syzbot+f153bde47a62e0b05f83@syzkaller.appspotmail.com Cc: Link: https://lore.kernel.org/r/20191204144824.17801-1-tiwai@suse.de Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/core/oss/linear.c | 2 ++ sound/core/oss/mulaw.c | 2 ++ sound/core/oss/route.c | 2 ++ 3 files changed, 6 insertions(+) --- a/sound/core/oss/linear.c +++ b/sound/core/oss/linear.c @@ -107,6 +107,8 @@ static snd_pcm_sframes_t linear_transfer } } #endif + if (frames > dst_channels[0].frames) + frames = dst_channels[0].frames; convert(plugin, src_channels, dst_channels, frames); return frames; } --- a/sound/core/oss/mulaw.c +++ b/sound/core/oss/mulaw.c @@ -269,6 +269,8 @@ static snd_pcm_sframes_t mulaw_transfer( } } #endif + if (frames > dst_channels[0].frames) + frames = dst_channels[0].frames; data = (struct mulaw_priv *)plugin->extra_data; data->func(plugin, src_channels, dst_channels, frames); return frames; --- a/sound/core/oss/route.c +++ b/sound/core/oss/route.c @@ -57,6 +57,8 @@ static snd_pcm_sframes_t route_transfer( return -ENXIO; if (frames == 0) return 0; + if (frames > dst_channels[0].frames) + frames = dst_channels[0].frames; nsrcs = plugin->src_format.channels; ndsts = plugin->dst_format.channels;