Skip to content

wifi_winc1500 driver socket id stored in net_context->user_data may be overwritten at socket layer #8820

@GAnthony

Description

@GAnthony

While looking through net_context.h for a place to store the net offload driver's (internal) socket handle, considering the net_context->user_data field, and seeing what was done in wifi_winc1500.c, I noticed that socket.c reuses the same user_data for flags, potentially overwriting the driver's socket handle for that net_context.

From drivers/wifi/winc1500/wifi_winc15000.c:

static int winc1500_get(sa_family_t family,
			enum net_sock_type type,
			enum net_ip_protocol ip_proto,
			struct net_context **context)
{
	struct socket_data *sd;
[...]
	(*context)->user_data = (void *)(sint32)socket(family, type, 0);

Later, if socket API is used over net_context (with this offload driver), then:
subsys/lib/sockets/socket.c:

static inline void sock_set_flag(struct net_context *ctx, u32_t mask,
				 u32_t flag)
{
	u32_t val = POINTER_TO_INT(ctx->user_data);
	val = (val & ~mask) | flag;
	(ctx)->user_data = INT_TO_POINTER(val);
}

Can sockets use the available bits of the net_context->flags parameter instead, or would it be better to have an optional, more clearly named, void *offload_context for NET_OFFLOAD drivers?

Metadata

Metadata

Assignees

Labels

area: NetworkingbugThe issue is a bug, or the PR is fixing a bugpriority: mediumMedium impact/importance bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions