All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] net: eth-uclass: Fix eth_halt
@ 2022-03-28  9:57 qianfanguijin
  2022-03-28  9:57 ` [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb qianfanguijin
  0 siblings, 1 reply; 6+ messages in thread
From: qianfanguijin @ 2022-03-28  9:57 UTC (permalink / raw)
  To: u-boot
  Cc: Joe Hershberger, Ramon Fried, Matthias Schiffer,
	Heinrich Schuchardt, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

eth_device_priv maybe unaccessable after @stop handler due to eth device
is removed in @stop. Setting private data before @stop handler.

This also fix data abort bug when run dhcp or tftp command via usbnet.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 net/eth-uclass.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 58c308f332..c6eb1bc8f8 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -338,9 +338,14 @@ void eth_halt(void)
 	if (!priv || !priv->running)
 		return;
 
-	eth_get_ops(current)->stop(current);
-	priv->state = ETH_STATE_PASSIVE;
+	/* Make sure setting private data before @stop handler, it may remove
+	 * ethernet device and will cause @priv unaccessable.
+	 * eg:
+	 * usb_eth_stop -> usb_gadget_release -> device_remove
+	 */
 	priv->running = false;
+
+	eth_get_ops(current)->stop(current);
 }
 
 int eth_is_active(struct udevice *dev)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb
  2022-03-28  9:57 [PATCH v2 1/2] net: eth-uclass: Fix eth_halt qianfanguijin
@ 2022-03-28  9:57 ` qianfanguijin
  2022-04-01 19:23   ` Ramon Fried
  0 siblings, 1 reply; 6+ messages in thread
From: qianfanguijin @ 2022-03-28  9:57 UTC (permalink / raw)
  To: u-boot
  Cc: Joe Hershberger, Ramon Fried, Matthias Schiffer,
	Heinrich Schuchardt, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

tftp_handler do eth_halt when TFTP_ERROR, but eth_halt will remove eth
device if it is an usb network. usbeth's private data will be unaccessable
when usb_eth_free_pkt, touch it will trigger data abort.

Next is the console messages:

=> tftp xxx
...
Loading: *
TFTP error: 'open failed: No such file or directory' (1)
Not retrying...
data abort
pc : [<9feb6ba2>]          lr : [<9feb6b9f>]

Fix it.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 net/eth-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index c6eb1bc8f8..27baf52c26 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -405,6 +405,13 @@ int eth_rx(void)
 		flags = 0;
 		if (ret > 0)
 			net_process_received_packet(packet, ret);
+
+		/* ethernet maybe halted when packet_handler, check again */
+		if (!eth_is_active(current)) {
+			ret = 0;
+			break;
+		}
+
 		if (ret >= 0 && eth_get_ops(current)->free_pkt)
 			eth_get_ops(current)->free_pkt(current, packet, ret);
 		if (ret <= 0)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb
  2022-03-28  9:57 ` [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb qianfanguijin
@ 2022-04-01 19:23   ` Ramon Fried
  0 siblings, 0 replies; 6+ messages in thread
From: Ramon Fried @ 2022-04-01 19:23 UTC (permalink / raw)
  To: qianfanguijin
  Cc: U-Boot Mailing List, Joe Hershberger, Matthias Schiffer,
	Heinrich Schuchardt

On Mon, Mar 28, 2022 at 12:58 PM <qianfanguijin@163.com> wrote:
>
> From: qianfan Zhao <qianfanguijin@163.com>
>
> tftp_handler do eth_halt when TFTP_ERROR, but eth_halt will remove eth
> device if it is an usb network. usbeth's private data will be unaccessable
> when usb_eth_free_pkt, touch it will trigger data abort.
>
> Next is the console messages:
>
> => tftp xxx
> ...
> Loading: *
> TFTP error: 'open failed: No such file or directory' (1)
> Not retrying...
> data abort
> pc : [<9feb6ba2>]          lr : [<9feb6b9f>]
>
> Fix it.
>
> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
> ---
>  net/eth-uclass.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> index c6eb1bc8f8..27baf52c26 100644
> --- a/net/eth-uclass.c
> +++ b/net/eth-uclass.c
> @@ -405,6 +405,13 @@ int eth_rx(void)
>                 flags = 0;
>                 if (ret > 0)
>                         net_process_received_packet(packet, ret);
> +
> +               /* ethernet maybe halted when packet_handler, check again */
> +               if (!eth_is_active(current)) {
> +                       ret = 0;
> +                       break;
> +               }
> +
>                 if (ret >= 0 && eth_get_ops(current)->free_pkt)
>                         eth_get_ops(current)->free_pkt(current, packet, ret);
>                 if (ret <= 0)
> --
> 2.17.1
>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb
  2022-04-14  4:39   ` Ramon Fried
@ 2022-04-14  6:17     ` qianfan
  0 siblings, 0 replies; 6+ messages in thread
From: qianfan @ 2022-04-14  6:17 UTC (permalink / raw)
  To: Ramon Fried
  Cc: U-Boot Mailing List, Joe Hershberger, Matthias Schiffer,
	Heinrich Schuchardt


在 2022/4/14 12:39, Ramon Fried 写道:
> On Sat, Apr 2, 2022 at 5:58 AM <qianfanguijin@163.com> wrote:
>> From: qianfan Zhao <qianfanguijin@163.com>
>>
>> tftp_handler do eth_halt when TFTP_ERROR, but eth_halt will remove eth
>> device if it is an usb network. usbeth's private data will be unaccessable
>> when usb_eth_free_pkt, touch it will trigger data abort.
>>
>> Next is the console messages:
>>
>> => tftp xxx
>> ...
>> Loading: *
>> TFTP error: 'open failed: No such file or directory' (1)
>> Not retrying...
>> data abort
>> pc : [<9feb6ba2>]          lr : [<9feb6b9f>]
>>
>> Fix it.
>>
>> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
>> ---
>>   net/eth-uclass.c | 7 +++++++
>>   1 file changed, 7 insertions(+)
>>
>> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
>> index 2b88b6c145..c9bba4f8de 100644
>> --- a/net/eth-uclass.c
>> +++ b/net/eth-uclass.c
>> @@ -407,6 +407,13 @@ int eth_rx(void)
>>                  flags = 0;
>>                  if (ret > 0)
>>                          net_process_received_packet(packet, ret);
>> +
>> +               /* ethernet maybe halted when packet_handler, check again */
>> +               if (!eth_is_active(current)) {
>> +                       ret = 0;
>> +                       break;
>> +               }
>> +
>>                  if (ret >= 0 && eth_get_ops(current)->free_pkt)
>>                          eth_get_ops(current)->free_pkt(current, packet, ret);
>>                  if (ret <= 0)
>> --
>> 2.17.1
>>
> I wonder how I never experienced this behavior. I have used USB based
> ethernet dongles.
> And I used tftp and got errors but never an abort .Is it possible that
> the problem is with the specific ethernet driver you are using ?
> Can you specify which one you used ?

I had check the pc location of data abort, it's on dlmalloc. The bug had 
changed those memory already freed. Cause dlmalloc trigger data abort.

This bug is happens on am335x device.  nothing is specific, use 
am335x_evm_defconfig can reproduce this.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb
  2022-04-02  2:58 ` [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb qianfanguijin
@ 2022-04-14  4:39   ` Ramon Fried
  2022-04-14  6:17     ` qianfan
  0 siblings, 1 reply; 6+ messages in thread
From: Ramon Fried @ 2022-04-14  4:39 UTC (permalink / raw)
  To: qianfan
  Cc: U-Boot Mailing List, Joe Hershberger, Matthias Schiffer,
	Heinrich Schuchardt

On Sat, Apr 2, 2022 at 5:58 AM <qianfanguijin@163.com> wrote:
>
> From: qianfan Zhao <qianfanguijin@163.com>
>
> tftp_handler do eth_halt when TFTP_ERROR, but eth_halt will remove eth
> device if it is an usb network. usbeth's private data will be unaccessable
> when usb_eth_free_pkt, touch it will trigger data abort.
>
> Next is the console messages:
>
> => tftp xxx
> ...
> Loading: *
> TFTP error: 'open failed: No such file or directory' (1)
> Not retrying...
> data abort
> pc : [<9feb6ba2>]          lr : [<9feb6b9f>]
>
> Fix it.
>
> Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
> ---
>  net/eth-uclass.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/net/eth-uclass.c b/net/eth-uclass.c
> index 2b88b6c145..c9bba4f8de 100644
> --- a/net/eth-uclass.c
> +++ b/net/eth-uclass.c
> @@ -407,6 +407,13 @@ int eth_rx(void)
>                 flags = 0;
>                 if (ret > 0)
>                         net_process_received_packet(packet, ret);
> +
> +               /* ethernet maybe halted when packet_handler, check again */
> +               if (!eth_is_active(current)) {
> +                       ret = 0;
> +                       break;
> +               }
> +
>                 if (ret >= 0 && eth_get_ops(current)->free_pkt)
>                         eth_get_ops(current)->free_pkt(current, packet, ret);
>                 if (ret <= 0)
> --
> 2.17.1
>
I wonder how I never experienced this behavior. I have used USB based
ethernet dongles.
And I used tftp and got errors but never an abort .Is it possible that
the problem is with the specific ethernet driver you are using ?
Can you specify which one you used ?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb
  2022-04-02  2:58 [PATCH v2 1/2] net: eth-uclass: Fix eth_halt qianfanguijin
@ 2022-04-02  2:58 ` qianfanguijin
  2022-04-14  4:39   ` Ramon Fried
  0 siblings, 1 reply; 6+ messages in thread
From: qianfanguijin @ 2022-04-02  2:58 UTC (permalink / raw)
  To: u-boot
  Cc: Joe Hershberger, Ramon Fried, Matthias Schiffer,
	Heinrich Schuchardt, qianfan Zhao

From: qianfan Zhao <qianfanguijin@163.com>

tftp_handler do eth_halt when TFTP_ERROR, but eth_halt will remove eth
device if it is an usb network. usbeth's private data will be unaccessable
when usb_eth_free_pkt, touch it will trigger data abort.

Next is the console messages:

=> tftp xxx
...
Loading: *
TFTP error: 'open failed: No such file or directory' (1)
Not retrying...
data abort
pc : [<9feb6ba2>]          lr : [<9feb6b9f>]

Fix it.

Signed-off-by: qianfan Zhao <qianfanguijin@163.com>
---
 net/eth-uclass.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/net/eth-uclass.c b/net/eth-uclass.c
index 2b88b6c145..c9bba4f8de 100644
--- a/net/eth-uclass.c
+++ b/net/eth-uclass.c
@@ -407,6 +407,13 @@ int eth_rx(void)
 		flags = 0;
 		if (ret > 0)
 			net_process_received_packet(packet, ret);
+
+		/* ethernet maybe halted when packet_handler, check again */
+		if (!eth_is_active(current)) {
+			ret = 0;
+			break;
+		}
+
 		if (ret >= 0 && eth_get_ops(current)->free_pkt)
 			eth_get_ops(current)->free_pkt(current, packet, ret);
 		if (ret <= 0)
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-04-14  6:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  9:57 [PATCH v2 1/2] net: eth-uclass: Fix eth_halt qianfanguijin
2022-03-28  9:57 ` [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb qianfanguijin
2022-04-01 19:23   ` Ramon Fried
2022-04-02  2:58 [PATCH v2 1/2] net: eth-uclass: Fix eth_halt qianfanguijin
2022-04-02  2:58 ` [PATCH v2 2/2] net: eth-uclass: Fix data abort when tftp get nonexistent file via usb qianfanguijin
2022-04-14  4:39   ` Ramon Fried
2022-04-14  6:17     ` qianfan

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.