Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp7721245ioo; Fri, 3 Jun 2022 12:02:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwf6fPyEUL33SBv3lEOeaktmbbA+91QyVrP7S5Hb83sN11uEWk31eVR813nYmo33ylqQb9F X-Received: by 2002:a05:6a00:a03:b0:51b:5131:704e with SMTP id p3-20020a056a000a0300b0051b5131704emr11596716pfh.53.1654282944192; Fri, 03 Jun 2022 12:02:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654282944; cv=none; d=google.com; s=arc-20160816; b=AsxJ6uFYcnjVeWEWifT0rZKtiwEUKTdTMmUN8Op4Z9001NbOLRMUlwrWNXxktnD1Mf Xi5dEk/TUomBdU4bJO9RGMM33cBnvaBSEXtjpEQMfrivSuIjxznW+saTZD5gpPCOP44p ib7UiGVK+/3STUO2Yb4HTQmiTLuq9Z+Myx3m+fxM8dE3VN6Iz1xHEoTGZsna+HmQPGZ2 WZXb9NvhsbOKdDtNqnPnmgtdp7S1f6xdJuu//w9QX27a7QLVdw6BX/pMrRy+UYBpqGJK 5ocIiwQ2vW01AUSOAHcWmOLCeXTXQPPYjRifsPv1z5zwBTudifETTEafC2NOUUviq2HW cIzw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=0MtylCBpbGINTJdwmGiKAHJvCn5tstrQu662d3dbhCY=; b=sZrNS0cIBSTEYiRBXWfCH2MulI05ddPISJBK3fU0LzNerda1dJs3Sl8mE0nIL+Nt5e xSufe2AZbLi4Zf6UasmZWbSQdvq1ED7YHkw5KlhG1Iase77MVag2UvssK9QzXFK5vcBL izQzIMy2Z8261I7BzFDPnNCVYRs/SDXhw/I8Yw2Dj9nq+VT3m1EU88MIJw4E322RCNXZ 11cfqsSZM7i0JB9lHwwp6i+jx3M9xQaGu6TJe0py9FXeMSP572ml1HmNZy0pY+AOksNS wsdgyLWa0+bKc/65RGQ1vPtLcXBbZknpOrwuZsWPv7/5LqPbiBnyNS2E8iabe+JJxQ5v 20ow== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h4-20020a170902b94400b0015e6330c0ecsi10023749pls.330.2022.06.03.12.02.09; Fri, 03 Jun 2022 12:02:24 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231150AbiFCPm0 (ORCPT + 99 others); Fri, 3 Jun 2022 11:42:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43286 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245625AbiFCPmX (ORCPT ); Fri, 3 Jun 2022 11:42:23 -0400 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 779769FD9 for ; Fri, 3 Jun 2022 08:42:19 -0700 (PDT) Received: (qmail 304861 invoked by uid 1000); 3 Jun 2022 11:42:19 -0400 Date: Fri, 3 Jun 2022 11:42:19 -0400 From: Alan Stern To: Andy Shevchenko Cc: syzbot , gregkh@linuxfoundation.org, hdanton@sina.com, lenb@kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, rafael.j.wysocki@intel.com, rafael@kernel.org, rjw@rjwysocki.net, syzkaller-bugs@googlegroups.com, linux-usb@vger.kernel.org Subject: Re: [syzbot] general protection fault in __device_attach Message-ID: References: <000000000000bb7f1c05da29b601@google.com> <00000000000010b7d305e08837c8@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=no 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 On Fri, Jun 03, 2022 at 02:04:04PM +0300, Andy Shevchenko wrote: > On Fri, Jun 03, 2022 at 03:02:07AM -0700, syzbot wrote: > > syzbot has bisected this issue to: > > > > commit a9c4cf299f5f79d5016c8a9646fa1fc49381a8c1 > > Author: Andy Shevchenko > > Date: Fri Jun 18 13:41:27 2021 +0000 > > > > ACPI: sysfs: Use __ATTR_RO() and __ATTR_RW() macros > > Hmm... It's not obvious at all how this change can alter the behaviour so > drastically. device_add() is called from USB core with intf->dev.name == NULL > by some reason. A-ha, seems like fault injector, which looks like > > dev_set_name(&intf->dev, "%d-%s:%d.%d", dev->bus->busnum, > dev->devpath, configuration, ifnum); > > missed the return code check. > > But I'm not familiar with that code at all, adding Linux USB ML and Alan. I can't see any connection between this bug and acpi/sysfs.c. Is it a bad bisection? It looks like you're right about dev_set_name() failing. In fact, the kernel appears to be littered with calls to that routine which do not check the return code (the entire subtree below drivers/usb/ contains only _one_ call that does check the return code!). The function doesn't have any __must_check annotation, and its kerneldoc doesn't mention the return code or the possibility of a failure. Apparently the assumption is that if dev_set_name() fails then device_add() later on will also fail, and the problem will be detected then. So now what should happen when device_add() for an interface fails in usb_set_configuration()? I guess the interface should be deleted; otherwise we have the possibility that people might still try to access it via usbfs, as in the syzbot test run. Same goes for the of_device_is_available() check. Fixing that will be a little painful. Right now there are plenty of places in the USB core that aren't prepared to cope with a non-existent interface. Alan Stern