Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp7150446ybi; Mon, 8 Jul 2019 15:39:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqwqZDPPLD2HLSIn8wKisRLLcd2ZjGO9DGgFTVSKeEpddHJsZ/iwn/KP/57xZcxynOVFvt8o X-Received: by 2002:a17:902:f082:: with SMTP id go2mr29048917plb.25.1562625579163; Mon, 08 Jul 2019 15:39:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562625579; cv=none; d=google.com; s=arc-20160816; b=gHd7Ci5UkmUMuO7lW7Y7QXPdmOOu4ulrVKEL/wH+aD2J+6CzPa+GTXt7aj7Fv1bAG2 f4yQv2mBwXc6vjeGDpdZhwqnaGBApJyi4IV7gak2yD75L8jGkBi/elmedFsqVfEu3nHh MX49KhQ/pBWBdKlHGNxf+Gz35mOiDbgQA8jhTrG4Sau05H5m1xv43HvZBImUYztZolyH 27kirrfkCbV/ZMe58OJN6HSTS0HUrY1p+ruU1W0kQgn3l58TggZq+Sui0TH8YpOEbP4N ob3RuNz22nQpOdjYj9BecIATueYCQJUlF1FIdaUSXdfz2SexiPSaC1/oaJzyH9zC/yh5 WUsQ== 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=gUdnGKh3HBWDGgf7FyyPxax80hNmqvXhvuioD7HrJ2nTJozwxujw+MycA9BZytu1Ze kA+rrEWbZrMDvMxiDBkWRC9wo2vzuS6Visq1Zf28vnFv+cZQxWVMQHgZuMzqeEIJfIEV hvZZQCcIEpohEfVbD/nOmgsIW+CLJcrFL7Jczo6s8fPhOqnj6Ozqyh+Hxch0Rw+qIpiH bI/DCrBHNvXp07JZzsldV7Uia0w3Yx3SV8SO9wD17IaipAzGVAqzt5OTuB9offm57EXw m/EFUhFMLa41UcV41BrPFl5aGxOhyG6G3zZUkqw/K0po9lrCgZY1yzZ1rk6+vFZzHJhS vlzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=VikKRbeS; 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 g8si743522pjp.57.2019.07.08.15.39.24; Mon, 08 Jul 2019 15:39:39 -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=VikKRbeS; 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 S2390333AbfGHPdU (ORCPT + 99 others); Mon, 8 Jul 2019 11:33:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:35334 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390326AbfGHPdS (ORCPT ); Mon, 8 Jul 2019 11:33:18 -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 C04F621738; Mon, 8 Jul 2019 15:33:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1562599997; bh=EnjuQiri8fxKmmSfNGNWGp7FDP1+lvBIO/dhJrFiXVU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VikKRbeSzgGM6NbRINVDDynKxWsWK1EclZmvODGIvyIFoSmbjD64a88gJEVRuRJfa rjVpxooVPyuZuS+o8xqrq6Ua1d55OZqZsmWbYe+oBBDLCTh66HexFS0m5W0+oMv6Mt k+gTKWm9aymdm9bKk3aGLOh//sMN1zSdq8Z0BOpU= 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 5.1 61/96] ALSA: line6: Fix write on zero-sized buffer Date: Mon, 8 Jul 2019 17:13:33 +0200 Message-Id: <20190708150529.781946993@linuxfoundation.org> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190708150526.234572443@linuxfoundation.org> References: <20190708150526.234572443@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);