Commit 35990ea
netfilter: nft_set_pipapo: prevent overflow in lookup table allocation
BugLink: https://bugs.launchpad.net/bugs/2119603
[ Upstream commit 4c5c6aa9967dbe55bd017bb509885928d0f31206 ]
When calculating the lookup table size, ensure the following
multiplication does not overflow:
- desc->field_len[] maximum value is U8_MAX multiplied by
NFT_PIPAPO_GROUPS_PER_BYTE(f) that can be 2, worst case.
- NFT_PIPAPO_BUCKETS(f->bb) is 2^8, worst case.
- sizeof(unsigned long), from sizeof(*f->lt), lt in
struct nft_pipapo_field.
Then, use check_mul_overflow() to multiply by bucket size and then use
check_add_overflow() to the alignment for avx2 (if needed). Finally, add
lt_size_check_overflow() helper and use it to consolidate this.
While at it, replace leftover allocation using the GFP_KERNEL to
GFP_KERNEL_ACCOUNT for consistency, in pipapo_resize().
Fixes: 3c4287f ("nf_tables: Add set type for arbitrary concatenation of ranges")
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Reviewed-by: Stefano Brivio <[email protected]>
Signed-off-by: Pablo Neira Ayuso <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
CVE-2025-38162
Signed-off-by: Manuel Diewald <[email protected]>
Signed-off-by: Mehmet Basaran <[email protected]>1 parent 662071d commit 35990ea
1 file changed
+44
-14
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
683 | 683 | | |
684 | 684 | | |
685 | 685 | | |
| 686 | + | |
| 687 | + | |
| 688 | + | |
| 689 | + | |
| 690 | + | |
| 691 | + | |
| 692 | + | |
| 693 | + | |
| 694 | + | |
| 695 | + | |
| 696 | + | |
| 697 | + | |
| 698 | + | |
| 699 | + | |
| 700 | + | |
| 701 | + | |
| 702 | + | |
| 703 | + | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
| 709 | + | |
686 | 710 | | |
687 | 711 | | |
688 | 712 | | |
| |||
701 | 725 | | |
702 | 726 | | |
703 | 727 | | |
| 728 | + | |
704 | 729 | | |
705 | 730 | | |
706 | 731 | | |
| |||
719 | 744 | | |
720 | 745 | | |
721 | 746 | | |
722 | | - | |
723 | | - | |
724 | | - | |
725 | | - | |
| 747 | + | |
| 748 | + | |
| 749 | + | |
| 750 | + | |
| 751 | + | |
726 | 752 | | |
727 | 753 | | |
728 | 754 | | |
| |||
907 | 933 | | |
908 | 934 | | |
909 | 935 | | |
910 | | - | |
| 936 | + | |
911 | 937 | | |
912 | 938 | | |
913 | 939 | | |
| |||
917 | 943 | | |
918 | 944 | | |
919 | 945 | | |
920 | | - | |
921 | | - | |
| 946 | + | |
| 947 | + | |
| 948 | + | |
922 | 949 | | |
923 | 950 | | |
924 | 951 | | |
925 | 952 | | |
926 | 953 | | |
927 | | - | |
928 | | - | |
| 954 | + | |
| 955 | + | |
| 956 | + | |
929 | 957 | | |
930 | 958 | | |
931 | 959 | | |
| |||
936 | 964 | | |
937 | 965 | | |
938 | 966 | | |
939 | | - | |
| 967 | + | |
940 | 968 | | |
941 | 969 | | |
942 | 970 | | |
| |||
1451 | 1479 | | |
1452 | 1480 | | |
1453 | 1481 | | |
| 1482 | + | |
1454 | 1483 | | |
1455 | 1484 | | |
1456 | 1485 | | |
1457 | | - | |
1458 | | - | |
1459 | | - | |
1460 | | - | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
1461 | 1491 | | |
1462 | 1492 | | |
1463 | 1493 | | |
| |||
0 commit comments