Skip to content

Commit 2ab1195

Browse files
rlubosfabiobaltieri
authored andcommitted
net: context: Separate user data pointer from FIFO reserved space
Using the same memory as a user data pointer and FIFO reserved space could lead to a crash in certain circumstances, those two use cases were not completely separate. The crash could happen for example, if an incoming TCP connection was abruptly closed just after being established. As TCP uses the user data to notify error condition to the upper layer, the user data pointer could've been used while the newly allocated context could still be waiting on the accept queue. This damaged the data area used by the FIFO and eventually could lead to a crash. Signed-off-by: Robert Lubos <[email protected]>
1 parent 4e6f80d commit 2ab1195

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

include/zephyr/net/net_context.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,11 @@ struct net_conn_handle;
199199
* anyway. This saves 12 bytes / context in IPv6.
200200
*/
201201
__net_socket struct net_context {
202-
/** User data.
203-
*
204-
* First member of the structure to let users either have user data
205-
* associated with a context, or put contexts into a FIFO.
202+
/** First member of the structure to allow to put contexts into a FIFO.
203+
*/
204+
void *fifo_reserved;
205+
206+
/** User data associated with a context.
206207
*/
207208
void *user_data;
208209

0 commit comments

Comments
 (0)