|
|
@@ -1294,13 +1294,17 @@ static int check_map_access(struct bpf_verifier_env *env, u32 regno,
|
|
|
*/
|
|
|
if (env->log.level)
|
|
|
print_verifier_state(env, state);
|
|
|
+
|
|
|
/* The minimum value is only important with signed
|
|
|
* comparisons where we can't assume the floor of a
|
|
|
* value is 0. If we are using signed variables for our
|
|
|
* index'es we need to make sure that whatever we use
|
|
|
* will have a set floor within our range.
|
|
|
*/
|
|
|
- if (reg->smin_value < 0) {
|
|
|
+ if (reg->smin_value < 0 &&
|
|
|
+ (reg->smin_value == S64_MIN ||
|
|
|
+ (off + reg->smin_value != (s64)(s32)(off + reg->smin_value)) ||
|
|
|
+ reg->smin_value + off < 0)) {
|
|
|
verbose(env, "R%d min value is negative, either use unsigned index or do a if (index >=0) check.\n",
|
|
|
regno);
|
|
|
return -EACCES;
|