Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp1839524iob; Thu, 5 May 2022 09:08:30 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzUTCHumgPBlC6NthABTB1bvM3AgPuOWWVO7PEd5pNA29ZlCEKFxTQlWRx4Vs2Tk9lIvJlB X-Received: by 2002:aa7:d70a:0:b0:425:e56d:c1b9 with SMTP id t10-20020aa7d70a000000b00425e56dc1b9mr30751516edq.78.1651766910518; Thu, 05 May 2022 09:08:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651766910; cv=none; d=google.com; s=arc-20160816; b=z3Q9m7xSkKBElqXY+dBrbkgeCZnpjeseDdA5RAXOfW8mSLa2UUD2KB+g1bhmDDricE ebthMtlVhbci3V1cdt1ZDhzWRh0d2k7PsPElsHRslMxruD48bEpqQVSWP/EvYcEy9W33 Dz9W8ZST8vhbcQGCW/mMnzAcRZfQWIm13xu6jE6EPyu8dJT/VVP3zbnh+/IlU2Qiu/gs cRctS78QiR2AVoeQZQ65I08Q4z+bfouDp62OMRdTArRFle/4lnDkPBom4QXhg60v9vl8 4KeODGnHFSY7dMuOuW0fBuTAuxM738KbNN1xNAxMhXoIpQbOaKKKsH5rvZdohIWQUeGf w9+g== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rNowNYNn9ne7NeU36o6vTv3ohKD4ZVECHoyCD2VXnnw=; b=UUliSfh3144JBjeVh/OTTn8DXKaORdKi8kG3NbYYWL1rPNSbjQRJ9A+J+A9NGZi4Kj S5xUMV3mdQbi5AQ7qcgz2PJOGoIWTKPF+ke+Vt/wvZ/RLWKOx1xLmUjmxdJZqlF6DmM4 LkI9gdV3HMv75jPC6HooLuCMZTLARxvQinU7R1YU/oCJ25mWzf+G1fNMJhwKdWSpe3qd xLonEY+P6B8zcP3f+5niYMA2l98pYYX6GP1Icq/VYzqr87RyR+ETUu18VxSsZEl7qO4a 1DH6dNdJR6i/LQIGNRf8fVNyG08cZgkLUnNKNhpT/rwCuyc8oos1rnTNscUB5OYZ3vH7 8MjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n1i7ZbIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ch9-20020a0564021bc900b00425ffedf73asi2080426edb.223.2022.05.05.09.08.06; Thu, 05 May 2022 09:08:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=n1i7ZbIG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355106AbiEDRVk (ORCPT + 99 others); Wed, 4 May 2022 13:21:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51462 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355704AbiEDREj (ORCPT ); Wed, 4 May 2022 13:04:39 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4E2B4F45A; Wed, 4 May 2022 09:53:15 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 55CDE616F8; Wed, 4 May 2022 16:53:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id ACA1FC385AA; Wed, 4 May 2022 16:53:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683194; bh=2AHMO1rt09lcgtSq7YM7IIDJOOXaAVwLycWd1FnTCxA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n1i7ZbIGgTpEcOjXxyGJne/zTlTB3TvrK+iNXRhJ0MQcEMvyvlXFpdEU42y45RlSp 1HPDfGgTSXtv5P6I4Z75MI2c+IvPXohVQ2wUXhXyopC7ojFwBHbKo6pK7hIelqZmWL TdjNBDGCpz2bVZz0EzLFMdrK0E7DT2G3JKjJAlyI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Pavel Skripkin , Helge Deller , Sasha Levin , syzbot+53ce4a4246d0fe0fee34@syzkaller.appspotmail.com Subject: [PATCH 5.15 047/177] video: fbdev: udlfb: properly check endpoint type Date: Wed, 4 May 2022 18:44:00 +0200 Message-Id: <20220504153057.147274575@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Pavel Skripkin [ Upstream commit aaf7dbe07385e0b8deb7237eca2a79926bbc7091 ] syzbot reported warning in usb_submit_urb, which is caused by wrong endpoint type. This driver uses out bulk endpoint for communication, so let's check if this endpoint is present and bail out early if not. Fail log: usb 1-1: BOGUS urb xfer, pipe 3 != type 1 WARNING: CPU: 0 PID: 4822 at drivers/usb/core/urb.c:493 usb_submit_urb+0xd27/0x1540 drivers/usb/core/urb.c:493 Modules linked in: CPU: 0 PID: 4822 Comm: kworker/0:3 Tainted: G W 5.13.0-syzkaller #0 ... Workqueue: usb_hub_wq hub_event RIP: 0010:usb_submit_urb+0xd27/0x1540 drivers/usb/core/urb.c:493 ... Call Trace: dlfb_submit_urb+0x89/0x160 drivers/video/fbdev/udlfb.c:1969 dlfb_set_video_mode+0x21f0/0x2950 drivers/video/fbdev/udlfb.c:315 dlfb_ops_set_par+0x2a3/0x840 drivers/video/fbdev/udlfb.c:1110 dlfb_usb_probe.cold+0x113e/0x1f4a drivers/video/fbdev/udlfb.c:1732 usb_probe_interface+0x315/0x7f0 drivers/usb/core/driver.c:396 Fixes: 88e58b1a42f8 ("Staging: add udlfb driver") Reported-and-tested-by: syzbot+53ce4a4246d0fe0fee34@syzkaller.appspotmail.com Signed-off-by: Pavel Skripkin Signed-off-by: Helge Deller Signed-off-by: Sasha Levin --- drivers/video/fbdev/udlfb.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/udlfb.c b/drivers/video/fbdev/udlfb.c index 90f48b71fd8f..d9eec1b60e66 100644 --- a/drivers/video/fbdev/udlfb.c +++ b/drivers/video/fbdev/udlfb.c @@ -1649,8 +1649,9 @@ static int dlfb_usb_probe(struct usb_interface *intf, const struct device_attribute *attr; struct dlfb_data *dlfb; struct fb_info *info; - int retval = -ENOMEM; + int retval; struct usb_device *usbdev = interface_to_usbdev(intf); + struct usb_endpoint_descriptor *out; /* usb initialization */ dlfb = kzalloc(sizeof(*dlfb), GFP_KERNEL); @@ -1664,6 +1665,12 @@ static int dlfb_usb_probe(struct usb_interface *intf, dlfb->udev = usb_get_dev(usbdev); usb_set_intfdata(intf, dlfb); + retval = usb_find_common_endpoints(intf->cur_altsetting, NULL, &out, NULL, NULL); + if (retval) { + dev_err(&intf->dev, "Device should have at lease 1 bulk endpoint!\n"); + goto error; + } + dev_dbg(&intf->dev, "console enable=%d\n", console); dev_dbg(&intf->dev, "fb_defio enable=%d\n", fb_defio); dev_dbg(&intf->dev, "shadow enable=%d\n", shadow); @@ -1673,6 +1680,7 @@ static int dlfb_usb_probe(struct usb_interface *intf, if (!dlfb_parse_vendor_descriptor(dlfb, intf)) { dev_err(&intf->dev, "firmware not recognized, incompatible device?\n"); + retval = -ENODEV; goto error; } @@ -1686,8 +1694,10 @@ static int dlfb_usb_probe(struct usb_interface *intf, /* allocates framebuffer driver structure, not framebuffer memory */ info = framebuffer_alloc(0, &dlfb->udev->dev); - if (!info) + if (!info) { + retval = -ENOMEM; goto error; + } dlfb->info = info; info->par = dlfb; -- 2.35.1