Skip to content

Commit 7fe8097

Browse files
Erik Hugnedavem330
authored andcommitted
tipc: fix nullpointer bug when subscribing to events
If a subscription request is sent to a topology server connection, and any error occurs (malformed request, oom or limit reached) while processing this request, TIPC should terminate the subscriber connection. While doing so, it tries to access fields in an already freed (or never allocated) subscription element leading to a nullpointer exception. We fix this by removing the subscr_terminate function and terminate the connection immediately upon any subscription failure. Signed-off-by: Erik Hugne <[email protected]> Reviewed-by: Jon Maloy <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 3622c36 commit 7fe8097

File tree

1 file changed

+4
-19
lines changed

1 file changed

+4
-19
lines changed

net/tipc/subscr.c

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,6 @@ static void subscr_del(struct tipc_subscription *sub)
162162
atomic_dec(&tn->subscription_count);
163163
}
164164

165-
/**
166-
* subscr_terminate - terminate communication with a subscriber
167-
*
168-
* Note: Must call it in process context since it might sleep.
169-
*/
170-
static void subscr_terminate(struct tipc_subscription *sub)
171-
{
172-
struct tipc_subscriber *subscriber = sub->subscriber;
173-
struct tipc_net *tn = net_generic(sub->net, tipc_net_id);
174-
175-
tipc_conn_terminate(tn->topsrv, subscriber->conid);
176-
}
177-
178165
static void subscr_release(struct tipc_subscriber *subscriber)
179166
{
180167
struct tipc_subscription *sub;
@@ -312,16 +299,14 @@ static void subscr_conn_msg_event(struct net *net, int conid,
312299
{
313300
struct tipc_subscriber *subscriber = usr_data;
314301
struct tipc_subscription *sub = NULL;
302+
struct tipc_net *tn = net_generic(net, tipc_net_id);
315303

316304
spin_lock_bh(&subscriber->lock);
317-
if (subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber,
318-
&sub) < 0) {
319-
spin_unlock_bh(&subscriber->lock);
320-
subscr_terminate(sub);
321-
return;
322-
}
305+
subscr_subscribe(net, (struct tipc_subscr *)buf, subscriber, &sub);
323306
if (sub)
324307
tipc_nametbl_subscribe(sub);
308+
else
309+
tipc_conn_terminate(tn->topsrv, subscriber->conid);
325310
spin_unlock_bh(&subscriber->lock);
326311
}
327312

0 commit comments

Comments
 (0)