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: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aSgUpIGfpYXgH1-X@tom-desktop>
Date: Thu, 27 Nov 2025 10:07:23 +0100
From: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>
To: Jian Hui Lee <jianhui.lee@...onical.com>
Cc: andi.shyti@...nel.org, arnd@...db.de, biju.das.jz@...renesas.com,
	conor+dt@...nel.org, devicetree@...r.kernel.org,
	fabrizio.castro.jz@...esas.com, geert+renesas@...der.be,
	gregkh@...uxfoundation.org, jonathan.cameron@...wei.com,
	kishon@...nel.org, krzk+dt@...nel.org, linux-kernel@...r.kernel.org,
	linux-phy@...ts.infradead.org, linux-renesas-soc@...r.kernel.org,
	magnus.damm@...il.com, p.zabel@...gutronix.de, peda@...ntia.se,
	prabhakar.mahadev-lad.rj@...renesas.com, robh@...nel.org,
	sebastian.reichel@...labora.com, tomm.merciai@...il.com,
	ukleinek@...nel.org, vkoul@...nel.org,
	yoshihiro.shimoda.uh@...esas.com
Subject: Re: [PATCH v4 06/22] mux: Add driver for Renesas RZ/V2H USB VBUS_SEL
 mux

Hi Jian,
Thanks for your comments!

On Thu, Nov 27, 2025 at 10:28:41AM +0800, Jian Hui Lee wrote:
> On Fri, Nov 21, 2025 at 04:11:55PM +0100, Tommaso Merciai wrote:
> > As per the RZ/V2H(P) HW manual, VBUSEN can be controlled by the VBUS_SEL
> > bit of the VBENCTL Control Register. This register is mapped in the
> > reset framework. The reset driver expose this register as mux-controller
> > and instantiates this driver. The consumer will use the mux API to
> > control the VBUS_SEL bit.
> > 
> > Signed-off-by: Tommaso Merciai <tommaso.merciai.xr@...renesas.com>
> > ---
> > v3->v4:
> >  - Removed mux_chip->dev.of_node not needed.
> > 
> > v2->v3:
> >  - Added mux_chip->dev.of_node = dev->of_node->child as the mux-controller
> >    is an internal node.
> >  - Fixed auxiliary_device_id name.
> >  - Get rdev using from platform_data.
> >  - Drop struct auxiliary_device adev from reset_rzv2h_usb2phy_adev
> >    as it is needed.
> >  - Drop to_reset_rzv2h_usb2phy_adev() as it is not needed.
> > 
> > v1->v2:
> >  - New patch
> > 
> >  drivers/mux/Kconfig                       | 10 +++
> >  drivers/mux/Makefile                      |  2 +
> >  drivers/mux/rzv2h-usb-vbus.c              | 97 +++++++++++++++++++++++
> >  include/linux/reset/reset_rzv2h_usb2phy.h | 11 +++
> >  4 files changed, 120 insertions(+)
> >  create mode 100644 drivers/mux/rzv2h-usb-vbus.c
> >  create mode 100644 include/linux/reset/reset_rzv2h_usb2phy.h
> > 
> > diff --git a/drivers/mux/Kconfig b/drivers/mux/Kconfig
> > index c68132e38138..604f625544ed 100644
> > --- a/drivers/mux/Kconfig
> > +++ b/drivers/mux/Kconfig
> > @@ -59,4 +59,14 @@ config MUX_MMIO
> >  	  To compile the driver as a module, choose M here: the module will
> >  	  be called mux-mmio.
> >  
> > +config MUX_RZV2H_VBENCTL
> > +	tristate "Renesas RZ/V2H USB VBUS mux driver"
> > +	depends on RESET_RZV2H_USB2PHY || COMPILE_TEST
> > +	depends on OF
> > +	select REGMAP_MMIO
> > +	select AUXILIARY_BUS
> > +	default RESET_RZV2H_USB2PHY
> > +	help
> > +	  Support for VBUS mux implemented on Renesas RZ/V2H SoCs.
> > +
> >  endmenu
> > diff --git a/drivers/mux/Makefile b/drivers/mux/Makefile
> > index 6e9fa47daf56..9421660399af 100644
> > --- a/drivers/mux/Makefile
> > +++ b/drivers/mux/Makefile
> > @@ -8,9 +8,11 @@ mux-adg792a-objs		:= adg792a.o
> >  mux-adgs1408-objs		:= adgs1408.o
> >  mux-gpio-objs			:= gpio.o
> >  mux-mmio-objs			:= mmio.o
> > +mux-rzv2h-usb-vbus-objs		:= rzv2h-usb-vbus.o
> >  
> >  obj-$(CONFIG_MULTIPLEXER)	+= mux-core.o
> >  obj-$(CONFIG_MUX_ADG792A)	+= mux-adg792a.o
> >  obj-$(CONFIG_MUX_ADGS1408)	+= mux-adgs1408.o
> >  obj-$(CONFIG_MUX_GPIO)		+= mux-gpio.o
> >  obj-$(CONFIG_MUX_MMIO)		+= mux-mmio.o
> > +obj-$(CONFIG_MUX_RZV2H_VBENCTL)	+= mux-rzv2h-usb-vbus.o
> > diff --git a/drivers/mux/rzv2h-usb-vbus.c b/drivers/mux/rzv2h-usb-vbus.c
> > new file mode 100644
> > index 000000000000..9513bc8f35ff
> > --- /dev/null
> > +++ b/drivers/mux/rzv2h-usb-vbus.c
> > @@ -0,0 +1,97 @@
> > +// SPDX-License-Identifier: GPL-2.0
> > +/*
> > + * Renesas RZ/V2H(P) USB2 VBUS_SEL mux driver
> > + *
> > + * Copyright (C) 2025 Renesas Electronics Corp.
> > + */
> > +
> > +#include <linux/auxiliary_bus.h>
> > +#include <linux/bitops.h>
> > +#include <linux/err.h>
> > +#include <linux/module.h>
> > +#include <linux/mux/driver.h>
> > +#include <linux/of.h>
> > +#include <linux/property.h>
> > +#include <linux/regmap.h>
> > +#include <linux/reset/reset_rzv2h_usb2phy.h>
> > +
> > +#define RZV2H_VBENCTL		0xf0c
> > +
> > +struct mux_rzv2h_usb_vbus_priv {
> > +	struct regmap_field *field;
> > +};
> > +
> > +static int mux_rzv2h_usb_vbus_set(struct mux_control *mux, int state)
> > +{
> > +	struct mux_rzv2h_usb_vbus_priv *priv = mux_chip_priv(mux->chip);
> > +
> > +	return regmap_field_write(priv->field, state);
> > +}
> > +
> > +static const struct mux_control_ops mux_rzv2h_usb_vbus_ops = {
> > +	.set = mux_rzv2h_usb_vbus_set,
> > +};
> > +
> > +static const struct regmap_config rzv2h_usb_vbus_regconf = {
> > +	.reg_bits = 32,
> > +	.val_bits = 32,
> > +	.reg_stride = 4,
> > +	.max_register = RZV2H_VBENCTL,
> > +};
> > +
> > +static int mux_rzv2h_usb_vbus_probe(struct auxiliary_device *adev,
> > +				    const struct auxiliary_device_id *id)
> > +{
> > +	struct reset_rzv2h_usb2phy_adev *rdev = adev->dev.platform_data;
> > +	struct mux_rzv2h_usb_vbus_priv *priv;
> > +	struct device *dev = &adev->dev;
> > +	struct mux_chip *mux_chip;
> > +	struct regmap *regmap;
> > +	struct reg_field reg_field = {
> > +		.reg = RZV2H_VBENCTL,
> > +		.lsb = 0,
> > +		.msb = 0,
> > +	};
> > +	int ret;
> > +
> > +	regmap = devm_regmap_init_mmio(dev, rdev->base, &rzv2h_usb_vbus_regconf);
> > +	if (IS_ERR(regmap))
> > +		return PTR_ERR(regmap);
> > +
> > +	mux_chip = devm_mux_chip_alloc(dev, 1, sizeof(*priv));
> > +	if (IS_ERR(mux_chip))
> > +		return PTR_ERR(mux_chip);
> > +
> > +	priv = mux_chip_priv(mux_chip);
> > +
> > +	priv->field = devm_regmap_field_alloc(dev, regmap, reg_field);
> > +	if (IS_ERR(priv->field))
> > +		return PTR_ERR(priv->field);
> > +
> > +	mux_chip->ops = &mux_rzv2h_usb_vbus_ops;
> > +	mux_chip->mux[0].states = 2;
> > +	mux_chip->mux[0].idle_state = MUX_IDLE_AS_IS;
> > +
> > +	ret = devm_mux_chip_register(dev, mux_chip);
> > +	if (ret < 0)
> > +		return dev_err_probe(dev, ret, "Failed to register mux chip\n");
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct auxiliary_device_id mux_rzv2h_usb_vbus_ids[] = {
> > +	{ .name = "rzv2h_usb2phy_reset.vbus-sel-mux" },
> 
> hi Tommaso,
> this string causes buffer overflow, could you help to check on it?

I'll send v5 with:

	{ .name = "rzv2h_usb2phy_reset.vbenctl" },

in v5.
Thank you!


Kind Regards,
Tommaso

> 
> [   15.349036] strlen: detected buffer overflow: 33 byte read of buffer size 32
> [   15.349083] WARNING: CPU: 0 PID: 518 at lib/string_helpers.c:1035 __fortify_report+0x64/0xc8
> [   15.349110] Modules linked in: mux_rzv2h_usb_vbus(+) rcar_canfd(+) mtd sm4_ce(-) can_dev rz_dmac(+) pwm_rzg2l_gpt binfmt_misc dm_multipath efi_pstore nfnetlink ip_tables x_tables autofs4 btrfs blake2b_generic raid10 raid456 async_raid6_recov async_memcpy async_pq async_xor async_tx xor xor_neon raid6_pq raid1 raid0 linear rtc_isl1208 micrel phy_package mmc_block raa215300 rpmb_core dwmac_renesas_gbeth spi_rpc_if pcs_rzn1_miic stmmac_platform stmmac polyval_ce renesas_sdhi_internal_dmac renesas_usbhs ghash_ce panfrost udc_core pcs_xpcs renesas_sdhi_core reset_rzv2h_usb2phy gpu_sched tmio_mmc_core xhci_rcar_hcd ehci_platform sm4 phy_rzg3e_usb3 phy_rcar_gen3_usb2 rzv2m_usb3drd xhci_plat_hcd ohci_platform renesas_rpc_if i2c_riic gpio_regulator gpio_keys fixed aes_neon_bs aes_neon_blk aes_ce_blk aes_ce_cipher
> [   15.349359] CPU: 0 UID: 0 PID: 518 Comm: (udev-worker) Not tainted 6.18.0-5.5 #3 PREEMPT(voluntary)
> [   15.349371] Hardware name: Renesas SMARC EVK version 2 based on r9a09g047e57 (DT)
> [   15.349380] pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [   15.349390] pc : __fortify_report+0x64/0xc8
> [   15.349400] lr : __fortify_report+0x64/0xc8
> [   15.349408] sp : ffff8000854fb830
> [   15.349413] x29: ffff8000854fb830 x28: ffff80007c7a41d8 x27: ffff80007c7a4300
> [   15.349430] x26: ffff800083c4d780 x25: 0000000000000000 x24: ffff0000c5de9de8
> [   15.349446] x23: ffff800081d23b68 x22: ffff0000c004b200 x21: ffff0000ca6dd080
> [   15.349462] x20: 0000000000000020 x19: ffff80007c7a6140 x18: ffff800084b870a8
> [   15.349477] x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000000
> [   15.349492] x14: 0000000000000000 x13: 323320657a697320 x12: 7265666675622066
> [   15.349507] x11: 0000000000000000 x10: 0000000000000000 x9 : ffff800080208f0c
> [   15.349522] x8 : 0000000000000000 x7 : 0000000000000000 x6 : 0000000000000000
> [   15.349536] x5 : 0000000000000000 x4 : 0000000000000000 x3 : 0000000000000000
> [   15.349550] x2 : 0000000000000000 x1 : 0000000000000000 x0 : 0000000000000000
> [   15.349565] Call trace:
> [   15.349572]  __fortify_report+0x64/0xc8 (P)
> [   15.349583]  __fortify_panic+0x14/0x18
> [   15.349595]  auxiliary_match_id+0xf8/0x110
> [   15.349608]  auxiliary_match+0x28/0x60
> [   15.349617]  __driver_attach+0x34/0x2a8
> [   15.349629]  bus_for_each_dev+0x88/0x110
> [   15.349639]  driver_attach+0x30/0x60
> [   15.349649]  bus_add_driver+0x178/0x2d8
> [   15.349658]  driver_register+0x74/0x178
> [   15.349668]  __auxiliary_driver_register+0x7c/0x150
> [   15.349677]  mux_rzv2h_usb_vbus_driver_init+0x34/0xfd0 [mux_rzv2h_usb_vbus]
> 
> > +	{ /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(auxiliary, mux_rzv2h_usb_vbus_ids);
> > +
> > +static struct auxiliary_driver mux_rzv2h_usb_vbus_driver = {
> > +	.name		= "vbus-sel-mux",
> > +	.probe		= mux_rzv2h_usb_vbus_probe,
> > +	.id_table	= mux_rzv2h_usb_vbus_ids,
> > +};
> > +module_auxiliary_driver(mux_rzv2h_usb_vbus_driver);
> > +
> > +MODULE_DESCRIPTION("RZ/V2H USB VBUS_SEL mux driver");
> > +MODULE_AUTHOR("Tommaso Merciai <tommaso.merciai.xr@...renesas.com>");
> > +MODULE_LICENSE("GPL");
> > diff --git a/include/linux/reset/reset_rzv2h_usb2phy.h b/include/linux/reset/reset_rzv2h_usb2phy.h
> > new file mode 100644
> > index 000000000000..06247080a66c
> > --- /dev/null
> > +++ b/include/linux/reset/reset_rzv2h_usb2phy.h
> > @@ -0,0 +1,11 @@
> > +/* SPDX-License-Identifier: GPL-2.0 */
> > +#ifndef _RESET_RZV2H_USB2PHY_H
> > +#define _RESET_RZV2H_USB2PHY_H
> > +
> > +#include <linux/auxiliary_bus.h>
> > +
> > +struct reset_rzv2h_usb2phy_adev {
> > +	void __iomem *base;
> > +};
> > +
> > +#endif
> > -- 
> > 2.43.0
> > 
> > 
> > -- 
> > linux-phy mailing list
> > linux-phy@...ts.infradead.org
> > https://lists.infradead.org/mailman/listinfo/linux-phy

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ