Skip to content

Commit 1b12580

Browse files
lxindavem330
authored andcommitted
bridge: check brport attr show in brport_show
Now br_sysfs_if file flush doesn't have attr show. To read it will cause kernel panic after users chmod u+r this file. Xiong found this issue when running the commands: ip link add br0 type bridge ip link add type veth ip link set veth0 master br0 chmod u+r /sys/devices/virtual/net/veth0/brport/flush timeout 3 cat /sys/devices/virtual/net/veth0/brport/flush kernel crashed with NULL a pointer dereference call trace. This patch is to fix it by return -EINVAL when brport_attr->show is null, just the same as the check for brport_attr->store in brport_store(). Fixes: 9cf6374 ("bridge: add sysfs hook to flush forwarding table") Reported-by: Xiong Zhou <[email protected]> Signed-off-by: Xin Long <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 7ac8ff9 commit 1b12580

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

net/bridge/br_sysfs_if.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,9 @@ static ssize_t brport_show(struct kobject *kobj,
255255
struct brport_attribute *brport_attr = to_brport_attr(attr);
256256
struct net_bridge_port *p = to_brport(kobj);
257257

258+
if (!brport_attr->show)
259+
return -EINVAL;
260+
258261
return brport_attr->show(p, buf);
259262
}
260263

0 commit comments

Comments
 (0)