Skip to content

Commit 63ec72b

Browse files
keeskuba-moo
authored andcommitted
mptcp: Use struct_group() to avoid cross-field memset()
In preparation for FORTIFY_SOURCE performing compile-time and run-time field bounds checking for memcpy(), memmove(), and memset(), avoid intentionally writing across neighboring fields. Use struct_group() to capture the fields to be reset, so that memset() can be appropriately bounds-checked by the compiler. Cc: Matthieu Baerts <[email protected]> Cc: [email protected] Signed-off-by: Kees Cook <[email protected]> Reviewed-by: Mat Martineau <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 2c13c05 commit 63ec72b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

net/mptcp/protocol.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ DECLARE_PER_CPU(struct mptcp_delegated_action, mptcp_delegated_actions);
408408
struct mptcp_subflow_context {
409409
struct list_head node;/* conn_list of subflows */
410410

411-
char reset_start[0];
411+
struct_group(reset,
412412

413413
unsigned long avg_pacing_rate; /* protected by msk socket lock */
414414
u64 local_key;
@@ -458,7 +458,7 @@ struct mptcp_subflow_context {
458458

459459
long delegated_status;
460460

461-
char reset_end[0];
461+
);
462462

463463
struct list_head delegated_node; /* link into delegated_action, protected by local BH */
464464

@@ -494,7 +494,7 @@ mptcp_subflow_tcp_sock(const struct mptcp_subflow_context *subflow)
494494
static inline void
495495
mptcp_subflow_ctx_reset(struct mptcp_subflow_context *subflow)
496496
{
497-
memset(subflow->reset_start, 0, subflow->reset_end - subflow->reset_start);
497+
memset(&subflow->reset, 0, sizeof(subflow->reset));
498498
subflow->request_mptcp = 1;
499499
}
500500

0 commit comments

Comments
 (0)