Commit 617504c6 authored by Horatiu Vultur's avatar Horatiu Vultur Committed by David S. Miller

bridge: mrp: Fix out-of-bounds read in br_mrp_parse

The issue was reported by syzbot. When the function br_mrp_parse was
called with a valid net_bridge_port, the net_bridge was an invalid
pointer. Therefore the check br->stp_enabled could pass/fail
depending where it was pointing in memory.
The fix consists of setting the net_bridge pointer if the port is a
valid pointer.

Reported-by: syzbot+9c6f0f1f8e32223df9a4@syzkaller.appspotmail.com
Fixes: 65369933 ("bridge: mrp: Integrate MRP into the bridge")
Signed-off-by: default avatarHoratiu Vultur <horatiu.vultur@microchip.com>
Acked-by: default avatarNikolay Aleksandrov <nikolay@cumulusnetworks.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 07153961
...@@ -27,6 +27,12 @@ int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p, ...@@ -27,6 +27,12 @@ int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p,
struct nlattr *tb[IFLA_BRIDGE_MRP_MAX + 1]; struct nlattr *tb[IFLA_BRIDGE_MRP_MAX + 1];
int err; int err;
/* When this function is called for a port then the br pointer is
* invalid, therefor set the br to point correctly
*/
if (p)
br = p->br;
if (br->stp_enabled != BR_NO_STP) { if (br->stp_enabled != BR_NO_STP) {
NL_SET_ERR_MSG_MOD(extack, "MRP can't be enabled if STP is already enabled"); NL_SET_ERR_MSG_MOD(extack, "MRP can't be enabled if STP is already enabled");
return -EINVAL; return -EINVAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment