From: Dan Carpenter <dan.carpenter@oracle.com>
To: daniel@iogearbox.net
Cc: bpf@vger.kernel.org
Subject: [bug report] bpf: Make 32->64 bounds propagation slightly more robust
Date: Tue, 11 Jan 2022 11:20:54 +0300 [thread overview]
Message-ID: <20220111082054.GA20305@kili> (raw)
Hello Daniel Borkmann,
The patch e572ff80f05c: "bpf: Make 32->64 bounds propagation slightly
more robust" from Dec 15, 2021, leads to the following Smatch static
checker warning:
kernel/bpf/verifier.c:1412 __reg32_bound_s64()
warn: always true condition '(a <= (((~0) >> 1))) => (s32min-s32max <= s32max)'
kernel/bpf/verifier.c
1410 static bool __reg32_bound_s64(s32 a)
1411 {
1412 return a >= 0 && a <= S32_MAX;
Obviously an s32 is going to be <= S32_MAX
1413 }
1414
1415 static void __reg_assign_32_into_64(struct bpf_reg_state *reg)
1416 {
1417 reg->umin_value = reg->u32_min_value;
1418 reg->umax_value = reg->u32_max_value;
1419
1420 /* Attempt to pull 32-bit signed bounds into 64-bit bounds but must
1421 * be positive otherwise set to worse case bounds and refine later
1422 * from tnum.
1423 */
1424 if (__reg32_bound_s64(reg->s32_min_value) &&
1425 __reg32_bound_s64(reg->s32_max_value)) {
1426 reg->smin_value = reg->s32_min_value;
1427 reg->smax_value = reg->s32_max_value;
1428 } else {
1429 reg->smin_value = 0;
1430 reg->smax_value = U32_MAX;
Should this be S32_MAX instead of U32_MAX?
1431 }
1432 }
regards,
dan carpenter
next reply other threads:[~2022-01-11 8:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-11 8:20 Dan Carpenter [this message]
2022-01-11 13:48 ` [bug report] bpf: Make 32->64 bounds propagation slightly more robust Daniel Borkmann
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=20220111082054.GA20305@kili \
--to=dan.carpenter@oracle.com \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
/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.