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: <20230626131034.1766bdbf@kernel.org>
Date: Mon, 26 Jun 2023 13:10:34 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Moritz Fischer <moritzf@...gle.com>
Cc: netdev@...r.kernel.org, pabeni@...hat.com, edumazet@...gle.com,
 davem@...emloft.net, bryan.whitehead@...rochip.com,
 UNGLinuxDriver@...rochip.com, mdf@...nel.org
Subject: Re: [PATCH net-next v2] net: lan743x: Don't sleep in atomic context

On Sun, 25 Jun 2023 18:23:27 +0000 Moritz Fischer wrote:
> dev_set_rx_mode() grabs a spin_lock, and the lan743x implementation
> proceeds subsequently to go to sleep using readx_poll_timeout().
> 
> Introduce a helper wrapping the readx_poll_timeout_atomic() function
> and use it to replace the calls to readx_polL_timeout().
> 
> Signed-off-by: Moritz Fischer <moritzf@...gle.com>
> ---
> 
> Changes from v1:
> - Added line-breaks
> - Changed subject to target net-next
> - Removed Tested-by: tag

Sleeping in atomic context is a bug, this is a bug fix.
You should add a Fixes tag (probably 23f0703c125be AFAICT)
and target the patch at net rather than net-next.
Make sure you CC the authors of the patch under fixes (get_maintainer
will point them out if run on a patch file with a Fixes tag)
One more nit below...

>  drivers/net/ethernet/microchip/lan743x_main.c | 22 +++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/microchip/lan743x_main.c b/drivers/net/ethernet/microchip/lan743x_main.c
> index f1bded993edc..4f277ffff1dc 100644
> --- a/drivers/net/ethernet/microchip/lan743x_main.c
> +++ b/drivers/net/ethernet/microchip/lan743x_main.c
> @@ -144,6 +144,19 @@ static int lan743x_csr_light_reset(struct lan743x_adapter *adapter)
>  				  !(data & HW_CFG_LRST_), 100000, 10000000);
>  }
>  
> +static int lan743x_csr_wait_for_bit_atomic(struct lan743x_adapter *adapter,
> +					   int offset, u32 bit_mask,
> +					   int target_value, int udelay_min,
> +					   int udelay_max, int count)
> +{
> +	u32 data;
> +
> +	return readx_poll_timeout_atomic(LAN743X_CSR_READ_OP, offset, data,
> +					 target_value == ((data & bit_mask) ?
> +					 1 : 0), udelay_max,

You can save the awkward wrapping by using a double negation:

					target_value == !!(data & bit_mask)

this is a fairly common form in the kernel.
-- 
pw-bot: cr

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ