Received: by 2002:a05:6358:16cd:b0:dc:6189:e246 with SMTP id r13csp783523rwl; Fri, 4 Nov 2022 06:24:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6EE1qZ8Z4G3oxRs6W6X1Q7YWrNmHeC9QQsuC3CYNx0xyePE8RQZ9j8TVz70SKOg6syAAVw X-Received: by 2002:a17:902:c745:b0:186:b287:7d02 with SMTP id q5-20020a170902c74500b00186b2877d02mr36036537plq.87.1667568295931; Fri, 04 Nov 2022 06:24:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1667568295; cv=none; d=google.com; s=arc-20160816; b=FfXHbzdMcTkG2zETwRutGGDzZ3MwO/KnU5r7tNVfBAWKSeIXBVnJEdVJNx7hi2hq2s uvk5P4/b/bpB5X44MeLyoCtPT3jAoFoYAdT+ws12eNEOCSvpe+Ew/yzIGSsZv70CuB8r l9KU/3t8JWXwaHG14d9DYLdOEmwXdyA4JfbH+rgJPcICudlYXUt/bRyVjni9cvuxq/XY 2f/S5z5WzfCgVyPv7+JW5VrdmSkeiiwkzBBUK/Qi5bKudQhytrofdMRYg73eshOJNecs JKFlXvEom1kPIAjO9wlyAb7tmNvko1FYo9AQ45R8xT+z1WTdxyPDF9a3+k4/jL/6X27L VT4A== 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 :message-id:date:subject:cc:to:from; bh=MwLGpjcwyH4beaI7rZFB9rCrPA6g2v12EdPo210+bi8=; b=Ooj224/mc32OIfChfUADPi846nHvB8i27ZbPWdV4sySgm9aURS3ceoYChuzDf9hu4o IyNnzf6weTwBdL7gBlpOugnFwX+L2y/lum7OatL6uIsCMHKdzfdGOu1bXAWqEhFWAZbn Xi7mza+xp9vH4ohWmqIdapCjzq9EbDqD4zDjfID2v8z3saNHlJvqlNXuTEpixeJg78ii qwBu+5j9PMV9bkYVx7CVq8qBUCD/VpJyfr6DQdMPdLDc9jTiJ5/eKmtpIhZEhQ9XheV/ OVlyfloSHdl7QN7d7djrb+yLQyevN/Q0H5wD8y45ZISedoat/MIhzXd+TJLXd+4icYbK X6bw== 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 p26-20020a056a000a1a00b00542c772d478si5536685pfh.247.2022.11.04.06.24.43; Fri, 04 Nov 2022 06:24:55 -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 S231838AbiKDNKq (ORCPT + 96 others); Fri, 4 Nov 2022 09:10:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231627AbiKDNKh (ORCPT ); Fri, 4 Nov 2022 09:10:37 -0400 Received: from metis.ext.pengutronix.de (metis.ext.pengutronix.de [IPv6:2001:67c:670:201:290:27ff:fe1d:cc33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CE02A28E0E for ; Fri, 4 Nov 2022 06:10:36 -0700 (PDT) Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.ext.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oqwSw-0000Yl-HE; Fri, 04 Nov 2022 14:10:34 +0100 Received: from [2a0a:edc0:0:1101:1d::28] (helo=dude02.red.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtp (Exim 4.94.2) (envelope-from ) id 1oqwSw-002HHi-Oq; Fri, 04 Nov 2022 14:10:33 +0100 Received: from sha by dude02.red.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1oqwSv-004041-3P; Fri, 04 Nov 2022 14:10:33 +0100 From: Sascha Hauer To: linux-usb@vger.kernel.org Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, kernel@pengutronix.de, Sascha Hauer Subject: [PATCH 0/2] use-after-free issues in configfs Date: Fri, 4 Nov 2022 14:10:29 +0100 Message-Id: <20221104131031.850850-1-s.hauer@pengutronix.de> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SA-Exim-Connect-IP: 2a0a:edc0:0:c01:1d::a2 X-SA-Exim-Mail-From: sha@pengutronix.de X-SA-Exim-Scanned: No (on metis.ext.pengutronix.de); SAEximRunCond expanded to false X-PTX-Original-Recipient: linux-kernel@vger.kernel.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 This series addresses a few problems with the users of the gether code. The problem arises when a UDC is disconnected from a gadget created with configfs doing a "echo '' > UDC". It seems the existing code is tested up to the point where the gadget from configfs is up, tearing it down still seems to make problems. I for myself am also not interested in tearing it down, but I see use-after-free issues when doing a reboot -f. The underlying problem is that the eth_dev returned by the gether code is used for multiple bind/unbind cycles, but only initialized properly once. The usb_gadget * is only valid between bind and unbind, so it is not a suitable parent for the net_device whose lifetime spans multiple bind/unbind cycles. I solved the issues for the f_ecm driver, similar problems exist in the other users like f_eem or f_ncm as well. I can prepare patches for these once it's clear that this is really the way to go. Sascha Hauer (2): usb: gadget: u_ether: Do not make UDC parent of the net device usb: gadget: f_ecm: Always set current gadget in ecm_bind() drivers/usb/gadget/function/f_ecm.c | 22 +++++++++------------- drivers/usb/gadget/function/u_ether.c | 4 ---- 2 files changed, 9 insertions(+), 17 deletions(-) -- 2.30.2