* [PATCH 0/3] net: netlink info leak fixes
@ 2013-03-09 15:52 Mathias Krause
2013-03-09 15:52 ` [PATCH 1/3] bridge: fix mdb info leaks Mathias Krause
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Mathias Krause @ 2013-03-09 15:52 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Mathias Krause
Hi Dave,
a few more info leak fixes -- this time in rtnl.
Please apply!
Mathias Krause (3):
bridge: fix mdb info leaks
rtnl: fix info leak on RTM_GETLINK request for VF devices
dcbnl: fix various netlink info leaks
net/bridge/br_mdb.c | 4 ++++
net/core/rtnetlink.c | 1 +
net/dcb/dcbnl.c | 8 ++++++++
3 files changed, 13 insertions(+)
--
1.7.10.4
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/3] bridge: fix mdb info leaks
2013-03-09 15:52 [PATCH 0/3] net: netlink info leak fixes Mathias Krause
@ 2013-03-09 15:52 ` Mathias Krause
2013-03-09 15:52 ` [PATCH 2/3] rtnl: fix info leak on RTM_GETLINK request for VF devices Mathias Krause
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-03-09 15:52 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Mathias Krause, Stephen Hemminger
The bridging code discloses heap and stack bytes via the RTM_GETMDB
netlink interface and via the notify messages send to group RTNLGRP_MDB
afer a successful add/del.
Fix both cases by initializing all unset members/padding bytes with
memset(0).
Cc: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
net/bridge/br_mdb.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index 9f97b85..ee79f3f 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -80,6 +80,7 @@ static int br_mdb_fill_info(struct sk_buff *skb, struct netlink_callback *cb,
port = p->port;
if (port) {
struct br_mdb_entry e;
+ memset(&e, 0, sizeof(e));
e.ifindex = port->dev->ifindex;
e.state = p->state;
if (p->addr.proto == htons(ETH_P_IP))
@@ -136,6 +137,7 @@ static int br_mdb_dump(struct sk_buff *skb, struct netlink_callback *cb)
break;
bpm = nlmsg_data(nlh);
+ memset(bpm, 0, sizeof(*bpm));
bpm->ifindex = dev->ifindex;
if (br_mdb_fill_info(skb, cb, dev) < 0)
goto out;
@@ -171,6 +173,7 @@ static int nlmsg_populate_mdb_fill(struct sk_buff *skb,
return -EMSGSIZE;
bpm = nlmsg_data(nlh);
+ memset(bpm, 0, sizeof(*bpm));
bpm->family = AF_BRIDGE;
bpm->ifindex = dev->ifindex;
nest = nla_nest_start(skb, MDBA_MDB);
@@ -228,6 +231,7 @@ void br_mdb_notify(struct net_device *dev, struct net_bridge_port *port,
{
struct br_mdb_entry entry;
+ memset(&entry, 0, sizeof(entry));
entry.ifindex = port->dev->ifindex;
entry.addr.proto = group->proto;
entry.addr.u.ip4 = group->u.ip4;
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/3] rtnl: fix info leak on RTM_GETLINK request for VF devices
2013-03-09 15:52 [PATCH 0/3] net: netlink info leak fixes Mathias Krause
2013-03-09 15:52 ` [PATCH 1/3] bridge: fix mdb info leaks Mathias Krause
@ 2013-03-09 15:52 ` Mathias Krause
2013-03-09 15:52 ` [PATCH 3/3] dcbnl: fix various netlink info leaks Mathias Krause
2013-03-10 9:20 ` [PATCH 0/3] net: netlink info leak fixes David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-03-09 15:52 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Mathias Krause
Initialize the mac address buffer with 0 as the driver specific function
will probably not fill the whole buffer. In fact, all in-kernel drivers
fill only ETH_ALEN of the MAX_ADDR_LEN bytes, i.e. 6 of the 32 possible
bytes. Therefore we currently leak 26 bytes of stack memory to userland
via the netlink interface.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
net/core/rtnetlink.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index b376410..a585d45 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -979,6 +979,7 @@ static int rtnl_fill_ifinfo(struct sk_buff *skb, struct net_device *dev,
* report anything.
*/
ivi.spoofchk = -1;
+ memset(ivi.mac, 0, sizeof(ivi.mac));
if (dev->netdev_ops->ndo_get_vf_config(dev, i, &ivi))
break;
vf_mac.vf =
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 3/3] dcbnl: fix various netlink info leaks
2013-03-09 15:52 [PATCH 0/3] net: netlink info leak fixes Mathias Krause
2013-03-09 15:52 ` [PATCH 1/3] bridge: fix mdb info leaks Mathias Krause
2013-03-09 15:52 ` [PATCH 2/3] rtnl: fix info leak on RTM_GETLINK request for VF devices Mathias Krause
@ 2013-03-09 15:52 ` Mathias Krause
2013-03-10 9:20 ` [PATCH 0/3] net: netlink info leak fixes David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Mathias Krause @ 2013-03-09 15:52 UTC (permalink / raw)
To: David S. Miller; +Cc: netdev, Mathias Krause
The dcb netlink interface leaks stack memory in various places:
* perm_addr[] buffer is only filled at max with 12 of the 32 bytes but
copied completely,
* no in-kernel driver fills all fields of an IEEE 802.1Qaz subcommand,
so we're leaking up to 58 bytes for ieee_ets structs, up to 136 bytes
for ieee_pfc structs, etc.,
* the same is true for CEE -- no in-kernel driver fills the whole
struct,
Prevent all of the above stack info leaks by properly initializing the
buffers/structures involved.
Signed-off-by: Mathias Krause <minipli@googlemail.com>
---
net/dcb/dcbnl.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c
index 1b588e2..21291f1 100644
--- a/net/dcb/dcbnl.c
+++ b/net/dcb/dcbnl.c
@@ -284,6 +284,7 @@ static int dcbnl_getperm_hwaddr(struct net_device *netdev, struct nlmsghdr *nlh,
if (!netdev->dcbnl_ops->getpermhwaddr)
return -EOPNOTSUPP;
+ memset(perm_addr, 0, sizeof(perm_addr));
netdev->dcbnl_ops->getpermhwaddr(netdev, perm_addr);
return nla_put(skb, DCB_ATTR_PERM_HWADDR, sizeof(perm_addr), perm_addr);
@@ -1042,6 +1043,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
if (ops->ieee_getets) {
struct ieee_ets ets;
+ memset(&ets, 0, sizeof(ets));
err = ops->ieee_getets(netdev, &ets);
if (!err &&
nla_put(skb, DCB_ATTR_IEEE_ETS, sizeof(ets), &ets))
@@ -1050,6 +1052,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
if (ops->ieee_getmaxrate) {
struct ieee_maxrate maxrate;
+ memset(&maxrate, 0, sizeof(maxrate));
err = ops->ieee_getmaxrate(netdev, &maxrate);
if (!err) {
err = nla_put(skb, DCB_ATTR_IEEE_MAXRATE,
@@ -1061,6 +1064,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
if (ops->ieee_getpfc) {
struct ieee_pfc pfc;
+ memset(&pfc, 0, sizeof(pfc));
err = ops->ieee_getpfc(netdev, &pfc);
if (!err &&
nla_put(skb, DCB_ATTR_IEEE_PFC, sizeof(pfc), &pfc))
@@ -1094,6 +1098,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
/* get peer info if available */
if (ops->ieee_peer_getets) {
struct ieee_ets ets;
+ memset(&ets, 0, sizeof(ets));
err = ops->ieee_peer_getets(netdev, &ets);
if (!err &&
nla_put(skb, DCB_ATTR_IEEE_PEER_ETS, sizeof(ets), &ets))
@@ -1102,6 +1107,7 @@ static int dcbnl_ieee_fill(struct sk_buff *skb, struct net_device *netdev)
if (ops->ieee_peer_getpfc) {
struct ieee_pfc pfc;
+ memset(&pfc, 0, sizeof(pfc));
err = ops->ieee_peer_getpfc(netdev, &pfc);
if (!err &&
nla_put(skb, DCB_ATTR_IEEE_PEER_PFC, sizeof(pfc), &pfc))
@@ -1280,6 +1286,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
/* peer info if available */
if (ops->cee_peer_getpg) {
struct cee_pg pg;
+ memset(&pg, 0, sizeof(pg));
err = ops->cee_peer_getpg(netdev, &pg);
if (!err &&
nla_put(skb, DCB_ATTR_CEE_PEER_PG, sizeof(pg), &pg))
@@ -1288,6 +1295,7 @@ static int dcbnl_cee_fill(struct sk_buff *skb, struct net_device *netdev)
if (ops->cee_peer_getpfc) {
struct cee_pfc pfc;
+ memset(&pfc, 0, sizeof(pfc));
err = ops->cee_peer_getpfc(netdev, &pfc);
if (!err &&
nla_put(skb, DCB_ATTR_CEE_PEER_PFC, sizeof(pfc), &pfc))
--
1.7.10.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/3] net: netlink info leak fixes
2013-03-09 15:52 [PATCH 0/3] net: netlink info leak fixes Mathias Krause
` (2 preceding siblings ...)
2013-03-09 15:52 ` [PATCH 3/3] dcbnl: fix various netlink info leaks Mathias Krause
@ 2013-03-10 9:20 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2013-03-10 9:20 UTC (permalink / raw)
To: minipli; +Cc: netdev
From: Mathias Krause <minipli@googlemail.com>
Date: Sat, 9 Mar 2013 16:52:18 +0100
> a few more info leak fixes -- this time in rtnl.
>
> Please apply!
All applied and queued up for -stable, thanks!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2013-03-10 9:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-09 15:52 [PATCH 0/3] net: netlink info leak fixes Mathias Krause
2013-03-09 15:52 ` [PATCH 1/3] bridge: fix mdb info leaks Mathias Krause
2013-03-09 15:52 ` [PATCH 2/3] rtnl: fix info leak on RTM_GETLINK request for VF devices Mathias Krause
2013-03-09 15:52 ` [PATCH 3/3] dcbnl: fix various netlink info leaks Mathias Krause
2013-03-10 9:20 ` [PATCH 0/3] net: netlink info leak fixes David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).