In the Linux kernel, the following vulnerability has been resolved:
bpf: Check the validity of nrwords in bpfiterbitsnew()
Check the validity of nrwords in bpfiterbitsnew(). Without this check, when multiplication overflow occurs for nrbits (e.g., when nrwords = 0x0400-0001, nrbits becomes 64), stack corruption may occur due to bpfprobereadkernelcommon(..., nrbytes = 0x2000-0008).
Fix it by limiting the maximum value of nrwords to 511. The value is derived from the current implementation of BPF memory allocator. To ensure compatibility if the BPF memory allocator's size limitation changes in the future, use the helper bpfmemallocchecksize() to check whether nrbytes is too larger. And return -E2BIG instead of -ENOMEM for oversized nr_bytes.