Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2573991yba; Mon, 6 May 2019 08:12:03 -0700 (PDT) X-Google-Smtp-Source: APXvYqwtJIb21eAI+oeoYuG9AmpS4rPLj1Rtx4PFEgJ+8XxTX53Guvb0KW5caQFDhiMifJeWEGz/ X-Received: by 2002:a65:534b:: with SMTP id w11mr32607662pgr.210.1557155523611; Mon, 06 May 2019 08:12:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557155523; cv=none; d=google.com; s=arc-20160816; b=WxehHYDoeHvvsDfbtMmFrsePkToRMY/zHKqTwkSI89KiT0cg9WyKfzxhWi4BFPBUJq 59I29XuQyGxP7VeyzfrOsuWVeSmXbwmvoz+CiLZslfR9HZY6wEMrGu12h6YQQ85fyF7m D+EBmOz5jWoP6uMcWrSFWXLB9HNmYL7D9ToHczWVx7kd5SPqqQ4JE+QoQlJtxfogFOyn 5mya4gXCuN3xW6WSkbndCwMeb/ikIHmhX78W51MSmHUjT7LHM0BOKEKmMkU0sje5I3M3 mTzUJ0RZX3hA8bnBltEsCLzN6F069wI91abtattYmDPjVdQQ4jaADBPIx5Q4vyfytOJu eZVQ== 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=6u6plbf5FIKFBXH9g1UX7tqlvYWDlxFcwscaJrWdg/w=; b=dy2Z7knBYoVyYqVhMt2Ew2CxIN+9IyQGC9eZlbH4m9MMyEyma8UqIesARpb1jXiTsD 90cGoPCmp2O32U0JAWPpJi7WDXWXn++JGbHrcD0i2JNO01ew+EYeEP/tqSUJbLb63OvI 7O2CfNbO2+O8MLBeik/8m4F2zoIDS39DytGYIBmD5+KXuPIyAZybvcHt+m9rNyB5zM0i i5PK+NvoL2hfyV5dA0gZDdmqP43rvYZrZD+mfTFmfMHqHtH+y4ftAA1MSl7eyroH44qx 6T4f5+eJUmrVUD6F3AkA228UAhyVZin61JR39n4yBlnb0tVvCyPkyFCq6evKZ3I4g2ya EZ8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HmvWzvGU; 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 f11si13015128pgl.539.2019.05.06.08.11.47; Mon, 06 May 2019 08:12:03 -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=HmvWzvGU; 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 S1726484AbfEFOeC (ORCPT + 99 others); Mon, 6 May 2019 10:34:02 -0400 Received: from mail.kernel.org ([198.145.29.99]:53536 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726094AbfEFOeB (ORCPT ); Mon, 6 May 2019 10:34:01 -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 2E2D9204EC; Mon, 6 May 2019 14:34:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1557153240; bh=7ZemQmt0cOHyrYretRO4V8+S59a+oJa/34ZCLJ348R4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HmvWzvGU1oHBCftzHw5pSyFL9JhDRuo9yPnlADw72TCtAXgUqOVqGt7PpYqTmjy2E OAIvaP+MV35XHIpUd4Gf8wY7Q7nwsKIGv/jXX43/M9BxuIr/qMkWK3R/1tou2SuUUl SCSYPIPIKoeJednK+4tlfTr0p+/WTqM03OXr4q/I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alan Stern , syzbot+d65f673b847a1a96cdba@syzkaller.appspotmail.com Subject: [PATCH 5.0 015/122] USB: w1 ds2490: Fix bug caused by improper use of altsetting array Date: Mon, 6 May 2019 16:31:13 +0200 Message-Id: <20190506143056.112875886@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190506143054.670334917@linuxfoundation.org> References: <20190506143054.670334917@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: Alan Stern commit c114944d7d67f24e71562fcfc18d550ab787e4d4 upstream. The syzkaller USB fuzzer spotted a slab-out-of-bounds bug in the ds2490 driver. This bug is caused by improper use of the altsetting array in the usb_interface structure (the array's entries are not always stored in numerical order), combined with a naive assumption that all interfaces probed by the driver will have the expected number of altsettings. The bug can be fixed by replacing references to the possibly non-existent intf->altsetting[alt] entry with the guaranteed-to-exist intf->cur_altsetting entry. Signed-off-by: Alan Stern Reported-and-tested-by: syzbot+d65f673b847a1a96cdba@syzkaller.appspotmail.com CC: Signed-off-by: Greg Kroah-Hartman --- drivers/w1/masters/ds2490.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) --- a/drivers/w1/masters/ds2490.c +++ b/drivers/w1/masters/ds2490.c @@ -1016,15 +1016,15 @@ static int ds_probe(struct usb_interface /* alternative 3, 1ms interrupt (greatly speeds search), 64 byte bulk */ alt = 3; err = usb_set_interface(dev->udev, - intf->altsetting[alt].desc.bInterfaceNumber, alt); + intf->cur_altsetting->desc.bInterfaceNumber, alt); if (err) { dev_err(&dev->udev->dev, "Failed to set alternative setting %d " "for %d interface: err=%d.\n", alt, - intf->altsetting[alt].desc.bInterfaceNumber, err); + intf->cur_altsetting->desc.bInterfaceNumber, err); goto err_out_clear; } - iface_desc = &intf->altsetting[alt]; + iface_desc = intf->cur_altsetting; if (iface_desc->desc.bNumEndpoints != NUM_EP-1) { pr_info("Num endpoints=%d. It is not DS9490R.\n", iface_desc->desc.bNumEndpoints);