Unsafe memory access in testpmd
Noticed that test-pmd is using a signal handler to exit. And that signal handle clears a flag "f_quit".
But that variable is updated without atomic and is not volatile.
Simple fix to use atomic, would fix that part.
But the signal_handler is calling a bunch of functions that are not safe in a signal handler.
The signal handler in testpmd should only be doing atomic update of f_quit. All the cleanup logic needs to be moved to a place where thread is an safe state, like after exiting the forwarding loop in main thread.
The problem is that testpmd has grown in complexity and not sure if this won't break other things.
Quoted 12 lines
-----Original Message-----
From: Stephen Hemminger <[email protected]>
Sent: Friday, October 14, 2022 7:39 AM
To: Ruifeng Wang <[email protected]>; Honnappa Nagarahalli <[email protected]>
Cc: [email protected]
Subject: Unsafe memory access in testpmdNoticed that test-pmd is using a signal handler to exit. And that signal handle clears a flag "
f_quit".
But that variable is updated without atomic and is not volatile.
Quoted 7 lines
Simple fix to use atomic, would fix that part.
But thesignal_handleris calling a bunch of functions that are not safe in a signal handler.The signal handler in testpmd should only be doing atomic update of
f_quit. All the cleanup logic needs to be moved to a place where thread is an safe state, like after exiting the forwarding loop in main thread.
Agree.
Quoted 3 lines
The problem is that testpmd has grown in complexity and not sure if this won't break other things.
We can propose patches. Review and testing from the community are expected to cover as many cases as possible.