From: Dan Carpenter <dan.carpenter@oracle.com>
To: markos.chandras@imgtec.com, Matt Evans <matt@ozlabs.org>
Cc: linux-mips@linux-mips.org, linuxppc-dev@lists.ozlabs.org
Subject: [bug report] MIPS: net: Add BPF JIT
Date: Wed, 13 Jul 2016 17:07:12 +0300 [thread overview]
Message-ID: <20160713140711.GA8984@mwanda> (raw)
Hello Markos Chandras,
The patch c6610de353da: "MIPS: net: Add BPF JIT" from Apr 8, 2014,
leads to the following static checker warning:
arch/mips/net/bpf_jit.c:1185 build_body()
warn: potential off by one 'ctx->offsets[]' limit 'prog->len'
arch/mips/net/bpf_jit.c
652 static int build_body(struct jit_ctx *ctx)
653 {
654 const struct bpf_prog *prog = ctx->skf;
655 const struct sock_filter *inst;
656 unsigned int i, off, condt;
657 u32 k, b_off __maybe_unused;
658 u8 (*sk_load_func)(unsigned long *skb, int offset);
659
660 for (i = 0; i < prog->len; i++) {
661 u16 code;
662
663 inst = &(prog->insns[i]);
664 pr_debug("%s: code->0x%02x, jt->0x%x, jf->0x%x, k->0x%x\n",
665 __func__, inst->code, inst->jt, inst->jf, inst->k);
666 k = inst->k;
667 code = bpf_anc_helper(inst);
668
669 if (ctx->target == NULL)
670 ctx->offsets[i] = ctx->idx * 4;
We have this so we don't need the other assignment.
671
672 switch (code) {
[ snipped big switch statement ]
1176 default:
1177 pr_debug("%s: Unhandled opcode: 0x%02x\n", __FILE__,
1178 inst->code);
1179 return -1;
1180 }
1181 }
1182
1183 /* compute offsets only during the first pass */
1184 if (ctx->target == NULL)
1185 ctx->offsets[i] = ctx->idx * 4;
i is always one step beyond the end of the array here.
1186
1187 return 0;
1188 }
That arm and powerpc implementations have the same issue.
regards,
dan carpenter
reply other threads:[~2016-07-13 14:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20160713140711.GA8984@mwanda \
--to=dan.carpenter@oracle.com \
--cc=linux-mips@linux-mips.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=markos.chandras@imgtec.com \
--cc=matt@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.