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: <20250529175627.4e6a3b07@kernel.org>
Date: Thu, 29 May 2025 17:56:27 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Arkadiusz Kubalewski <arkadiusz.kubalewski@...el.com>
Cc: donald.hunter@...il.com, davem@...emloft.net, edumazet@...gle.com,
 pabeni@...hat.com, horms@...nel.org, vadim.fedorenko@...ux.dev,
 jiri@...nulli.us, anthony.l.nguyen@...el.com, przemyslaw.kitszel@...el.com,
 andrew+netdev@...n.ch, aleksandr.loktionov@...el.com, corbet@....net,
 netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
 intel-wired-lan@...ts.osuosl.org, linux-rdma@...r.kernel.org,
 linux-doc@...r.kernel.org, Milena Olech <milena.olech@...el.com>
Subject: Re: [PATCH net-next v4 2/3] dpll: add reference sync get/set

On Fri, 23 May 2025 19:26:49 +0200 Arkadiusz Kubalewski wrote:
> +static int
> +dpll_pin_ref_sync_state_set(struct dpll_pin *pin,
> +			    unsigned long ref_sync_pin_idx,
> +			    const enum dpll_pin_state state,
> +			    struct netlink_ext_ack *extack)
> +
> +{
> +	struct dpll_pin_ref *ref, *failed;
> +	const struct dpll_pin_ops *ops;
> +	enum dpll_pin_state old_state;
> +	struct dpll_pin *ref_sync_pin;
> +	struct dpll_device *dpll;
> +	unsigned long i;
> +	int ret;
> +
> +	ref_sync_pin = xa_find(&pin->ref_sync_pins, &ref_sync_pin_idx,
> +			       ULONG_MAX, XA_PRESENT);
> +	if (!ref_sync_pin) {
> +		NL_SET_ERR_MSG(extack, "reference sync pin not found");
> +		return -EINVAL;
> +	}
> +	if (!dpll_pin_available(ref_sync_pin)) {
> +		NL_SET_ERR_MSG(extack, "reference sync pin not available");
> +		return -EINVAL;
> +	}
> +	ref = dpll_xa_ref_dpll_first(&pin->dpll_refs);
> +	ASSERT_NOT_NULL(ref);

why the assert? The next line will crash very.. "informatively"
if ref is NULL 🤷️

> +static int
> +dpll_pin_ref_sync_set(struct dpll_pin *pin, struct nlattr *nest,
> +		      struct netlink_ext_ack *extack)
> +{
> +	struct nlattr *tb[DPLL_A_PIN_MAX + 1];
> +	enum dpll_pin_state state;
> +	u32 sync_pin_id;
> +
> +	nla_parse_nested(tb, DPLL_A_PIN_MAX, nest,
> +			 dpll_reference_sync_nl_policy, extack);
> +	if (!tb[DPLL_A_PIN_ID]) {

NL_REQ_ATTR_CHECK(), please

	if (NL_REQ_ATTR_CHECK(extack, nest, tb, DPLL_A_PIN_ID) ||
	    NL_REQ_ATTR_CHECK(extack, nest, tb, DPLL_A_PIN_STATE))
		return -EINVAL;

it will set ATTR_MISS metadata for you. Not 100% sure if Python YNL
can decode miss attrs in nests but that's a SMOP :) C YNL can do it.

> +		NL_SET_ERR_MSG(extack, "sync pin id expected");
> +		return -EINVAL;
> +	}
> +	sync_pin_id = nla_get_u32(tb[DPLL_A_PIN_ID]);
> +
> +	if (!tb[DPLL_A_PIN_STATE]) {
> +		NL_SET_ERR_MSG(extack, "sync pin state expected");
> +		return -EINVAL;
> +	}
> +	state = nla_get_u32(tb[DPLL_A_PIN_STATE]);
> +
> +	return dpll_pin_ref_sync_state_set(pin, sync_pin_id, state, extack);
> +}

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ