lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <202108121918.qhvpt9H0-lkp@intel.com>
Date:   Thu, 12 Aug 2021 19:24:24 +0800
From:   kernel test robot <lkp@...el.com>
To:     Cong Wang <xiyou.wangcong@...il.com>
Cc:     clang-built-linux@...glegroups.com, kbuild-all@...ts.01.org,
        linux-kernel@...r.kernel.org
Subject: [congwang:sch_bpf 2/2] net/sched/sch_bpf.c:174:13: error:
 indirection requires pointer operand ('struct sch_bpf_prog' invalid)

tree:   https://github.com/congwang/linux.git sch_bpf
head:   aa61f170d88b706060a1977b7b7bef9d08e33ff1
commit: aa61f170d88b706060a1977b7b7bef9d08e33ff1 [2/2] sch_bpf: draft
config: hexagon-buildonly-randconfig-r001-20210812 (attached as .config)
compiler: clang version 12.0.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/congwang/linux/commit/aa61f170d88b706060a1977b7b7bef9d08e33ff1
        git remote add congwang https://github.com/congwang/linux.git
        git fetch --no-tags congwang sch_bpf
        git checkout aa61f170d88b706060a1977b7b7bef9d08e33ff1
        # save the attached .config to linux build tree
        mkdir build_dir
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross O=build_dir ARCH=hexagon SHELL=/bin/bash net/sched/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@...el.com>

All error/warnings (new ones prefixed by >>):

>> net/sched/sch_bpf.c:174:13: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
                   enqueue = rcu_dereference(q->enqueue_prog);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:389:9: note: expanded from macro '__rcu_dereference_check'
           typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                  ^~
>> net/sched/sch_bpf.c:174:13: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
                   enqueue = rcu_dereference(q->enqueue_prog);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:389:35: note: expanded from macro '__rcu_dereference_check'
           typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                            ^~
>> net/sched/sch_bpf.c:174:13: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
                   enqueue = rcu_dereference(q->enqueue_prog);
                             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:392:11: note: expanded from macro '__rcu_dereference_check'
           ((typeof(*p) __force __kernel *)(________p1)); \
                    ^~
>> net/sched/sch_bpf.c:174:11: error: assigning to 'struct bpf_prog *' from incompatible type 'void'
                   enqueue = rcu_dereference(q->enqueue_prog);
                           ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   net/sched/sch_bpf.c:219:12: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
           dequeue = rcu_dereference(q->dequeue_prog);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:389:9: note: expanded from macro '__rcu_dereference_check'
           typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                  ^~
   net/sched/sch_bpf.c:219:12: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
           dequeue = rcu_dereference(q->dequeue_prog);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:389:35: note: expanded from macro '__rcu_dereference_check'
           typeof(*p) *________p1 = (typeof(*p) *__force)READ_ONCE(p); \
                                            ^~
   net/sched/sch_bpf.c:219:12: error: indirection requires pointer operand ('struct sch_bpf_prog' invalid)
           dequeue = rcu_dereference(q->dequeue_prog);
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:596:28: note: expanded from macro 'rcu_dereference'
   #define rcu_dereference(p) rcu_dereference_check(p, 0)
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:528:2: note: expanded from macro 'rcu_dereference_check'
           __rcu_dereference_check((p), (c) || rcu_read_lock_held(), __rcu)
           ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   include/linux/rcupdate.h:392:11: note: expanded from macro '__rcu_dereference_check'
           ((typeof(*p) __force __kernel *)(________p1)); \
                    ^~
   net/sched/sch_bpf.c:219:10: error: assigning to 'struct bpf_prog *' from incompatible type 'void'
           dequeue = rcu_dereference(q->dequeue_prog);
                   ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> net/sched/sch_bpf.c:220:28: error: use of undeclared identifier 'skb'
           bpf_compute_data_pointers(skb);
                                     ^
>> net/sched/sch_bpf.c:231:11: error: incompatible pointer types assigning to 'struct sk_buff *' from 'struct pq_node *' [-Werror,-Wincompatible-pointer-types]
                   ctx.skb = pq_pop(&cl->pq);
                           ^ ~~~~~~~~~~~~~~~
>> net/sched/sch_bpf.c:237:13: error: use of undeclared identifier 'SCH_BPF_RET_OK'
           if (res == SCH_BPF_RET_OK) {
                      ^
>> net/sched/sch_bpf.c:239:20: error: use of undeclared identifier 'SCH_BPF_RET_REQUEUE'
           } else if (res == SCH_BPF_RET_REQUEUE) {
                             ^
>> net/sched/sch_bpf.c:284:37: warning: incompatible integer to pointer conversion passing 'u32' (aka 'unsigned int') to parameter of type 'struct Qdisc *' [-Wint-conversion]
           return (unsigned long)sch_bpf_find(handle, sch);
                                              ^~~~~~
   net/sched/sch_bpf.c:115:57: note: passing argument to parameter 'sch' here
   static struct sch_bpf_class *sch_bpf_find(struct Qdisc *sch, u32 classid)
                                                           ^
>> net/sched/sch_bpf.c:284:45: warning: incompatible pointer to integer conversion passing 'struct Qdisc *' to parameter of type 'u32' (aka 'unsigned int') [-Wint-conversion]
           return (unsigned long)sch_bpf_find(handle, sch);
                                                      ^~~
   net/sched/sch_bpf.c:115:66: note: passing argument to parameter 'classid' here
   static struct sch_bpf_class *sch_bpf_find(struct Qdisc *sch, u32 classid)
                                                                    ^
>> net/sched/sch_bpf.c:298:3: error: use of undeclared identifier 'TCA_SCH_BPF_ENQUEUE_PROG_FD'; did you mean 'TCA_SCH_BPF_ENQUEUE_PROG_ID'?
           [TCA_SCH_BPF_ENQUEUE_PROG_FD]   = { .type = NLA_U32 },
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
            TCA_SCH_BPF_ENQUEUE_PROG_ID
   include/uapi/linux/pkt_sched.h:1269:2: note: 'TCA_SCH_BPF_ENQUEUE_PROG_ID' declared here
           TCA_SCH_BPF_ENQUEUE_PROG_ID,    /* u32 */
           ^
>> net/sched/sch_bpf.c:301:3: error: use of undeclared identifier 'TCA_SCH_BPF_DEQUEUE_PROG_FD'; did you mean 'TCA_SCH_BPF_DEQUEUE_PROG_ID'?
           [TCA_SCH_BPF_DEQUEUE_PROG_FD]   = { .type = NLA_U32 },
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~
            TCA_SCH_BPF_DEQUEUE_PROG_ID
   include/uapi/linux/pkt_sched.h:1272:2: note: 'TCA_SCH_BPF_DEQUEUE_PROG_ID' declared here
           TCA_SCH_BPF_DEQUEUE_PROG_ID,    /* u32 */
           ^
>> net/sched/sch_bpf.c:314:33: error: use of undeclared identifier 'BPF_PROG_TYPE_SCHED_SCH'; did you mean 'BPF_PROG_TYPE_SCHED_ACT'?
           fp = bpf_prog_get_type(bpf_fd, BPF_PROG_TYPE_SCHED_SCH);
                                          ^~~~~~~~~~~~~~~~~~~~~~~
                                          BPF_PROG_TYPE_SCHED_ACT
   include/uapi/linux/bpf.h:924:2: note: 'BPF_PROG_TYPE_SCHED_ACT' declared here
           BPF_PROG_TYPE_SCHED_ACT,
           ^
   net/sched/sch_bpf.c:353:26: error: use of undeclared identifier 'TCA_SCH_BPF_ENQUEUE_PROG_FD'; did you mean 'TCA_SCH_BPF_ENQUEUE_PROG_ID'?
           err = bpf_init_prog(opt[TCA_SCH_BPF_ENQUEUE_PROG_FD],
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                   TCA_SCH_BPF_ENQUEUE_PROG_ID
   include/uapi/linux/pkt_sched.h:1269:2: note: 'TCA_SCH_BPF_ENQUEUE_PROG_ID' declared here
           TCA_SCH_BPF_ENQUEUE_PROG_ID,    /* u32 */
           ^
>> net/sched/sch_bpf.c:353:22: error: passing 'struct nlattr' to parameter of incompatible type 'struct nlattr *'; take the address with &
           err = bpf_init_prog(opt[TCA_SCH_BPF_ENQUEUE_PROG_FD],
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                               &
   net/sched/sch_bpf.c:306:41: note: passing argument to parameter 'fd' here
   static int bpf_init_prog(struct nlattr *fd, struct nlattr *name, struct sch_bpf_prog *prog)
                                           ^
   net/sched/sch_bpf.c:357:26: error: use of undeclared identifier 'TCA_SCH_BPF_DEQUEUE_PROG_FD'; did you mean 'TCA_SCH_BPF_DEQUEUE_PROG_ID'?
           err = bpf_init_prog(opt[TCA_SCH_BPF_DEQUEUE_PROG_FD],
                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~
                                   TCA_SCH_BPF_DEQUEUE_PROG_ID
   include/uapi/linux/pkt_sched.h:1272:2: note: 'TCA_SCH_BPF_DEQUEUE_PROG_ID' declared here
           TCA_SCH_BPF_DEQUEUE_PROG_ID,    /* u32 */
           ^
   net/sched/sch_bpf.c:357:22: error: passing 'struct nlattr' to parameter of incompatible type 'struct nlattr *'; take the address with &
           err = bpf_init_prog(opt[TCA_SCH_BPF_DEQUEUE_PROG_FD],
                               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                               &
   net/sched/sch_bpf.c:306:41: note: passing argument to parameter 'fd' here
   static int bpf_init_prog(struct nlattr *fd, struct nlattr *name, struct sch_bpf_prog *prog)
                                           ^
   fatal error: too many errors emitted, stopping now [-ferror-limit=]
   2 warnings and 20 errors generated.


vim +174 net/sched/sch_bpf.c

   160	
   161	static int sch_bpf_enqueue(struct sk_buff *skb, struct Qdisc *sch,
   162				    struct sk_buff **to_free)
   163	{
   164		struct sch_bpf_qdisc *q = qdisc_priv(sch);
   165		unsigned int len = qdisc_pkt_len(skb);
   166		struct sch_bpf_ctx ctx = {};
   167		struct sch_bpf_class *cl;
   168		int res;
   169	
   170		cl = sch_bpf_classify(skb, sch, &res);
   171		if (!cl) {
   172			struct bpf_prog *enqueue;
   173	
 > 174			enqueue = rcu_dereference(q->enqueue_prog);
   175			bpf_compute_data_pointers(skb);
   176	
   177			ctx.skb = skb;
   178			ctx.nr_classes = q->clhash.hashelems;
   179			ctx.nr_packets = sch->q.qlen;
   180			res = BPF_PROG_RUN(enqueue, &ctx);
   181			cl = sch_bpf_find(sch, ctx.classid);
   182			if (!cl) {
   183				if (res & __NET_XMIT_BYPASS)
   184					qdisc_qstats_drop(sch);
   185				__qdisc_drop(skb, to_free);
   186				return res;
   187			}
   188		}
   189	
   190		if (cl->qdisc) {
   191			if ((res = qdisc_enqueue(skb, cl->qdisc,
   192						 to_free)) != NET_XMIT_SUCCESS) {
   193				if (net_xmit_drop_count(ret)) {
   194					qdisc_qstats_drop(sch);
   195					cl->drops++;
   196				}
   197				return res;
   198			}
   199		} else {
   200			sch_bpf_skb_cb(skb)->rank = ctx.rank;
   201			pq_push(&cl->pq, &skb->pqnode);
   202		}
   203	
   204		sch->qstats.backlog += len;
   205		sch->q.qlen++;
   206		return res;
   207	}
   208	
   209	static struct sk_buff *sch_bpf_dequeue(struct Qdisc *sch)
   210	{
   211		struct sch_bpf_qdisc *q = qdisc_priv(sch);
   212		struct sch_bpf_ctx ctx = {};
   213		struct sk_buff *ret = NULL;
   214		struct bpf_prog *dequeue;
   215		struct sch_bpf_class *cl;
   216		struct pq_node *flow;
   217		int res;
   218	
   219		dequeue = rcu_dereference(q->dequeue_prog);
 > 220		bpf_compute_data_pointers(skb);
   221	
   222		flow = pq_pop(&q->flows);
   223		if (!flow)
   224			return NULL;
   225	
   226		cl = container_of(flow, struct sch_bpf_class, node);
   227		if (cl->qdisc) {
   228			ctx.skb = cl->qdisc->dequeue(cl->qdisc);
   229			ctx.classid = cl->common.classid;
   230		} else {
 > 231			ctx.skb = pq_pop(&cl->pq);
   232			ctx.classid = cl->rank;
   233		}
   234		ctx.nr_classes = q->clhash.hashelems;
   235		ctx.nr_packets = sch->q.qlen;
   236		res = BPF_PROG_RUN(dequeue, &ctx);
 > 237		if (res == SCH_BPF_RET_OK) {
   238			ret = ctx.skb;
 > 239		} else if (res == SCH_BPF_RET_REQUEUE) {
   240			sch_bpf_skb_cb(ctx.skb)->rank = ctx.rank;
   241			pq_push(&cl->pq, &ctx.skb->pqnode);
   242			ret = NULL;
   243		} else {
   244			kfree_skb(ctx.skb);
   245			ret = NULL;
   246		}
   247	
   248		cl->rank = ctx.classid;
   249		if (pq_top(&cl->pq)) {
   250			pq_push(&q->flows, &cl->node);
   251		}
   252		return ret;
   253	}
   254	
   255	static struct Qdisc *sch_bpf_leaf(struct Qdisc *sch, unsigned long arg)
   256	{
   257		struct sch_bpf_class *cl = (struct sch_bpf_class *)arg;
   258	
   259		return cl->qdisc;
   260	}
   261	
   262	static int sch_bpf_graft(struct Qdisc *sch, unsigned long arg, struct Qdisc *new,
   263				 struct Qdisc **old, struct netlink_ext_ack *extack)
   264	{
   265		struct sch_bpf_class *cl = (struct sch_bpf_class *)arg;
   266	
   267		if (new)
   268			*old = qdisc_replace(sch, new, &cl->qdisc);
   269		return 0;
   270	}
   271	
   272	static unsigned long sch_bpf_bind(struct Qdisc *sch, unsigned long parent,
   273				      u32 classid)
   274	{
   275		return 0;
   276	}
   277	
   278	static void sch_bpf_unbind(struct Qdisc *q, unsigned long cl)
   279	{
   280	}
   281	
   282	static unsigned long sch_bpf_search(struct Qdisc *sch, u32 handle)
   283	{
 > 284		return (unsigned long)sch_bpf_find(handle, sch);
   285	}
   286	
   287	static struct tcf_block *sch_bpf_tcf_block(struct Qdisc *sch, unsigned long cl,
   288						    struct netlink_ext_ack *extack)
   289	{
   290		struct sch_bpf_qdisc *q = qdisc_priv(sch);
   291	
   292		if (cl)
   293			return NULL;
   294		return q->block;
   295	}
   296	
   297	static const struct nla_policy sch_bpf_policy[TCA_SCH_BPF_MAX + 1] = {
 > 298		[TCA_SCH_BPF_ENQUEUE_PROG_FD]	= { .type = NLA_U32 },
   299		[TCA_SCH_BPF_ENQUEUE_PROG_NAME]	= { .type = NLA_NUL_STRING,
   300						    .len = ACT_BPF_NAME_LEN },
 > 301		[TCA_SCH_BPF_DEQUEUE_PROG_FD]	= { .type = NLA_U32 },
   302		[TCA_SCH_BPF_DEQUEUE_PROG_NAME]	= { .type = NLA_NUL_STRING,
   303						    .len = ACT_BPF_NAME_LEN },
   304	};
   305	
   306	static int bpf_init_prog(struct nlattr *fd, struct nlattr *name, struct sch_bpf_prog *prog)
   307	{
   308		char *prog_name = NULL;
   309		struct bpf_prog *fp;
   310		u32 bpf_fd;
   311	
   312		bpf_fd = nla_get_u32(fd);
   313	
 > 314		fp = bpf_prog_get_type(bpf_fd, BPF_PROG_TYPE_SCHED_SCH);
   315		if (IS_ERR(fp))
   316			return PTR_ERR(fp);
   317	
   318		if (name) {
   319			prog_name = nla_memdup(name, GFP_KERNEL);
   320			if (!prog_name) {
   321				bpf_prog_put(fp);
   322				return -ENOMEM;
   323			}
   324		}
   325	
   326		prog->name = prog_name;
   327		prog->prog = fp;
   328		return 0;
   329	}
   330	
   331	static bpf_cleanup_prog(struct sch_bpf_prog *prog)
   332	{
   333		if (prog->prog)
   334			bpf_prog_put(prog->prog);
   335		kfree(prog->name);
   336	}
   337	
   338	static int sch_bpf_change(struct Qdisc *sch, struct nlattr *opt,
   339				   struct netlink_ext_ack *extack)
   340	{
   341		struct sch_bpf_qdisc *q = qdisc_priv(sch);
   342		struct nlattr *tb[TCA_SCH_BPF_MAX + 1];
   343		u32 gen_flags = 0;
   344		int err;
   345	
   346		if (!opt)
   347			return -EINVAL;
   348	
   349		err = nla_parse_nested_deprecated(tb, TCA_SCH_BPF_MAX, opt,
   350						  sch_bpf_policy, NULL);
   351		if (err < 0)
   352			return err;
 > 353		err = bpf_init_prog(opt[TCA_SCH_BPF_ENQUEUE_PROG_FD],
   354				    opt[TCA_SCH_BPF_ENQUEUE_PROG_NAME], &q->enqueue_prog);
   355		if (err)
   356			return err;
   357		err = bpf_init_prog(opt[TCA_SCH_BPF_DEQUEUE_PROG_FD],
   358				    opt[TCA_SCH_BPF_DEQUEUE_PROG_NAME], &q->dequeue_prog);
   359		return err;
   360	}
   361	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org

Download attachment ".config.gz" of type "application/gzip" (30339 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ