linux-kselftest.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net v2 0/2] netconsole: Fix userdata race condition
@ 2025-10-22 17:39 Gustavo Luiz Duarte
  2025-10-22 17:39 ` [PATCH net v2 1/2] netconsole: Fix race condition in between reader and writer of userdata Gustavo Luiz Duarte
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Gustavo Luiz Duarte @ 2025-10-22 17:39 UTC (permalink / raw)
  To: Andre Carvalho, Simon Horman, Breno Leitao, Andrew Lunn,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Matthew Wood, Shuah Khan
  Cc: netdev, linux-kernel, linux-kselftest, Gustavo Luiz Duarte

This series fixes a race condition in netconsole's userdata handling
where concurrent message transmission could read partially updated
userdata fields, resulting in corrupted netconsole output.

The first patch adds a selftest that reproduces the race condition by
continuously sending messages while rapidly changing userdata values,
detecting any torn reads in the output.

The second patch fixes the issue by ensuring update_userdata() holds
the target_list_lock while updating both extradata_complete and
userdata_length, preventing readers from seeing inconsistent state.

This targets net tree as it fixes a bug introduced in commit df03f830d099
("net: netconsole: cache userdata formatted string in netconsole_target").

Signed-off-by: Gustavo Luiz Duarte <gustavold@gmail.com>

Changes in v2:
- Added testcase to Makefile.
- Reordered fix and testcase to avoid failure in CI.
- testcase: delay cleanup until child process are killed, plus shellcheck fixes.
- Link to v1: https://lore.kernel.org/all/20251020-netconsole-fix-race-v1-0-b775be30ee8a@gmail.com/

---
Gustavo Luiz Duarte (2):
      netconsole: Fix race condition in between reader and writer of userdata
      selftests: netconsole: Add race condition test for userdata corruption

 drivers/net/netconsole.c                           |  5 ++
 tools/testing/selftests/drivers/net/Makefile       |  1 +
 .../selftests/drivers/net/netcons_race_userdata.sh | 87 ++++++++++++++++++++++
 3 files changed, 93 insertions(+)
---
base-commit: d63f0391d6c7b75e1a847e1a26349fa8cad0004d
change-id: 20251020-netconsole-fix-race-f465f37b57ea

Best regards,
-- 
Gustavo Duarte <gustavold@meta.com>


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

end of thread, other threads:[~2025-10-27 15:56 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 17:39 [PATCH net v2 0/2] netconsole: Fix userdata race condition Gustavo Luiz Duarte
2025-10-22 17:39 ` [PATCH net v2 1/2] netconsole: Fix race condition in between reader and writer of userdata Gustavo Luiz Duarte
2025-10-22 17:39 ` [PATCH net v2 2/2] selftests: netconsole: Add race condition test for userdata corruption Gustavo Luiz Duarte
2025-10-23  1:01 ` [PATCH net v2 0/2] netconsole: Fix userdata race condition Jakub Kicinski
2025-10-24 21:10   ` Gustavo Luiz Duarte
2025-10-24 23:42     ` Jakub Kicinski
2025-10-27 15:56       ` Gustavo Luiz Duarte

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).