public inbox for [email protected]
 help / color / mirror / Atom feed
* [PATCH liburing v1 0/2] 2 fixes for recv-msgall.c
@ 2023-05-10 14:39 Ammar Faizi
  2023-05-10 14:39 ` [PATCH liburing v1 1/2] recv-msgall: Fix undefined behavior in `recv_prep()` Ammar Faizi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Ammar Faizi @ 2023-05-10 14:39 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Ammar Faizi, Barnabás Pőcze, Michael William Jonathan,
	Linux Kernel Mailing List, io-uring Mailing List,
	GNU/Weeb Mailing List

Hi Jens,

This is the follow up patchset for the recent issue found in
recv-msgall.c. There are two patches in this series.

1. Fix undefined behavior in `recv_prep()`.
The lifetime of `struct msghdr msg;` must be long enough until the CQE
is generated because the recvmsg operation will write to that storage. I
found this test segfault when compiling with -O0 optimization. This is
undefined behavior and may behave randomly. Fix this by making the
lifetime of `struct msghdr msg;` long enough.

2. Fix invalid mutex usage.
Calling pthread_mutex_lock() twice with the same mutex in the same
thread without unlocking it first is invalid. The intention behind this
pattern was to wait for the recv_fn() thread to be ready. Use the
pthread barrier instead. It is more straightforward and correct.

Please apply!

Signed-off-by: Ammar Faizi <[email protected]>
--- 

Ammar Faizi (2):
  recv-msgall: Fix undefined behavior in `recv_prep()`
  recv-msgall: Fix invalid mutex usage

 test/recv-msgall.c | 44 +++++++++++++++++++++-----------------------
 1 file changed, 21 insertions(+), 23 deletions(-)


base-commit: 4961ac480052089a94978e9f771d513551aff61b
-- 
Ammar Faizi


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

end of thread, other threads:[~2023-05-10 15:17 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-10 14:39 [PATCH liburing v1 0/2] 2 fixes for recv-msgall.c Ammar Faizi
2023-05-10 14:39 ` [PATCH liburing v1 1/2] recv-msgall: Fix undefined behavior in `recv_prep()` Ammar Faizi
2023-05-10 14:39 ` [PATCH liburing v1 2/2] recv-msgall: Fix invalid mutex usage Ammar Faizi
2023-05-10 15:17 ` [PATCH liburing v1 0/2] 2 fixes for recv-msgall.c Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox