]> git.baikalelectronics.ru Git - kernel.git/commit
bridge: check brport attr show in brport_show
authorXin Long <lucien.xin@gmail.com>
Mon, 12 Feb 2018 09:15:40 +0000 (17:15 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 12 Feb 2018 16:17:28 +0000 (11:17 -0500)
commit911216beb23dcea7fcde5c47466b3181ef80eab6
treeac6ce08d61e478296fa4130e1350d40f2365f702
parent821169a71196121afe2b4cec8d4708c39cb97825
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: c8cebb304d04 ("bridge: add sysfs hook to flush forwarding table")
Reported-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/bridge/br_sysfs_if.c