bonding: Display LACP info only to CAP_NET_ADMIN capable user
Subsystems (3)
PATCH v2 1/1 bonding: Display LACP info only to CAP_NET_ADMIN capable user
Actor and Partner details can be accessed via proc-fs, sys-fs entries or netlink interface. These interfaces are world readable at this moment. The earlier patch-series made the LACP communication secure to avoid nuisance attack from within the same L2 domain but it did not prevent "someone unprivileged" looking at that information on host and perform the same act.
This patch essentially avoids spitting those entries if the user in question does not have enough privileges.
--- drivers/net/bonding/bond_netlink.c | 11 ++-- drivers/net/bonding/bond_procfs.c | 101 +++++++++++++++++++------------------ drivers/net/bonding/bond_sysfs.c | 12 ++--- 3 files changed, 67 insertions(+), 57 deletions(-)
drivers/net/bonding/bond_netlink.c +8 -3
@@ -600,18 +600,23 @@ static int bond_fill_info(struct sk_buff *skb,if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info; +u8 zero_mac[ETH_ALEN ]; +eth_zero_addr (zero_mac);if (nla_put_u16 (skb,IFLA_BOND_AD_ACTOR_SYS_PRIO , - bond->params.ad_actor_sys_prio)) +capable (CAP_NET_ADMIN ) ? + bond->params.ad_actor_sys_prio :0 )) goto nla_put_failure;if (nla_put_u16 (skb,IFLA_BOND_AD_USER_PORT_KEY , - bond->params.ad_user_port_key)) +capable (CAP_NET_ADMIN ) ? + bond->params.ad_user_port_key :0 )) goto nla_put_failure;if (nla_put (skb,IFLA_BOND_AD_ACTOR_SYSTEM ,sizeof (bond->params.ad_actor_system), - &bond->params.ad_actor_system)) +capable (CAP_NET_ADMIN ) ? + &bond->params.ad_actor_system : &zero_mac)) goto nla_put_failure;if (!bond_3ad_get_active_agg_info (bond, &info)) {
drivers/net/bonding/bond_procfs.c +53 -48
113 lines not on this page · raw message
drivers/net/bonding/bond_sysfs.c +6 -6
@@ -549,7 +549,7 @@ static ssize_t bonding_show_ad_actor_key(struct device *d,int count =0 ;struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN )) {struct ad_info ad_info; count =sprintf (buf,"%d\n" , bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -569,7 +569,7 @@ static ssize_t bonding_show_ad_partner_key(struct device *d,int count =0 ;struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN )) {struct ad_info ad_info; count =sprintf (buf,"%d\n" , bond_3ad_get_active_agg_info(bond, &ad_info)
@@ -589,7 +589,7 @@ static ssize_t bonding_show_ad_partner_mac(struct device *d,int count =0 ;struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) { +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN )) {struct ad_info ad_info;if (!bond_3ad_get_active_agg_info (bond, &ad_info)) count =sprintf (buf,"%pM\n" , ad_info.partner_system);
@@ -698,7 +698,7 @@ static ssize_t bonding_show_ad_actor_sys_prio(struct device *d, {struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN ))return sprintf (buf,"%hu\n" , bond->params.ad_actor_sys_prio);return 0 ;
@@ -712,7 +712,7 @@ static ssize_t bonding_show_ad_actor_system(struct device *d, {struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN ))return sprintf (buf,"%pM\n" , bond->params.ad_actor_system);return 0 ;
@@ -727,7 +727,7 @@ static ssize_t bonding_show_ad_user_port_key(struct device *d, {struct bonding *bond =to_bond (d); -if (BOND_MODE (bond) ==BOND_MODE_8023AD ) +if (BOND_MODE (bond) ==BOND_MODE_8023AD &&capable (CAP_NET_ADMIN ))return sprintf (buf,"%hu\n" , bond->params.ad_user_port_key);return 0 ;
Signature · 1 line
2.4.3.573.g4eafbef
Quoted 37 lines · Mahesh Bandewar
Actor and Partner details can be accessed via proc-fs, sys-fs entries or netlink interface. These interfaces are world readable at this moment. The earlier patch-series made the LACP communication secure to avoid nuisance attack from within the same L2 domain but it did not prevent "someone unprivileged" looking at that information on host and perform the same act.
This patch essentially avoids spitting those entries if the user in question does not have enough privileges.
Signed-off-by Mahesh Bandewar <[email protected]>--- drivers/net/bonding/bond_netlink.c | 11 ++-- drivers/net/bonding/bond_procfs.c | 101 +++++++++++++++++++------------------ drivers/net/bonding/bond_sysfs.c | 12 ++--- 3 files changed, 67 insertions(+), 57 deletions(-)drivers/net/bonding/bond_netlink.c +5
-2@@ -600,18 +600,23 @@ static int bond_fill_info(struct sk_buff *skb,if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info; +u8 zero_mac[ETH_ALEN ]; +eth_zero_addr (zero_mac);if (nla_put_u16 (skb,IFLA_BOND_AD_ACTOR_SYS_PRIO , - bond->params.ad_actor_sys_prio)) +capable (CAP_NET_ADMIN ) ? + bond->params.ad_actor_sys_prio :0 )) goto nla_put_failure; if (nla_put_u16(skb, IFLA_BOND_AD_USER_PORT_KEY, - bond->params.ad_user_port_key)) + capable(CAP_NET_ADMIN) ?
drivers/net/bonding/bond_netlink.c static int bond_fill_info(struct sk_buff *skb, · line 621
Quoted 10 lines
drivers/net/bonding/bond_netlink.c +3
-1+ bond->params.ad_user_port_key : 0)) goto nla_put_failure;if (nla_put (skb,IFLA_BOND_AD_ACTOR_SYSTEM ,sizeof (bond->params.ad_actor_system), - &bond->params.ad_actor_system)) +capable (CAP_NET_ADMIN ) ? + &bond->params.ad_actor_system : &zero_mac)) goto nla_put_failure;
Hmm... I would rather not send these fake attributes at all ?
Quoted 41 lines · Eric Dumazet
Quoted 40 lines · Mahesh Bandewar
Actor and Partner details can be accessed via proc-fs, sys-fs entries or netlink interface. These interfaces are world readable at this moment. The earlier patch-series made the LACP communication secure to avoid nuisance attack from within the same L2 domain but it did not prevent "someone unprivileged" looking at that information on host and perform the same act.
This patch essentially avoids spitting those entries if the user in question does not have enough privileges.
Signed-off-by Mahesh Bandewar <[email protected]>--- drivers/net/bonding/bond_netlink.c | 11 ++-- drivers/net/bonding/bond_procfs.c | 101 +++++++++++++++++++------------------ drivers/net/bonding/bond_sysfs.c | 12 ++--- 3 files changed, 67 insertions(+), 57 deletions(-)drivers/net/bonding/bond_netlink.c +6
-2@@ -600,18 +600,23 @@ static int bond_fill_info(struct sk_buff *skb,if (BOND_MODE (bond) ==BOND_MODE_8023AD ) {struct ad_info info; +u8 zero_mac[ETH_ALEN ]; +eth_zero_addr (zero_mac);if (nla_put_u16 (skb,IFLA_BOND_AD_ACTOR_SYS_PRIO , - bond->params.ad_actor_sys_prio)) +capable (CAP_NET_ADMIN ) ? + bond->params.ad_actor_sys_prio :0 )) goto nla_put_failure;if (nla_put_u16 (skb,IFLA_BOND_AD_USER_PORT_KEY , - bond->params.ad_user_port_key)) +capable (CAP_NET_ADMIN ) ? + bond->params.ad_user_port_key :0 )) goto nla_put_failure;
Quoted 9 lines
drivers/net/bonding/bond_netlink.c static int bond_fill_info(struct sk_buff *skb, · line 621
Quoted 7 lines
drivers/net/bonding/bond_netlink.c +2
-1if (nla_put (skb,IFLA_BOND_AD_ACTOR_SYSTEM ,sizeof (bond->params.ad_actor_system), - &bond->params.ad_actor_system)) +capable (CAP_NET_ADMIN ) ? + &bond->params.ad_actor_system : &zero_mac)) goto nla_put_failure;Hmm... I would rather not send these fake attributes at all ?
That would be my preference as well. Sorry if my lack of elaboration on on my earlier email made this confusing.
If there are values that should not be visible to non-root users, then don't send them at all. Do not just send NULL values.
Quoted 9 lines
Quoted 2 lines
Hmm... I would rather not send these fake attributes at all ?
That would be my preference as well. Sorry if my lack of elaboration on on my earlier email made this confusing.
If there are values that should not be visible to non-root users, then don't send them at all. Do not just send NULL values.
OK, would change this in the next rev.
Thanks,