net_sched: Remove broken tc actions
Subsystems (3)
cover net_sched: Remove broken tc actions
While auditing the code to make certain it would be safe to enable the user namespace root to use tc actions I stumbled on the strange fact that two of the tc modules in the kernel have been broken for more years than I care to think about.
In particular neither of these two modules implements the tc_action_ops lookup method. Which means that in practice neither RTM_GETACTION nor RTM_DELACTION work. And with RTM_DELACTION broken that looks like a permanent leak of kernel memory to me.
A leak I am not happy at root having and certainly not something I want to allow unprivileged users access to.
On the premise that 5+ years is too long to wait for someone to notice, complain and get this code fixed let's just remove these broken tc modules.
Eric W. Biederman (2):
net_sched: Remove broken act_skbedit
net_sched: Remove broken act_simple
include/net/tc_act/tc_defact.h | 14 -- include/net/tc_act/tc_skbedit.h | 36 ----- include/uapi/linux/tc_act/Kbuild | 2 - include/uapi/linux/tc_act/tc_defact.h | 19 --- include/uapi/linux/tc_act/tc_skbedit.h | 46 ------- net/sched/Kconfig | 25 ---- net/sched/Makefile | 2 - net/sched/act_simple.c | 225 -------------------------------- net/sched/act_skbedit.c | 224 ------------------------------- 9 files changed, 0 insertions(+), 593 deletions(-)
PATCH 1/2 net_sched: Remove broken act_skbedit
While reading through the code I noticed that act_skbedit does not implement a .lookup function in act_skbedit_ops.
In practice this means that RTM_GETACTION and RTM_DELACTION will always fail for skbedit actions. This has been the case since at least 2.6.12-rc1 well before this code was added. Which means in practice this code does not work and has never worked.
Since the code has been in the tree and broken for 5 years and no one has noticed it seems reasonable to delete the code.
--- include/net/tc_act/tc_skbedit.h | 36 ----- include/uapi/linux/tc_act/Kbuild | 1 - include/uapi/linux/tc_act/tc_skbedit.h | 46 ------- net/sched/Kconfig | 11 -- net/sched/Makefile | 1 - net/sched/act_skbedit.c | 224 -------------------------------- 6 files changed, 0 insertions(+), 319 deletions(-) delete mode 100644 include/net/tc_act/tc_skbedit.h delete mode 100644 include/uapi/linux/tc_act/tc_skbedit.h delete mode 100644 net/sched/act_skbedit.c
include/net/tc_act/tc_skbedit.h deleted +0 -36
@@ -1,36 +0,0 @@ -/* -* Copyright (c) 2008, Intel Corporation. -* -* This program is free software; you can redistribute it and/or modify it -* under the terms and conditions of the GNU General Public License, -* version 2, as published by the Free Software Foundation. -* -* This program is distributed in the hope it will be useful, but WITHOUT -* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for -* more details. -* -* You should have received a copy of the GNU General Public License along with -* this program; if not, write to the Free Software Foundation, Inc., 59 Temple -* Place - Suite 330, Boston, MA 02111-1307 USA. -* -* Author: Alexander Duyck <[email protected]> -*/ - -#ifndef __NET_TC_SKBEDIT_H -#define __NET_TC_SKBEDIT_H - -#include <net/act_api.h> - -struct tcf_skbedit { -struct tcf_common common; -u32 flags; -u32 priority; -u32 mark; -u16 queue_mapping; -/* XXX: 16-bit pad here? */ -}; -#define to_skbedit (pc) \ - container_of(pc, struct tcf_skbedit, common) - -#endif /* __NET_TC_SKBEDIT_H */
include/uapi/linux/tc_act/Kbuild +0 -1
@@ -6,4 +6,3 @@ header-y += tc_ipt.h header-y += tc_mirred.h header-y += tc_nat.h header-y += tc_pedit.h -header-y += tc_skbedit.h
include/uapi/linux/tc_act/tc_skbedit.h deleted +0 -46
46 lines not on this page · raw message
net/sched/Kconfig +0 -11
@@ -632,17 +632,6 @@ config NET_ACT_SIMP To compile this code as a module, choose M here: the module will be called act_simple. -config NET_ACT_SKBEDIT - tristate "SKB Editing" - depends on NET_CLS_ACT - ---help--- - Say Y here to change skb priority or queue_mapping settings. - - If unsure, say N. - - To compile this code as a module, choose M here: the - module will be called act_skbedit. - config NET_ACT_CSUM tristate "Checksum Updating" depends on NET_CLS_ACT && INET
net/sched/Makefile +0 -1
@@ -14,7 +14,6 @@ obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o obj-$(CONFIG_NET_ACT_NAT) += act_nat.o obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o -obj-$(CONFIG_NET_ACT_SKBEDIT) += act_skbedit.o obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
net/sched/act_skbedit.c deleted +0 -224
224 lines not on this page · raw message
Signature · 1 line
1.7.5.4
PATCH 2/2 net_sched: Remove broken act_simple
In reply to Eric W. BiedermanWhile reading through the code I noticed that act_simple does not implement a .lookup function in act_simp_ops.
In practice this means that RTM_GETACTION and RTM_DELACTION will always fail for "simple" actions. This has been the case since at least 2.6.12-rc1. Which means this code has been broken for more years than I care to think about.
On the principle that a broken example is worse than no example delete this code.
--- include/net/tc_act/tc_defact.h | 14 -- include/uapi/linux/tc_act/Kbuild | 1 - include/uapi/linux/tc_act/tc_defact.h | 19 --- net/sched/Kconfig | 14 -- net/sched/Makefile | 1 - net/sched/act_simple.c | 225 --------------------------------- 6 files changed, 0 insertions(+), 274 deletions(-) delete mode 100644 include/net/tc_act/tc_defact.h delete mode 100644 include/uapi/linux/tc_act/tc_defact.h delete mode 100644 net/sched/act_simple.c
include/net/tc_act/tc_defact.h deleted +0 -14
@@ -1,14 +0,0 @@ -#ifndef __NET_TC_DEF_H -#define __NET_TC_DEF_H - -#include <net/act_api.h> - -struct tcf_defact { -struct tcf_common common; -u32 tcfd_datalen; -void *tcfd_defdata; -}; -#define to_defact (pc) \ - container_of(pc, struct tcf_defact, common) - -#endif /* __NET_TC_DEF_H */
include/uapi/linux/tc_act/Kbuild +0 -1
@@ -1,6 +1,5 @@ # UAPI Header export list header-y += tc_csum.h -header-y += tc_defact.h header-y += tc_gact.h header-y += tc_ipt.h header-y += tc_mirred.h
include/uapi/linux/tc_act/tc_defact.h deleted +0 -19
@@ -1,19 +0,0 @@ -#ifndef __LINUX_TC_DEF_H -#define __LINUX_TC_DEF_H - -#include <linux/pkt_cls.h> - -struct tc_defact { -tc_gen ; -}; - -enum { -TCA_DEF_UNSPEC , -TCA_DEF_TM , -TCA_DEF_PARMS , -TCA_DEF_DATA , - __TCA_DEF_MAX -}; -#define TCA_DEF_MAX (__TCA_DEF_MAX - 1) - -#endif
net/sched/Kconfig +0 -14
@@ -618,20 +618,6 @@ config NET_ACT_PEDIT To compile this code as a module, choose M here: the module will be called act_pedit. -config NET_ACT_SIMP - tristate "Simple Example (Debug)" - depends on NET_CLS_ACT - ---help--- - Say Y here to add a simple action for demonstration purposes. - It is meant as an example and for debugging purposes. It will - print a configured policy string followed by the packet count - to the console for every packet that passes by. - - If unsure, say N. - - To compile this code as a module, choose M here: the - module will be called act_simple. - config NET_ACT_CSUM tristate "Checksum Updating" depends on NET_CLS_ACT && INET
net/sched/Makefile +0 -1
@@ -13,7 +13,6 @@ obj-$(CONFIG_NET_ACT_MIRRED) += act_mirred.o obj-$(CONFIG_NET_ACT_IPT) += act_ipt.o obj-$(CONFIG_NET_ACT_NAT) += act_nat.o obj-$(CONFIG_NET_ACT_PEDIT) += act_pedit.o -obj-$(CONFIG_NET_ACT_SIMP) += act_simple.o obj-$(CONFIG_NET_ACT_CSUM) += act_csum.o obj-$(CONFIG_NET_SCH_FIFO) += sch_fifo.o obj-$(CONFIG_NET_SCH_CBQ) += sch_cbq.o
net/sched/act_simple.c deleted +0 -225
225 lines not on this page · raw message
Signature · 1 line
1.7.5.4
Jamal Hadi Salim
maintainerQuoted 12 lines · Eric W. Biederman
While auditing the code to make certain it would be safe to enable the user namespace root to use tc actions I stumbled on the strange fact that two of the tc modules in the kernel have been broken for more years than I care to think about.
In particular neither of these two modules implements the
tc_action_opslookup method. Which means that in practice neitherRTM_GETACTIONnorRTM_DELACTIONwork. And withRTM_DELACTIONbroken that looks like a permanent leak of kernel memory to me.
Quoted 7 lines
A leak I am not happy at root having and certainly not something I want to allow unprivileged users access to.
On the premise that 5+ years is too long to wait for someone to notice, complain and get this code fixed let's just remove these broken tc modules.
Nah, dude.
You dont have to implement the get/del. Actions are typically bound to filters; when the filters disappears the action is destroyed. You Get the filter, you Get the bound actions.
you can add actions without filters - but in such a case, for both of these ones you picked, you can dump or flush them unless they are bound to a filter. Thats the minimal requirement (which is met).
What is your use case to need explicit get/del? Given act_simple is pedagogical in nature, I think that will be useful for illustration purposes.
cheers,
jamal
Quoted 30 lines · Jamal Hadi Salim
Quoted 12 lines · Eric W. Biederman
While auditing the code to make certain it would be safe to enable the user namespace root to use tc actions I stumbled on the strange fact that two of the tc modules in the kernel have been broken for more years than I care to think about.
In particular neither of these two modules implements the
tc_action_opslookup method. Which means that in practice neitherRTM_GETACTIONnorRTM_DELACTIONwork. And withRTM_DELACTIONbroken that looks like a permanent leak of kernel memory to me.Quoted 7 lines
A leak I am not happy at root having and certainly not something I want to allow unprivileged users access to.
On the premise that 5+ years is too long to wait for someone to notice, complain and get this code fixed let's just remove these broken tc modules.
Nah, dude.
You dont have to implement the get/del. Actions are typically bound to filters; when the filters disappears the action is destroyed. You Get the filter, you Get the bound actions.
you can add actions without filters - but in such a case, for both of these ones you picked, you can dump or flush them unless they are bound to a filter. Thats the minimal requirement (which is met).
Quoted 6 lines
What is your use case to need explicit get/del? Given
act_simpleis pedagogical in nature, I think that will be useful for illustration purposes.cheers,
jamal
The primary use case for act_skbedit was to have it associated with a filter. I based it off of act_simple so it isn't surprising that it inherited this issue.
Quoted 1 line
From what I can tell all of the other actions are just using
tcf_hash_search for lookup. Is there anything special that is needed in order to add the lookup call, or could we just add a one liner associating simple and skbedit lookup with tcf_hash_search?
Thanks,
Alex
Jamal Hadi Salim
maintainerQuoted 3 lines · Alexander Duyck
The primary use case for
act_skbeditwas to have it associated with a filter. I based it off ofact_simpleso it isn't surprising that it inherited this issue.
Thats almost 100% of the use cases.
Quoted 6 lines
From what I can tell all of the other actions are just using
tcf_hash_searchfor lookup. Is there anything special that is needed in order to add the lookup call, or could we just add a one liner associating simple and skbedit lookup withtcf_hash_search?
Yes, that would do it. But dont bother - let me just send a generic patch that will assume that for any other action that doesnt do it. Will do it likely tomorow.
cheers,
jamal