lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <58a73e70-565e-45e3-a1b5-3163978b7cea@ieee.org>
Date: Mon, 1 Jul 2024 07:21:41 -0500
From: Alex Elder <elder@...e.org>
To: Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
 linux-kernel@...r.kernel.org
Cc: "Rafael J. Wysocki" <rafael@...nel.org>
Subject: Re: [greybus-dev] [PATCH] driver core: have match() callback in
 struct bus_type take a const *

On 7/1/24 7:07 AM, Greg Kroah-Hartman wrote:
> In the match() callback, the struct device_driver * should not be
> changed, so change the function callback to be a const *.  This is one
> step of many towards making the driver core safe to have struct
> device_driver in read-only memory.
> 
> Because the match() callback is in all busses, all busses are modified
> to handle this properly.  This does entail switching some container_of()
> calls to container_of_const() to properly handle the constant *.
> 
> For some busses, like PCI and USB and HV, the const * is cast away in
> the match callback as those busses do want to modify those structures at
> this point in time (they have a local lock in the driver structure.)
> That will have to be changed in the future if they wish to have their
> struct device * in read-only-memory.
> 
> Cc: "Rafael J. Wysocki" <rafael@...nel.org>
> Signed-off-by: Greg Kroah-Hartman <gregkh@...uxfoundation.org>

For drivers/greybus/core.c, drivers/staging/greybus/gbphy.c, and
include/linux/greybus.h:

Reviewed-by: Alex Elder <elder@...nel.org>

> ---
>   - cc: list suppressed as it just touches too many different subsystems
>     at once, sorry.  I tried to hit all of the mailing lists as a bcc:
>     hopefully they don't reject it...
> 
>   arch/arm/common/locomo.c                      |  4 ++--
>   arch/arm/include/asm/hardware/locomo.h        |  2 +-
>   arch/parisc/include/asm/parisc-device.h       |  2 +-
>   arch/parisc/kernel/drivers.c                  |  4 ++--
>   arch/powerpc/include/asm/ps3.h                |  6 +-----
>   arch/powerpc/include/asm/vio.h                |  6 +-----
>   arch/powerpc/platforms/ps3/system-bus.c       |  4 ++--
>   arch/powerpc/platforms/pseries/ibmebus.c      |  2 +-
>   arch/powerpc/platforms/pseries/vio.c          |  6 +++---
>   arch/s390/include/asm/ccwdev.h                |  2 +-
>   arch/sparc/include/asm/vio.h                  |  6 +-----
>   arch/sparc/kernel/vio.c                       |  4 ++--
>   drivers/acpi/bus.c                            |  4 ++--
>   drivers/amba/bus.c                            |  6 +++---
>   drivers/base/auxiliary.c                      |  2 +-
>   drivers/base/base.h                           |  3 +--
>   drivers/base/cpu.c                            |  2 +-
>   drivers/base/isa.c                            |  2 +-
>   drivers/base/platform.c                       |  2 +-
>   drivers/bcma/main.c                           |  6 +++---
>   drivers/bus/fsl-mc/fsl-mc-bus.c               |  4 ++--
>   drivers/bus/mhi/ep/main.c                     |  4 ++--
>   drivers/bus/mhi/host/init.c                   |  4 ++--
>   drivers/bus/mips_cdmm.c                       |  6 +++---
>   drivers/bus/moxtet.c                          |  4 ++--
>   drivers/bus/sunxi-rsb.c                       |  2 +-
>   drivers/cdx/cdx.c                             |  4 ++--
>   drivers/cxl/core/port.c                       |  2 +-
>   drivers/cxl/cxl.h                             |  5 +----
>   drivers/dax/bus.c                             | 17 +++++++----------
>   drivers/dma/idxd/bus.c                        |  6 +++---
>   drivers/eisa/eisa-bus.c                       |  4 ++--
>   drivers/firewire/core-device.c                |  6 +++---
>   drivers/firmware/arm_ffa/bus.c                |  2 +-
>   drivers/firmware/arm_scmi/bus.c               |  6 +++---
>   drivers/firmware/google/coreboot_table.c      |  6 +++---
>   drivers/fpga/dfl.c                            |  4 ++--
>   drivers/fsi/fsi-core.c                        |  4 ++--
>   drivers/gpio/gpiolib.c                        |  2 +-
>   drivers/gpu/drm/display/drm_dp_aux_bus.c      |  2 +-
>   drivers/gpu/drm/drm_mipi_dsi.c                |  2 +-
>   drivers/gpu/host1x/bus.c                      |  2 +-
>   drivers/greybus/core.c                        |  4 ++--
>   drivers/hid/hid-core.c                        |  2 +-
>   drivers/hid/intel-ish-hid/ishtp/bus.c         |  2 +-
>   drivers/hsi/hsi_core.c                        |  2 +-
>   drivers/hv/vmbus_drv.c                        |  8 ++++----
>   drivers/hwtracing/intel_th/core.c             |  4 ++--
>   drivers/hwtracing/intel_th/intel_th.h         |  2 +-
>   drivers/i2c/i2c-core-base.c                   |  4 ++--
>   drivers/i3c/master.c                          |  4 ++--
>   drivers/input/gameport/gameport.c             |  4 ++--
>   drivers/input/rmi4/rmi_bus.c                  |  6 +++---
>   drivers/input/rmi4/rmi_bus.h                  |  2 +-
>   drivers/input/rmi4/rmi_driver.c               |  2 +-
>   drivers/input/rmi4/rmi_driver.h               |  2 +-
>   drivers/input/serio/serio.c                   |  4 ++--
>   drivers/ipack/ipack.c                         |  6 +++---
>   drivers/macintosh/macio_asic.c                |  2 +-
>   drivers/mcb/mcb-core.c                        |  4 ++--
>   drivers/media/pci/bt8xx/bttv-gpio.c           |  4 ++--
>   drivers/media/pci/bt8xx/bttv.h                |  2 +-
>   drivers/memstick/core/memstick.c              |  7 +++----
>   drivers/mfd/mcp-core.c                        |  2 +-
>   drivers/misc/mei/bus.c                        |  4 ++--
>   drivers/misc/tifm_core.c                      |  6 +++---
>   drivers/mmc/core/sdio_bus.c                   | 10 +++++-----
>   drivers/most/core.c                           |  2 +-
>   drivers/net/phy/mdio_bus.c                    |  4 ++--
>   drivers/net/phy/mdio_device.c                 |  4 ++--
>   drivers/net/phy/phy_device.c                  |  4 ++--
>   drivers/ntb/ntb_transport.c                   |  2 +-
>   drivers/nvdimm/bus.c                          |  6 +++---
>   drivers/nvmem/layouts.c                       |  4 ++--
>   drivers/pci/endpoint/pci-epf-core.c           |  4 ++--
>   drivers/pci/pci-driver.c                      |  8 ++++----
>   drivers/pcmcia/ds.c                           |  2 +-
>   drivers/peci/core.c                           |  4 ++--
>   drivers/peci/internal.h                       |  5 +----
>   drivers/platform/surface/aggregator/bus.c     |  4 ++--
>   drivers/platform/x86/wmi.c                    |  9 +++------
>   drivers/pnp/driver.c                          |  6 +++---
>   drivers/rapidio/rio-driver.c                  |  4 ++--
>   drivers/rpmsg/rpmsg_core.c                    |  4 ++--
>   drivers/rpmsg/rpmsg_internal.h                |  2 +-
>   drivers/s390/cio/css.c                        |  4 ++--
>   drivers/s390/cio/css.h                        |  2 +-
>   drivers/s390/cio/device.c                     |  4 ++--
>   drivers/s390/crypto/ap_bus.c                  |  4 ++--
>   drivers/s390/crypto/ap_bus.h                  |  2 +-
>   drivers/scsi/fcoe/fcoe_sysfs.c                |  2 +-
>   drivers/scsi/scsi_sysfs.c                     |  6 +++---
>   drivers/scsi/scsi_transport_iscsi.c           |  2 +-
>   drivers/sh/maple/maple.c                      |  4 ++--
>   drivers/siox/siox-core.c                      |  2 +-
>   drivers/slimbus/core.c                        |  4 ++--
>   drivers/soc/qcom/apr.c                        |  4 ++--
>   drivers/soundwire/bus_type.c                  |  6 +++---
>   drivers/spi/spi.c                             |  2 +-
>   drivers/spmi/spmi.c                           |  2 +-
>   drivers/ssb/main.c                            |  4 ++--
>   .../staging/fieldbus/anybuss/anybuss-client.h |  6 +-----
>   drivers/staging/fieldbus/anybuss/host.c       |  4 ++--
>   drivers/staging/greybus/gbphy.c               |  2 +-
>   .../interface/vchiq_arm/vchiq_bus.c           |  2 +-
>   drivers/staging/vme_user/vme.c                |  2 +-
>   drivers/tc/tc-driver.c                        |  6 +++---
>   drivers/tee/tee_core.c                        |  2 +-
>   drivers/thunderbolt/domain.c                  |  8 ++++----
>   drivers/tty/serdev/core.c                     |  2 +-
>   drivers/tty/serial/serial_base_bus.c          |  2 +-
>   drivers/usb/common/ulpi.c                     |  2 +-
>   drivers/usb/core/driver.c                     |  2 +-
>   drivers/usb/gadget/udc/core.c                 |  2 +-
>   drivers/usb/serial/bus.c                      |  2 +-
>   drivers/usb/typec/bus.c                       |  2 +-
>   drivers/vdpa/vdpa.c                           |  2 +-
>   drivers/vfio/mdev/mdev_driver.c               |  2 +-
>   drivers/virtio/virtio.c                       |  2 +-
>   drivers/xen/xenbus/xenbus.h                   |  2 +-
>   drivers/xen/xenbus/xenbus_probe.c             |  4 ++--
>   include/acpi/acpi_bus.h                       |  2 +-
>   include/linux/arm_ffa.h                       |  2 +-
>   include/linux/cdx/cdx_bus.h                   |  2 +-
>   include/linux/device/bus.h                    |  2 +-
>   include/linux/dfl.h                           |  2 +-
>   include/linux/eisa.h                          |  2 +-
>   include/linux/fsi.h                           |  2 +-
>   include/linux/fsl/mc.h                        |  2 +-
>   include/linux/gameport.h                      |  2 +-
>   include/linux/greybus.h                       |  2 +-
>   include/linux/hyperv.h                        |  6 +-----
>   include/linux/i2c.h                           |  2 +-
>   include/linux/i3c/device.h                    |  5 +----
>   include/linux/maple.h                         |  2 +-
>   include/linux/mcb.h                           |  5 +----
>   include/linux/mdio.h                          | 19 ++++++-------------
>   include/linux/mhi.h                           |  2 +-
>   include/linux/mhi_ep.h                        |  2 +-
>   include/linux/moxtet.h                        |  9 ++-------
>   include/linux/nd.h                            |  6 +-----
>   include/linux/pci-epf.h                       |  3 +--
>   include/linux/pci.h                           |  6 ++----
>   include/linux/phy.h                           |  2 +-
>   include/linux/pnp.h                           |  2 +-
>   include/linux/rio.h                           |  2 +-
>   include/linux/scmi_protocol.h                 |  2 +-
>   include/linux/serio.h                         |  2 +-
>   include/linux/slimbus.h                       |  2 +-
>   include/linux/soc/qcom/apr.h                  |  2 +-
>   include/linux/soundwire/sdw_type.h            |  2 +-
>   include/linux/spi/spi.h                       |  6 ++----
>   include/linux/ssb/ssb.h                       |  2 +-
>   include/linux/tc.h                            |  2 +-
>   include/linux/tee_drv.h                       |  2 +-
>   include/linux/virtio.h                        |  5 +----
>   include/scsi/scsi_transport_iscsi.h           |  2 +-
>   include/sound/ac97/codec.h                    |  5 +----
>   include/xen/xenbus.h                          |  5 +----
>   net/iucv/iucv.c                               |  2 +-
>   sound/ac97/bus.c                              |  4 ++--
>   sound/core/seq_device.c                       |  4 ++--
>   sound/hda/hda_bus_type.c                      |  2 +-
>   163 files changed, 268 insertions(+), 338 deletions(-)
> 

. . .

> diff --git a/drivers/greybus/core.c b/drivers/greybus/core.c
> index 95c09d4f3a86..c5569563bd03 100644
> --- a/drivers/greybus/core.c
> +++ b/drivers/greybus/core.c
> @@ -90,9 +90,9 @@ greybus_match_id(struct gb_bundle *bundle, const struct greybus_bundle_id *id)
>   	return NULL;
>   }
>   
> -static int greybus_match_device(struct device *dev, struct device_driver *drv)
> +static int greybus_match_device(struct device *dev, const struct device_driver *drv)
>   {
> -	struct greybus_driver *driver = to_greybus_driver(drv);
> +	const struct greybus_driver *driver = to_greybus_driver(drv);
>   	struct gb_bundle *bundle;
>   	const struct greybus_bundle_id *id;
>   

. . .

> diff --git a/drivers/staging/greybus/gbphy.c b/drivers/staging/greybus/gbphy.c
> index d827f03f5253..fe4f76da7f9c 100644
> --- a/drivers/staging/greybus/gbphy.c
> +++ b/drivers/staging/greybus/gbphy.c
> @@ -117,7 +117,7 @@ gbphy_dev_match_id(struct gbphy_device *gbphy_dev,
>   	return NULL;
>   }
>   
> -static int gbphy_dev_match(struct device *dev, struct device_driver *drv)
> +static int gbphy_dev_match(struct device *dev, const struct device_driver *drv)
>   {
>   	struct gbphy_driver *gbphy_drv = to_gbphy_driver(drv);
>   	struct gbphy_device *gbphy_dev = to_gbphy_dev(dev);

. . .

> diff --git a/include/linux/greybus.h b/include/linux/greybus.h
> index 634c9511cf78..4d58e27ceaf6 100644
> --- a/include/linux/greybus.h
> +++ b/include/linux/greybus.h
> @@ -64,7 +64,7 @@ struct greybus_driver {
>   
>   	struct device_driver driver;
>   };
> -#define to_greybus_driver(d) container_of(d, struct greybus_driver, driver)
> +#define to_greybus_driver(d) container_of_const(d, struct greybus_driver, driver)
>   
>   static inline void greybus_set_drvdata(struct gb_bundle *bundle, void *data)
>   {

. . .


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ