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]
Message-ID: <b7a48bbf-d783-4636-8f75-35c9904ffe05@microchip.com>
Date: Fri, 13 Dec 2024 10:35:03 +0000
From: <Parthiban.Veerasooran@...rochip.com>
To: <kuba@...nel.org>
CC: <andrew+netdev@...n.ch>, <davem@...emloft.net>, <edumazet@...gle.com>,
	<pabeni@...hat.com>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <UNGLinuxDriver@...rochip.com>,
	<jacob.e.keller@...el.com>
Subject: Re: [PATCH net v3 2/2] net: ethernet: oa_tc6: fix tx skb race
 condition between reference pointers

Hi Jakub,

On 12/12/24 6:03 pm, Parthiban.Veerasooran@...rochip.com wrote:
> Hi Jakub,
> 
> On 10/12/24 5:41 am, Jakub Kicinski wrote:
>> EXTERNAL EMAIL: Do not click links or open attachments unless you know the content is safe
>>
>> On Wed, 4 Dec 2024 19:05:18 +0530 Parthiban Veerasooran wrote:
>>> @@ -1210,7 +1213,9 @@ netdev_tx_t oa_tc6_start_xmit(struct oa_tc6 *tc6, struct sk_buff *skb)
>>>                 return NETDEV_TX_OK;
>>>         }
>>>
>>> +     mutex_lock(&tc6->tx_skb_lock);
>>>         tc6->waiting_tx_skb = skb;
>>> +     mutex_unlock(&tc6->tx_skb_lock);
>>
>> start_xmit runs in BH / softirq context. You can't take sleeping locks.
>> The lock has to be a spin lock. You could possibly try to use the
>> existing spin lock of the tx queue (__netif_tx_lock()) but that may be
>> more challenging to do cleanly from within a library..
> Thanks for the input. Yes, it looks like implementing a spin lock would
> be a right choice. I will implement it and do the testing as you
> suggested below and share the feedback.
I tried using spin_lock_bh() variants (as the softirq involved) on both 
start_xmit() and spi_thread() where the critical regions need to be 
protected and tested by enabling the Kconfigs in the 
kernel/configs/debug.config. Didn't notice any warnings in the dmesg log.

Note: Prior to the above test, purposefully I tried with spin_lock() 
variants on both the sides to check/simulate for the warnings using 
Kconfigs kernel/configs/debug.config. Got some warnings in the dmesg 
regarding deadlock which clarified the expected behavior. And then I 
proceeded with the above fix and it worked as expected.

If you agree, I will prepare the next version with this fix and post.

Best regards,
Parthiban V
> 
> Best regards,
> Parthiban V
>>
>> Please make sure you test with builds including the
>> kernel/configs/debug.config Kconfigs.
>> --
>> pw-bot: cr
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ