Skip to content

Commit 05679ca

Browse files
tohojoAlexei Starovoitov
authored andcommitted
xdp: Prevent overflow in devmap_hash cost calculation for 32-bit builds
Tetsuo pointed out that without an explicit cast, the cost calculation for devmap_hash type maps could overflow on 32-bit builds. This adds the missing cast. Fixes: 6f9d451 ("xdp: Add devmap_hash map type for looking up devices by hashed index") Reported-by: Tetsuo Handa <penguin-kernel@i-love.sakura.ne.jp> Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Acked-by: Yonghong Song <yhs@fb.com> Link: https://lore.kernel.org/bpf/20191017105702.2807093-1-toke@redhat.com
1 parent 11875ba commit 05679ca

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎kernel/bpf/devmap.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ static int dev_map_init_map(struct bpf_dtab *dtab, union bpf_attr *attr)
128128

129129
if (!dtab->n_buckets) /* Overflow check */
130130
return -EINVAL;
131-
cost += sizeof(struct hlist_head) * dtab->n_buckets;
131+
cost += (u64) sizeof(struct hlist_head) * dtab->n_buckets;
132132
}
133133

134134
/* if map size is larger than memlock limit, reject it */

0 commit comments

Comments
 (0)