* [PATCH net] bridge: check brport attr show in brport_show
@ 2018-02-12 9:15 Xin Long
2018-02-12 16:19 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Xin Long @ 2018-02-12 9:15 UTC (permalink / raw)
To: network dev; +Cc: davem, Stephen Hemminger
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: 9cf637473c85 ("bridge: add sysfs hook to flush forwarding table")
Reported-by: Xiong Zhou <xzhou@redhat.com>
Signed-off-by: Xin Long <lucien.xin@gmail.com>
---
net/bridge/br_sysfs_if.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/net/bridge/br_sysfs_if.c b/net/bridge/br_sysfs_if.c
index 0254c35..126a8ea 100644
--- a/net/bridge/br_sysfs_if.c
+++ b/net/bridge/br_sysfs_if.c
@@ -255,6 +255,9 @@ static ssize_t brport_show(struct kobject *kobj,
struct brport_attribute *brport_attr = to_brport_attr(attr);
struct net_bridge_port *p = to_brport(kobj);
+ if (!brport_attr->show)
+ return -EINVAL;
+
return brport_attr->show(p, buf);
}
--
2.1.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net] bridge: check brport attr show in brport_show
2018-02-12 9:15 [PATCH net] bridge: check brport attr show in brport_show Xin Long
@ 2018-02-12 16:19 ` David Miller
0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2018-02-12 16:19 UTC (permalink / raw)
To: lucien.xin; +Cc: netdev, shemminger
From: Xin Long <lucien.xin@gmail.com>
Date: Mon, 12 Feb 2018 17:15:40 +0800
> 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: 9cf637473c85 ("bridge: add sysfs hook to flush forwarding table")
> Reported-by: Xiong Zhou <xzhou@redhat.com>
> Signed-off-by: Xin Long <lucien.xin@gmail.com>
Applied and queued up for -stable, thank you.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-02-12 16:20 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-12 9:15 [PATCH net] bridge: check brport attr show in brport_show Xin Long
2018-02-12 16:19 ` David Miller
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.