Received: by 2002:a5d:9c59:0:0:0:0:0 with SMTP id 25csp95475iof; Sun, 5 Jun 2022 22:12:56 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxskuvP3objvsJFfCBh5qZVm6OktQK78LNBOlKk108x/vvOnGv9C9S5kestKuDwESDIDZnr X-Received: by 2002:a63:4e0a:0:b0:3fd:b97e:36e9 with SMTP id c10-20020a634e0a000000b003fdb97e36e9mr3676448pgb.545.1654492375742; Sun, 05 Jun 2022 22:12:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654492375; cv=none; d=google.com; s=arc-20160816; b=LccOx7APLnttQnugsmlkGl+o+l/nZqmY2Lu8RXd88sKTsDdtNtGLirz25gbDnnAUvk oYRyMozs4rqhUewsZQYRjpGJeO+Zx5Wy2TM+MrtC7sO8lYUPCsov6awoL2hressdMyJs OkkCos+u5O5L5k2dq5X5/n4PnWSP99RExBSCqVhX5eL9XheoUO3GAm8qWJ5jLjTzEr1S eaItWe9Cn+BDaz6rQIEJ03XY9+6edbbgzJIZXBe6KgeaZztLo8Zja5sK6U4aj7Ex8ow1 nIKXDrjDNPTDP11BykSmf04gm2o8hqQAtzaiySWApT6xSIutG16LIKmIRA1C45Mjcwmi CT0g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=pqFZxA/HqywLfblJN7LT8qYahRL42XkEnGb9VnbgV1g=; b=YMfiDV8yTIvjg//VY0mJ3m2rP2ARtzz070/A3aYmBNi7rYqlfa4bc5Gsu8uIlkQ+Jv PLLl4a7288+pjUfwLt3JWVGOW57fahsasiHAvZCu5EsnRSa2SCoiIMRlnthaQa0jRX2j 3dFVCtRB2rZE20NS7uGSqBkuDnzn4ixYfctTkRu98UA/feyHDx+Khsxq66Y3FUio2g44 GxpRI8CUPgrXeqC1QZlIHc8HyoW84fOV8oyJFW3poV5OGUQxiAndWSSFb/WMyD8+RtqI sqlIlqhIsQMtTqDqVzKZOcIE4Osz1q+bPQNPCt27Nx1bR7hRIZ/d6Xj5DCTY24aJVtTJ 4sTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aMEmcO6O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id g8-20020a170902d5c800b001678898e70bsi295127plh.223.2022.06.05.22.12.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 05 Jun 2022 22:12:55 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=aMEmcO6O; spf=softfail (google.com: domain of transitioning linux-kernel-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 1FA3814FCA0; Sun, 5 Jun 2022 21:18:41 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232801AbiFDIdE (ORCPT + 99 others); Sat, 4 Jun 2022 04:33:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233244AbiFDIdD (ORCPT ); Sat, 4 Jun 2022 04:33:03 -0400 Received: from mail-lj1-x233.google.com (mail-lj1-x233.google.com [IPv6:2a00:1450:4864:20::233]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BE4CB1C108 for ; Sat, 4 Jun 2022 01:33:00 -0700 (PDT) Received: by mail-lj1-x233.google.com with SMTP id v9so10741417lja.12 for ; Sat, 04 Jun 2022 01:33:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=pqFZxA/HqywLfblJN7LT8qYahRL42XkEnGb9VnbgV1g=; b=aMEmcO6OUIvyzU0QCRHAQvI5GA7hvngQ+sQz4uJXxdYQ5GseqCH0wcQ91mZhWkVDes R63LqGXxkNB6k3TsarhUAu3Q//MR8HC/ewzyA2xJlNCFYP7aZuKGDPLXi047xRDql/to CJyREh+7nU5rml8U8fSWfBRxdhy5+fJAJc1O+t+lI6HFLDZr4/JRdop4EH2MgIKPwwsc RmDVoRf20N/S8dcUWxIrSnIonfVYi7E8IueQUwVVY/UPsPke89ekYlBwdrPnME40H00f 00EUNIHn6555Iydgnl2YAVLUPSOFALYjuUE3GN9s4L6ZWXV1puwUjKoL2pfb/xQcWQYO fnUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=pqFZxA/HqywLfblJN7LT8qYahRL42XkEnGb9VnbgV1g=; b=aP+ip7zV49ozhSzZIvsoqT3twsFkHHiVlf93VGiEB3VvQHt3w+zS/bkzjA7FlrZsjT zmmBJwNBcy5UNEAnS+1F97w963UDGCS4ZmQSoDNVhGm8NDU2ILLVV5uk4/pHPjv8NzFk R2MRCnAQmE7c+yHXdRwzKCeouGRrvo9gjkpSkk0k/MbYvpudnkbp5wZw0ftMxl1zYsJJ QhjO9kYEKsufrkb0NvT2Oz04+wm7w+E+ctkNFfLsT6o9G7ZMgNG7tf6zVEnS+8bn/2Zl 5YoPEg6Z4gg+vcLBPxskpxtw1Q0YfwfgaKq16QHuPExt3ac7ZeeVlvKWqIXM9I7CDwRr EFVQ== X-Gm-Message-State: AOAM531Q4hCxAvD05widFKsrJaX5KK9OqQa3JM5McZ7GbyIWc2P0iBmp 46VsmmWquk2DMxStQ58bK4373O701VszE0OMtZorEw== X-Received: by 2002:a05:651c:1797:b0:254:1a3a:801a with SMTP id bn23-20020a05651c179700b002541a3a801amr27436272ljb.363.1654331578574; Sat, 04 Jun 2022 01:32:58 -0700 (PDT) MIME-Version: 1.0 References: <000000000000bb7f1c05da29b601@google.com> <00000000000010b7d305e08837c8@google.com> In-Reply-To: From: Dmitry Vyukov Date: Sat, 4 Jun 2022 10:32:46 +0200 Message-ID: Subject: Re: [syzbot] general protection fault in __device_attach To: Greg KH Cc: Alan Stern , Andy Shevchenko , syzbot , 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-9.5 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE, USER_IN_DEF_DKIM_WL 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, 3 Jun 2022 at 18:12, Greg KH 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()? > > > > > > But how can that really fail on a real system? > > > > > > Is this just due to error-injection stuff? If so, I'm really loath to > > > rework the world for something that can never happen in real life. > > > > > > Or is this a real syzbot-found-with-reproducer issue? > > > > Aren't there quite a few reasons why device_add() might fail? (Although > > most of them probably are memory allocation errors...) > > I was thinking of the dev_set_name() issue further back in the call > chain. > > > Basically, you have to make up your mind. If a function can fail, you > > should be prepared to handle the failure. If it can't fail, there's no > > point in even checking the return code. > > True, ok, we should unwind the mess. I'll try to look at it after the > merge window... > > But again, is this a "real and able to be triggered from userspace" > problem, or just fault-injection-induced? Then this is something to fix in the fault injection subsystem. Testing systems shouldn't be reporting false positives. What allocations cannot fail in real life? Is it <=page_size?