diff mbox series

[net-next] net: sched: remove duplicate check of user rights in qdisc

Message ID 20220818072500.278410-1-shaozhengchao@huawei.com (mailing list archive)
State Superseded
Delegated to: Netdev Maintainers
Headers show
Series [net-next] net: sched: remove duplicate check of user rights in qdisc | expand

Checks

Context Check Description
netdev/tree_selection success Clearly marked for net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix success Link
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 520 this patch: 520
netdev/cc_maintainers success CCed 8 of 8 maintainers
netdev/build_clang success Errors and warnings before: 5 this patch: 5
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 520 this patch: 520
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 67 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

shaozhengchao Aug. 18, 2022, 7:25 a.m. UTC
In rtnetlink_rcv_msg function, the permission for all user operations
is checked except the GET operation, which is the same as the checking
in qdisc. Therefore, remove the user rights check in qdisc.

Signed-off-by: Zhengchao Shao <shaozhengchao@huawei.com>
---
 net/sched/act_api.c |  4 ----
 net/sched/cls_api.c | 10 ----------
 net/sched/sch_api.c | 11 -----------
 3 files changed, 25 deletions(-)

Comments

Jakub Kicinski Aug. 19, 2022, 3:44 a.m. UTC | #1
On Thu, 18 Aug 2022 15:25:00 +0800 Zhengchao Shao wrote:
> -	if ((n->nlmsg_type != RTM_GETACTION) &&
> -	    !netlink_capable(skb, CAP_NET_ADMIN))
> -		return -EPERM;

This check is not network namespace capable, right?

We're probably fine making it namespace aware but it needs to be a
separate change.
shaozhengchao Aug. 19, 2022, 4:21 a.m. UTC | #2
On 2022/8/19 11:44, Jakub Kicinski wrote:
> On Thu, 18 Aug 2022 15:25:00 +0800 Zhengchao Shao wrote:
>> -	if ((n->nlmsg_type != RTM_GETACTION) &&
>> -	    !netlink_capable(skb, CAP_NET_ADMIN))
>> -		return -EPERM;
> 
> This check is not network namespace capable, right?
> 
> We're probably fine making it namespace aware but it needs to be a
> separate change.

Hi Jakub:
	Thank you for your reply. I will add the wrong deletion back in V2. And 
I will also consider to make checking namespace aware in action function.

Zhengchao Shao
diff mbox series

Patch

diff --git a/net/sched/act_api.c b/net/sched/act_api.c
index 817065aa2833..b69fcde546ba 100644
--- a/net/sched/act_api.c
+++ b/net/sched/act_api.c
@@ -1993,10 +1993,6 @@  static int tc_ctl_action(struct sk_buff *skb, struct nlmsghdr *n,
 	u32 flags = 0;
 	int ret = 0;
 
-	if ((n->nlmsg_type != RTM_GETACTION) &&
-	    !netlink_capable(skb, CAP_NET_ADMIN))
-		return -EPERM;
-
 	ret = nlmsg_parse_deprecated(n, sizeof(struct tcamsg), tca,
 				     TCA_ROOT_MAX, NULL, extack);
 	if (ret < 0)
diff --git a/net/sched/cls_api.c b/net/sched/cls_api.c
index 790d6809be81..1ebab4b11262 100644
--- a/net/sched/cls_api.c
+++ b/net/sched/cls_api.c
@@ -1977,9 +1977,6 @@  static int tc_new_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 	bool rtnl_held = false;
 	u32 flags;
 
-	if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 replay:
 	tp_created = 0;
 
@@ -2208,9 +2205,6 @@  static int tc_del_tfilter(struct sk_buff *skb, struct nlmsghdr *n,
 	int err;
 	bool rtnl_held = false;
 
-	if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 	err = nlmsg_parse_deprecated(n, sizeof(*t), tca, TCA_MAX,
 				     rtm_tca_policy, extack);
 	if (err < 0)
@@ -2826,10 +2820,6 @@  static int tc_ctl_chain(struct sk_buff *skb, struct nlmsghdr *n,
 	unsigned long cl;
 	int err;
 
-	if (n->nlmsg_type != RTM_GETCHAIN &&
-	    !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 replay:
 	q = NULL;
 	err = nlmsg_parse_deprecated(n, sizeof(*t), tca, TCA_MAX,
diff --git a/net/sched/sch_api.c b/net/sched/sch_api.c
index bf87b50837a8..6c687e77d68b 100644
--- a/net/sched/sch_api.c
+++ b/net/sched/sch_api.c
@@ -1424,10 +1424,6 @@  static int tc_get_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
 	struct Qdisc *p = NULL;
 	int err;
 
-	if ((n->nlmsg_type != RTM_GETQDISC) &&
-	    !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 	err = nlmsg_parse_deprecated(n, sizeof(*tcm), tca, TCA_MAX,
 				     rtm_tca_policy, extack);
 	if (err < 0)
@@ -1508,9 +1504,6 @@  static int tc_modify_qdisc(struct sk_buff *skb, struct nlmsghdr *n,
 	struct Qdisc *q, *p;
 	int err;
 
-	if (!netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 replay:
 	/* Reinit, just in case something touches this. */
 	err = nlmsg_parse_deprecated(n, sizeof(*tcm), tca, TCA_MAX,
@@ -1992,10 +1985,6 @@  static int tc_ctl_tclass(struct sk_buff *skb, struct nlmsghdr *n,
 	u32 qid;
 	int err;
 
-	if ((n->nlmsg_type != RTM_GETTCLASS) &&
-	    !netlink_ns_capable(skb, net->user_ns, CAP_NET_ADMIN))
-		return -EPERM;
-
 	err = nlmsg_parse_deprecated(n, sizeof(*tcm), tca, TCA_MAX,
 				     rtm_tca_policy, extack);
 	if (err < 0)