Received: by 2002:a89:413:0:b0:1fd:dba5:e537 with SMTP id m19csp761672lqs; Fri, 14 Jun 2024 05:12:23 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCURbNs3Lg999w0pKS2C8NnCwAyg/sMWAgLhbgsW37OYCHvj2YLxpNatcFxOKUj7j8xJHTwCNiupBdR03CTAcAxmY3YnpH2ZHlif8jCoaQ== X-Google-Smtp-Source: AGHT+IEQLbm4SoIBGXEHrxmVUrfPc2OQPcWai+pztu/I2OgKTQNGunAoOEx7OCIbtXpyH4wwowLS X-Received: by 2002:a05:6870:c1d5:b0:254:a2c2:d3cc with SMTP id 586e51a60fabf-258428eb0f2mr2547169fac.19.1718367142780; Fri, 14 Jun 2024 05:12:22 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1718367142; cv=pass; d=google.com; s=arc-20160816; b=M+MEWjqUQOeNoJRF/0uRiYwScNPweGBObFPhZEYRi5OxkJMPSDQAafb/SfuSw7IjuQ NnmWkZasWDV2wdWflkAc1VKrKLJIW/GkKhHYdbuSgPXFnyxhkWga/VUc12smPw0tD4bo lVx2cTcZRZxYzLGt1ztFSSuzCR0CiMTzmync3VHX1ii8GIJfx7WlcG4v8yPvplhUJSc2 XkOEs3TlwJbO2X9fQc+ALj/z8TRrpjgMCyTNg9QLaG0sR3V2mmbyIzYo5b/gLpZOW30S ex0zsswmOezDLvp0ayfcNfTK/kBrt6ztlkH7GMqtCzzKFRmgxmiCt6asFuWoHMvnIa82 l57Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:lines:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=BwzEWjXCK6myqlQKfDxnUD1XW0gpk02wLeM9imSjpZ0=; fh=30kAIi1NdsW8hSJDysA0Ql9bzFU2ikbrK8dU1BeLZYw=; b=JJvhRZuQWc8kD4y35OtnttPU0xNfW/roNJtM70rkr9osR9hvhuLgn/8eIVYquZ8rjJ l3xE2zA7jEOYtYxT/k6eZkQmotc4a6aUWjkoyGtncRt/HmX8uCy87cgzPtRosolNBGhp I9zSiVNOp9khFD7BpJBLNpuAW4/dant1Ei51O48zuSVTxQ+vwxILzmC2o+hFWs5wUDJ7 Ucxeu4r4Hy6pYKU8u91U8gq7dVp7oEClojsebccxn/HHe+OcWj4UBGi271fbXfEaYmgc HWKVLbPdarkiVLS/JinN76Ab+ejwk0h3tbPSoH/PO+F7OuAICjJxs2hnbmobeHqrrxil PUmA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtUsMvpw; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-214867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d75a77b69052e-441ef3ba0c9si39453581cf.73.2024.06.14.05.12.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jun 2024 05:12:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-214867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=AtUsMvpw; arc=pass (i=1 dkim=pass dkdomain=linuxfoundation.org); spf=pass (google.com: domain of linux-kernel+bounces-214867-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-214867-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 7543A1C225B1 for ; Fri, 14 Jun 2024 12:12:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7DF8219885E; Fri, 14 Jun 2024 12:12:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="AtUsMvpw" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A2401192B98; Fri, 14 Jun 2024 12:12:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718367120; cv=none; b=tceOUbNcbnYVNz8Yn5x/YQEBId67Y91J/GOAx+Fp6HymFeMJTw2nWmszcrcUTzoD+X5LW90N8ZGjZ03/1mrgvgnzlYstN+d5STBIjP2WBtUg+0E/FEJq6Ll0lznC1rTBTIvo8BpjJZCiT+qRubhF6yuoGrUdWBB2BMWVBb7FoB0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1718367120; c=relaxed/simple; bh=cfWpz8K6Dhi/7RRbosYXUfONYA0Zam7ELSgNheWH0eI=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=n1vTeMXH77slfl0Nb2TCOw7b+EpQC0915urlpVe5XBFPGb7XmrH81zxCeBb4BXBSHIYu6PfdLLWodwtsDw21ceY2CFqAC0MrwOOmsXgUVjvDpvdBGEsRl5OqHUYi0h2v359CH1gXBLxfNn2B6i3oRtw9NBzqoLRcbXdn7kyph2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=AtUsMvpw; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7930C3277B; Fri, 14 Jun 2024 12:11:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1718367120; bh=cfWpz8K6Dhi/7RRbosYXUfONYA0Zam7ELSgNheWH0eI=; h=From:To:Cc:Subject:Date:From; b=AtUsMvpw303xpZIkpsVX1syK+ppUFSw67MySIsF+YHcwG7MJFbzUEOovzjBxzRkjO wiB+2EhnF5qpDNxb6W3e7Vc4CHaaEUi2KrA18f4QiMTCqGxHyz5JOePrTYP6r/oLqF i7f9KYpKc4xUeQoYVi37QEPKrKcouSXQc63FZeNE= From: Greg Kroah-Hartman To: linux-usb@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Greg Kroah-Hartman , Johan Hovold , Alan Stern , Grant Grundler , Yajun Deng , Oliver Neukum , Douglas Anderson Subject: [PATCH 1/4] USB: make to_usb_driver() use container_of_const() Date: Fri, 14 Jun 2024 14:11:49 +0200 Message-ID: <2024061448-manly-universal-00ad@gregkh> X-Mailer: git-send-email 2.45.2 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Lines: 58 X-Developer-Signature: v=1; a=openpgp-sha256; l=2166; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=cfWpz8K6Dhi/7RRbosYXUfONYA0Zam7ELSgNheWH0eI=; b=owGbwMvMwCRo6H6F97bub03G02pJDGk5xq0ssWK8l2oXzT61grv3u8RLm8L5Vk0GTp9M7DcI+ qs8vHioI5aFQZCJQVZMkeXLNp6j+ysOKXoZ2p6GmcPKBDKEgYtTACZSZ8swz1RWcaX+hPnuYvEb 67sXRfnPu/swhGG+b98B35nJz/Sbl82qPlPFdv2X+6RGAA== X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit Turns out that we have some const pointers being passed to to_usb_driver() but were not catching this. Change the macro to properly propagate the const-ness of the pointer so that we will notice when we try to write to memory that we shouldn't be writing to. This requires fixing up the usb_match_dynamic_id() function as well, because it can handle a const * to struct usb_driver. Cc: Johan Hovold Cc: Alan Stern Cc: Grant Grundler Cc: Yajun Deng Cc: Oliver Neukum Cc: Douglas Anderson Cc: linux-usb@vger.kernel.org Signed-off-by: Greg Kroah-Hartman --- drivers/usb/core/driver.c | 4 ++-- include/linux/usb.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/usb/core/driver.c b/drivers/usb/core/driver.c index 8e9bafcd62c6..c985a272e552 100644 --- a/drivers/usb/core/driver.c +++ b/drivers/usb/core/driver.c @@ -229,7 +229,7 @@ static void usb_free_dynids(struct usb_driver *usb_drv) } static const struct usb_device_id *usb_match_dynamic_id(struct usb_interface *intf, - struct usb_driver *drv) + const struct usb_driver *drv) { struct usb_dynid *dynid; @@ -880,7 +880,7 @@ static int usb_device_match(struct device *dev, const struct device_driver *drv) } else if (is_usb_interface(dev)) { struct usb_interface *intf; - struct usb_driver *usb_drv; + const struct usb_driver *usb_drv; const struct usb_device_id *id; /* device drivers never match interfaces */ diff --git a/include/linux/usb.h b/include/linux/usb.h index 1913a13833f2..4390426973f4 100644 --- a/include/linux/usb.h +++ b/include/linux/usb.h @@ -1232,7 +1232,7 @@ struct usb_driver { unsigned int disable_hub_initiated_lpm:1; unsigned int soft_unbind:1; }; -#define to_usb_driver(d) container_of(d, struct usb_driver, driver) +#define to_usb_driver(d) container_of_const(d, struct usb_driver, driver) /** * struct usb_device_driver - identifies USB device driver to usbcore -- 2.45.2