Message ID | 20230915134408.3410595-1-make_ruc2021@163.com (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | Netdev Maintainers |
Headers | show |
Series | net: sched: hfsc: dont intepret cls results when asked to drop | expand |
Hi Ma,
kernel test robot noticed the following build warnings:
[auto build test WARNING on net-next/main]
[also build test WARNING on net/main linus/master v6.6-rc1 next-20230915]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-Ke/net-sched-hfsc-dont-intepret-cls-results-when-asked-to-drop/20230915-214635
base: net-next/main
patch link: https://lore.kernel.org/r/20230915134408.3410595-1-make_ruc2021%40163.com
patch subject: [PATCH] net: sched: hfsc: dont intepret cls results when asked to drop
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20230916/202309160007.7615P5Df-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230916/202309160007.7615P5Df-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309160007.7615P5Df-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from include/linux/compiler_types.h:80,
from <command-line>:
net/sched/sch_hfsc.c: In function 'hfsc_classify':
>> include/linux/compiler_attributes.h:227:41: warning: attribute 'fallthrough' not preceding a case label or default label
227 | # define fallthrough __attribute__((__fallthrough__))
| ^~~~~~~~~~~~~
net/sched/sch_hfsc.c:1146:25: note: in expansion of macro 'fallthrough'
1146 | fallthrough;
| ^~~~~~~~~~~
vim +/fallthrough +227 include/linux/compiler_attributes.h
294f69e662d157 Joe Perches 2019-10-05 214
294f69e662d157 Joe Perches 2019-10-05 215 /*
294f69e662d157 Joe Perches 2019-10-05 216 * Add the pseudo keyword 'fallthrough' so case statement blocks
294f69e662d157 Joe Perches 2019-10-05 217 * must end with any of these keywords:
294f69e662d157 Joe Perches 2019-10-05 218 * break;
294f69e662d157 Joe Perches 2019-10-05 219 * fallthrough;
ca0760e7d79e2b Wei Ming Chen 2021-05-06 220 * continue;
294f69e662d157 Joe Perches 2019-10-05 221 * goto <label>;
294f69e662d157 Joe Perches 2019-10-05 222 * return [expression];
294f69e662d157 Joe Perches 2019-10-05 223 *
294f69e662d157 Joe Perches 2019-10-05 224 * gcc: https://gcc.gnu.org/onlinedocs/gcc/Statement-Attributes.html#Statement-Attributes
294f69e662d157 Joe Perches 2019-10-05 225 */
294f69e662d157 Joe Perches 2019-10-05 226 #if __has_attribute(__fallthrough__)
294f69e662d157 Joe Perches 2019-10-05 @227 # define fallthrough __attribute__((__fallthrough__))
294f69e662d157 Joe Perches 2019-10-05 228 #else
294f69e662d157 Joe Perches 2019-10-05 229 # define fallthrough do {} while (0) /* fallthrough */
a3f8a30f3f0079 Miguel Ojeda 2018-08-30 230 #endif
a3f8a30f3f0079 Miguel Ojeda 2018-08-30 231
Hi Ma,
kernel test robot noticed the following build errors:
[auto build test ERROR on net-next/main]
[also build test ERROR on net/main linus/master v6.6-rc1 next-20230915]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Ma-Ke/net-sched-hfsc-dont-intepret-cls-results-when-asked-to-drop/20230915-214635
base: net-next/main
patch link: https://lore.kernel.org/r/20230915134408.3410595-1-make_ruc2021%40163.com
patch subject: [PATCH] net: sched: hfsc: dont intepret cls results when asked to drop
config: x86_64-rhel-8.3-rust (https://download.01.org/0day-ci/archive/20230916/202309161941.5lMYMKdM-lkp@intel.com/config)
compiler: clang version 16.0.4 (https://github.com/llvm/llvm-project.git ae42196bc493ffe877a7e3dff8be32035dea4d07)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20230916/202309161941.5lMYMKdM-lkp@intel.com/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202309161941.5lMYMKdM-lkp@intel.com/
All errors (new ones prefixed by >>):
>> net/sched/sch_hfsc.c:1146:4: error: fallthrough annotation does not directly precede switch label
fallthrough;
^
include/linux/compiler_attributes.h:227:41: note: expanded from macro 'fallthrough'
# define fallthrough __attribute__((__fallthrough__))
^
1 error generated.
vim +1146 net/sched/sch_hfsc.c
^1da177e4c3f41 Linus Torvalds 2005-04-16 1119
^1da177e4c3f41 Linus Torvalds 2005-04-16 1120 static struct hfsc_class *
^1da177e4c3f41 Linus Torvalds 2005-04-16 1121 hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1122 {
^1da177e4c3f41 Linus Torvalds 2005-04-16 1123 struct hfsc_sched *q = qdisc_priv(sch);
a2f79227138c71 Patrick McHardy 2010-05-14 1124 struct hfsc_class *head, *cl;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1125 struct tcf_result res;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1126 struct tcf_proto *tcf;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1127 int result;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1128
^1da177e4c3f41 Linus Torvalds 2005-04-16 1129 if (TC_H_MAJ(skb->priority ^ sch->handle) == 0 &&
^1da177e4c3f41 Linus Torvalds 2005-04-16 1130 (cl = hfsc_find_class(skb->priority, sch)) != NULL)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1131 if (cl->level == 0)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1132 return cl;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1133
c27f339af90bb8 Jarek Poplawski 2008-08-04 1134 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_BYPASS;
a2f79227138c71 Patrick McHardy 2010-05-14 1135 head = &q->root;
25d8c0d55f241c John Fastabend 2014-09-12 1136 tcf = rcu_dereference_bh(q->root.filter_list);
3aa2605594556c Davide Caratti 2021-07-28 1137 while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) {
b633b393d00632 Ma Ke 2023-09-15 1138 if (result == TC_ACT_SHOT)
b633b393d00632 Ma Ke 2023-09-15 1139 return NULL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1140 #ifdef CONFIG_NET_CLS_ACT
^1da177e4c3f41 Linus Torvalds 2005-04-16 1141 switch (result) {
^1da177e4c3f41 Linus Torvalds 2005-04-16 1142 case TC_ACT_QUEUED:
^1da177e4c3f41 Linus Torvalds 2005-04-16 1143 case TC_ACT_STOLEN:
e25ea21ffa66a0 Jiri Pirko 2017-06-06 1144 case TC_ACT_TRAP:
378a2f090f7a47 Jarek Poplawski 2008-08-04 1145 *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN;
964201de695b8a Gustavo A. R. Silva 2020-07-07 @1146 fallthrough;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1147 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1148 #endif
cc7ec456f82da7 Eric Dumazet 2011-01-19 1149 cl = (struct hfsc_class *)res.class;
cc7ec456f82da7 Eric Dumazet 2011-01-19 1150 if (!cl) {
cc7ec456f82da7 Eric Dumazet 2011-01-19 1151 cl = hfsc_find_class(res.classid, sch);
cc7ec456f82da7 Eric Dumazet 2011-01-19 1152 if (!cl)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1153 break; /* filter selected invalid classid */
a2f79227138c71 Patrick McHardy 2010-05-14 1154 if (cl->level >= head->level)
a2f79227138c71 Patrick McHardy 2010-05-14 1155 break; /* filter may only point downwards */
^1da177e4c3f41 Linus Torvalds 2005-04-16 1156 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1157
^1da177e4c3f41 Linus Torvalds 2005-04-16 1158 if (cl->level == 0)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1159 return cl; /* hit leaf class */
^1da177e4c3f41 Linus Torvalds 2005-04-16 1160
^1da177e4c3f41 Linus Torvalds 2005-04-16 1161 /* apply inner filter chain */
25d8c0d55f241c John Fastabend 2014-09-12 1162 tcf = rcu_dereference_bh(cl->filter_list);
a2f79227138c71 Patrick McHardy 2010-05-14 1163 head = cl;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1164 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1165
^1da177e4c3f41 Linus Torvalds 2005-04-16 1166 /* classification failed, try default class */
^1da177e4c3f41 Linus Torvalds 2005-04-16 1167 cl = hfsc_find_class(TC_H_MAKE(TC_H_MAJ(sch->handle), q->defcls), sch);
^1da177e4c3f41 Linus Torvalds 2005-04-16 1168 if (cl == NULL || cl->level > 0)
^1da177e4c3f41 Linus Torvalds 2005-04-16 1169 return NULL;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1170
^1da177e4c3f41 Linus Torvalds 2005-04-16 1171 return cl;
^1da177e4c3f41 Linus Torvalds 2005-04-16 1172 }
^1da177e4c3f41 Linus Torvalds 2005-04-16 1173
diff --git a/net/sched/sch_hfsc.c b/net/sched/sch_hfsc.c index 3554085bc2be..8e07a215f7d1 100644 --- a/net/sched/sch_hfsc.c +++ b/net/sched/sch_hfsc.c @@ -1135,6 +1135,8 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) head = &q->root; tcf = rcu_dereference_bh(q->root.filter_list); while (tcf && (result = tcf_classify(skb, NULL, tcf, &res, false)) >= 0) { + if (result == TC_ACT_SHOT) + return NULL; #ifdef CONFIG_NET_CLS_ACT switch (result) { case TC_ACT_QUEUED: @@ -1142,8 +1144,6 @@ hfsc_classify(struct sk_buff *skb, struct Qdisc *sch, int *qerr) case TC_ACT_TRAP: *qerr = NET_XMIT_SUCCESS | __NET_XMIT_STOLEN; fallthrough; - case TC_ACT_SHOT: - return NULL; } #endif cl = (struct hfsc_class *)res.class;
If asked to drop a packet via TC_ACT_SHOT it is unsafe to assume that res.class contains a valid pointer. Signed-off-by: Ma Ke <make_ruc2021@163.com> --- net/sched/sch_hfsc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)