Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp379465pxb; Mon, 25 Oct 2021 10:03:21 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUEZlmSCYTDgGUigVz5PRmR3euxE3X6ybW2lgoSWijxgvcxu9ZCPLUSnuyrzUH/+w1Vmlo X-Received: by 2002:a17:902:e808:b0:140:55fe:1b4e with SMTP id u8-20020a170902e80800b0014055fe1b4emr6648083plg.87.1635181400746; Mon, 25 Oct 2021 10:03:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635181400; cv=none; d=google.com; s=arc-20160816; b=TmdGzyBdASgmD9SU4y0IweCWOXlpS1Zu8aUOYNeKKVXtgDfUetQ8GPd96vXZcqwYbq MkcRdIelXLmAluWm9GX3BWwy8Au/tur0bUgUVwqsnniuRch22YexjpCpUnjcYzAo14Jb EQLffcXi0G9C/gEwaA1dyCQ2tbFs3tyaS5XMWkdXLpEAZeUAb/6BCWJa+cimHRtlYeZJ ShAbrOFwJ/1CccHnSfA1Ug0h5FiZvFcfT6/8W3vllpSxsL7kDeARYADrzlbHX8YyeAFO VjXaeT9ytDmpqYbffHqHzR8/hmQ7hs1LKtaQTwo10hnJFhQ9yZIB3xJett8OAguZOpqy cvdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ZN2jp/akJ59SBXChei91FoGIdvy9Rx8km8tt5hneH6k=; b=DPX1rf690eQT5ojMdHuWsuJvYHql0AnrPcarY1TEi99Y1cHCl0Frh0NvP2f0x59bUb jVyWodqC9P7WzOzDRJayHOk7+fyeZZE0pdIU40CGrVSzWlkMwIDfU6pjOmjM5Paf+YFU 3ertez0YV/0+rqLLzP6ggW51lAF3wgBv0+85U6gaCbPtM7gNql5zBMEti1+l1UnLqe6G vNCg9nBzeWKhke351QwyZDW84oovocJ0d5qen2pAeoecF1siv60rLGXCzPOVYxJbKVpv k9YaQvV+qPwvpGgma2w9Xr+tBI2wHDJS5FHZGb58727LpHn/U1GdBbqB7j8lQnuXE4Xn o/wg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnt8+Dk0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i11si2263965pgv.577.2021.10.25.10.03.00; Mon, 25 Oct 2021 10:03:20 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=gnt8+Dk0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234430AbhJYRDG (ORCPT + 99 others); Mon, 25 Oct 2021 13:03:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:55210 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234308AbhJYRCm (ORCPT ); Mon, 25 Oct 2021 13:02:42 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 470DE61027; Mon, 25 Oct 2021 17:00:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1635181220; bh=J53SVgf4soVTj6FbrdJgx/eoNqv9xruAKPf6vDcMeLI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gnt8+Dk08qy/wLddi/DWrDLQMkY5vXgH/7wLlD940ApZaIVJRMeAqa7Q50SpFFleU gE5f93gHEKpGQ3lxHGQ+iaVCCRiYdL4xvblLVQoME1NZ7w6BwLqq8j81iUZmPbgXJE AIh4Re/L7inHz9zn2Bmy/LU98MpzJQNB0aRFFAICtcjEdCB0imwoIhJV67zKePAuQA qlZ3fZKKg8lG5fsYoXQQamQj0fh68y2f+0j/NDB5NZm+6051QaLlzC2ne/OD1HdpFL fnBTyEVedfitr9nka6B/FU3aZfRlWbr1U/g1acOXiYrfeOteFd1z7aaxdYfJu9NriW FIzqNsQd0sA8g== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Oliver Neukum , syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com, Johan Hovold , Jakub Kicinski , Sasha Levin , davem@davemloft.net, netdev@vger.kernel.org, linux-usb@vger.kernel.org Subject: [PATCH AUTOSEL 5.14 17/18] usbnet: sanity check for maxpacket Date: Mon, 25 Oct 2021 12:59:30 -0400 Message-Id: <20211025165939.1393655-17-sashal@kernel.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211025165939.1393655-1-sashal@kernel.org> References: <20211025165939.1393655-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oliver Neukum [ Upstream commit 397430b50a363d8b7bdda00522123f82df6adc5e ] maxpacket of 0 makes no sense and oopses as we need to divide by it. Give up. V2: fixed typo in log and stylistic issues Signed-off-by: Oliver Neukum Reported-by: syzbot+76bb1d34ffa0adc03baa@syzkaller.appspotmail.com Reviewed-by: Johan Hovold Link: https://lore.kernel.org/r/20211021122944.21816-1-oneukum@suse.com Signed-off-by: Jakub Kicinski Signed-off-by: Sasha Levin --- drivers/net/usb/usbnet.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index 470e1c1e6353..54d78d2a6b5d 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c @@ -1788,6 +1788,10 @@ usbnet_probe (struct usb_interface *udev, const struct usb_device_id *prod) if (!dev->rx_urb_size) dev->rx_urb_size = dev->hard_mtu; dev->maxpacket = usb_maxpacket (dev->udev, dev->out, 1); + if (dev->maxpacket == 0) { + /* that is a broken device */ + goto out4; + } /* let userspace know we have a random address */ if (ether_addr_equal(net->dev_addr, node_id)) -- 2.33.0