Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7149755ybi; Mon, 8 Jul 2019 15:38:43 -0700 (PDT) X-Google-Smtp-Source: APXvYqwOUOuVErlrcQIC9Qs28Hh0NWKbQ6HouL3rEGq1KD8LBUC1QBIWHFO2JaD83NbMI4dwpDHk X-Received: by 2002:a17:902:7d8b:: with SMTP id a11mr21140824plm.306.1562625523405; Mon, 08 Jul 2019 15:38:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625523; cv=none; d=google.com; s=arc-20160816; b=xyT6KvyGdZvBXvPnCQq9YngXsFam0cF2U82fdNjPH/pXh/XyU+azVa5WFtQ/hWm9Jl dw55v1DGwwu8FX9rKGg2xwzHo+XbkYqcsRcX4wRj140gF0PWv6M8LfyAV7YiWxlAf3QJ CH4OaIpfTpX4XNnvv+nuYGrVFRfNqOusugsoEmqQ74Pa2HnTKdNrhoFASa14G/11xZ4Q Y1RB6CCtey2SqULB+WZdrsiZczNNNlw7CDLqfCkaMSadKGLaAORXA5HwJiMyB/AbiUAI EpGqFwJQrV3wBpQDEeDIBGgys74LaOOz8CRjtrN87K9NgFI8SnwsWaiNe24u5c3B3DT6 kUuA== 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=jn5IAQ5lePnXSPzRh/dqcTeJu6T8fUzT5jZqOnhM19o=; b=s0QYdbUKehand1hTgCLoh3tQRpPrqaZik8E1/lYc7CL5uEm7qYBZ6WCINsxL3Vr1RX U+2luH2Fw8RMMmwXJYrlUoMg4j9JJyvhTsu36AfJH07KpCdmp5uaAZ6BCnRr+beQWEde dck91wi9JB7L6f2PeNqd9Fk/jgg+a6zFga1198IsCJKVaL5y74I7LOihofCiXVbpliSi AwbDBecXkjeLw4v9uyDy3dbnk1fuZ+4VyHwSQ6uIDv2FgcMsTRVPqPxq6gpHXiGs7y5s gYaw3f08OYjJTgBEw0Lq1Ok3oVXGEX4/o04XiWkLRhC+eCR42Y62N/JwoaJknVKqTTLW YHgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fJZrS3ng; 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 j10si19356420plg.71.2019.07.08.15.38.27; Mon, 08 Jul 2019 15:38:43 -0700 (PDT) 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=fJZrS3ng; 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 S2389592AbfGHPaY (ORCPT + 99 others); Mon, 8 Jul 2019 11:30:24 -0400 Received: from mail.kernel.org ([198.145.29.99]:59312 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389558AbfGHPaV (ORCPT ); Mon, 8 Jul 2019 11:30:21 -0400 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 AA15F20665; Mon, 8 Jul 2019 15:30:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599820; bh=EnjuQiri8fxKmmSfNGNWGp7FDP1+lvBIO/dhJrFiXVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fJZrS3ngWOqGRzilI8W3KW4AX1odMzvA+2OlAzrCEe5OcNrwIlFY8nM5VzjMkDGj/ EnCD7vTf9e7X9+aX+ShVI3KsiYEmevHwYVmAdLvzBCWcqMi0M5S5AetpkwxCEFuF2r jhX861oFqtWR2QCEbSgJHsCHU/O2Lk0/hqCM6zog= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, syzbot+219f00fb49874dcaea17@syzkaller.appspotmail.com, Takashi Iwai Subject: [PATCH 4.19 46/90] ALSA: line6: Fix write on zero-sized buffer Date: Mon, 8 Jul 2019 17:13:13 +0200 Message-Id: <20190708150524.894237413@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150521.829733162@linuxfoundation.org> References: <20190708150521.829733162@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 3450121997ce872eb7f1248417225827ea249710 upstream. LINE6 drivers allocate the buffers based on the value returned from usb_maxpacket() calls. The manipulated device may return zero for this, and this results in the kmalloc() with zero size (and it may succeed) while the other part of the driver code writes the packet data with the fixed size -- which eventually overwrites. This patch adds a simple sanity check for the invalid buffer size for avoiding that problem. Reported-by: syzbot+219f00fb49874dcaea17@syzkaller.appspotmail.com Cc: Signed-off-by: Takashi Iwai Signed-off-by: Greg Kroah-Hartman --- sound/usb/line6/pcm.c | 5 +++++ 1 file changed, 5 insertions(+) --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c @@ -560,6 +560,11 @@ int line6_init_pcm(struct usb_line6 *lin line6pcm->max_packet_size_out = usb_maxpacket(line6->usbdev, usb_sndisocpipe(line6->usbdev, ep_write), 1); + if (!line6pcm->max_packet_size_in || !line6pcm->max_packet_size_out) { + dev_err(line6pcm->line6->ifcdev, + "cannot get proper max packet size\n"); + return -EINVAL; + } spin_lock_init(&line6pcm->out.lock); spin_lock_init(&line6pcm->in.lock);