net: bridge: multicast: fix igmp/mld port context null pointer dereferences
authorNikolay Aleksandrov <nikolay@nvidia.com>
Wed, 21 Jul 2021 10:06:24 +0000 (13:06 +0300)
committerDavid S. Miller <davem@davemloft.net>
Wed, 21 Jul 2021 16:04:03 +0000 (09:04 -0700)
commit54cb43199e14c1181ddcd4a3782f1f7eb56bdab8
tree2ed34b06307271aceb991f25e54e36a17f189973
parent524df92c1907d31bc2d2643e81c680381d7c6bf8
net: bridge: multicast: fix igmp/mld port context null pointer dereferences

With the recent change to use bridge/port multicast context pointers
instead of bridge/port I missed to convert two locations which pass the
port pointer as-is, but with the new model we need to verify the port
context is non-NULL first and retrieve the port from it. The first
location is when doing querier selection when a query is received, the
second location is when leaving a group. The port context will be null
if the packets originated from the bridge device (i.e. from the host).
The fix is simple just check if the port context exists and retrieve
the port pointer from it.

Fixes: adc47037a7d5 ("net: bridge: multicast: use multicast contexts instead of bridge or port")
Signed-off-by: Nikolay Aleksandrov <nikolay@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_multicast.c