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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 17 Aug 2021 21:55:51 +0200
From:   Marc Kleine-Budde <mkl@...gutronix.de>
To:     Vincent Mailhol <mailhol.vincent@...adoo.fr>
Cc:     linux-can@...r.kernel.org,
        Stefan Mätje <Stefan.Maetje@....eu>,
        netdev@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v5 5/7] can: netlink: add interface for CAN-FD
 Transmitter Delay Compensation (TDC)

On 15.08.2021 12:32:46, Vincent Mailhol wrote:
> +static int can_tdc_changelink(struct net_device *dev, const struct nlattr *nla,
> +			      struct netlink_ext_ack *extack)
> +{
> +	struct nlattr *tb_tdc[IFLA_CAN_TDC_MAX + 1];
> +	struct can_priv *priv = netdev_priv(dev);
> +	struct can_tdc *tdc = &priv->tdc;
> +	const struct can_tdc_const *tdc_const = priv->tdc_const;
> +	int err;
> +
> +	if (!tdc_const || !can_tdc_is_enabled(priv))
> +		return -EOPNOTSUPP;
> +
> +	if (dev->flags & IFF_UP)
> +		return -EBUSY;
> +
> +	err = nla_parse_nested(tb_tdc, IFLA_CAN_TDC_MAX, nla,
> +			       can_tdc_policy, extack);
> +	if (err)
> +		return err;
> +
> +	if (tb_tdc[IFLA_CAN_TDC_TDCV]) {
> +		u32 tdcv = nla_get_u32(tb_tdc[IFLA_CAN_TDC_TDCV]);
> +
> +		if (tdcv < tdc_const->tdcv_min || tdcv > tdc_const->tdcv_max)
> +			return -EINVAL;
> +
> +		tdc->tdcv = tdcv;

You have to assign to a temporary struct first, and set the priv->tdc
after complete validation, otherwise you end up with inconsistent
values.

> +	}
> +
> +	if (tb_tdc[IFLA_CAN_TDC_TDCO]) {
> +		u32 tdco = nla_get_u32(tb_tdc[IFLA_CAN_TDC_TDCO]);
> +
> +		if (tdco < tdc_const->tdco_min || tdco > tdc_const->tdco_max)
> +			return -EINVAL;
> +
> +		tdc->tdco = tdco;
> +	}
> +
> +	if (tb_tdc[IFLA_CAN_TDC_TDCF]) {
> +		u32 tdcf = nla_get_u32(tb_tdc[IFLA_CAN_TDC_TDCF]);
> +
> +		if (tdcf < tdc_const->tdcf_min || tdcf > tdc_const->tdcf_max)
> +			return -EINVAL;
> +
> +		tdc->tdcf = tdcf;
> +	}
> +
> +	return 0;
> +}

To reproduce (ip pseudo-code only :D ):

ip down
ip up tdc-mode manual tdco 111 tdcv 33  # 111 is out of range, 33 is valid
ip down
ip up                                   # results in tdco=0 tdcv=33 mode=manual

Marc

-- 
Pengutronix e.K.                 | Marc Kleine-Budde           |
Embedded Linux                   | https://www.pengutronix.de  |
Vertretung West/Dortmund         | Phone: +49-231-2826-924     |
Amtsgericht Hildesheim, HRA 2686 | Fax:   +49-5121-206917-5555 |

Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ