diff mbox series

[net-next,1/4] netconsole: Ensure dynamic_netconsole_mutex is held during userdata update

Message ID 20241113-netcon_cpu-v1-1-d187bf7c0321@debian.org (mailing list archive)
State New
Delegated to: Netdev Maintainers
Headers show
Series netconsole: Add support for CPU population | expand

Checks

Context Check Description
netdev/series_format success Posting correctly formatted
netdev/tree_selection success Clearly marked for net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 3 this patch: 3
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 6 of 6 maintainers
netdev/build_clang success Errors and warnings before: 3 this patch: 3
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 4 this patch: 4
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-11-14--03-00 (tests: 782)

Commit Message

Breno Leitao Nov. 13, 2024, 3:10 p.m. UTC
Add a lock assertion to verify that dynamic_netconsole_mutex is held
when updating the userdata fields in the netconsole driver.

This change prevents calling update_userdata() without holding the lock,
ensuring data consistency and integrity.

The update_userdata() function is invoked only when the user changes the
configuration, so this addition does not impact performance as it is not
in the hot path.

Signed-off-by: Breno Leitao <leitao@debian.org>
---
 drivers/net/netconsole.c | 2 ++
 1 file changed, 2 insertions(+)
diff mbox series

Patch

diff --git a/drivers/net/netconsole.c b/drivers/net/netconsole.c
index 4ea44a2f48f7b1f9059d275f0f0edc40cc1997f0..965712d65a014c60f91bf35e48f1b112f66b8439 100644
--- a/drivers/net/netconsole.c
+++ b/drivers/net/netconsole.c
@@ -697,6 +697,8 @@  static void update_userdata(struct netconsole_target *nt)
 	int complete_idx = 0, child_count = 0;
 	struct list_head *entry;
 
+	lockdep_assert_held(&dynamic_netconsole_mutex);
+
 	/* Clear the current string in case the last userdatum was deleted */
 	nt->userdata_length = 0;
 	nt->userdata_complete[0] = 0;