Commit 230f6fa
committed
overflow: Provide constant expression struct_size
There have been cases where struct_size() (or flex_array_size()) needs
to be calculated for an initializer, which requires it be a constant
expression. This is possible when the "count" argument is a constant
expression, so provide this ability for the helpers.
Cc: Gustavo A. R. Silva <gustavoars@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>
Cc: Nick Desaulniers <ndesaulniers@google.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Tested-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/lkml/20220210010407.GA701603@embeddedor1 parent e1be43d commit 230f6fa
2 files changed
Lines changed: 24 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
224 | | - | |
225 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
226 | 228 | | |
227 | 229 | | |
228 | 230 | | |
| |||
237 | 239 | | |
238 | 240 | | |
239 | 241 | | |
240 | | - | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
241 | 245 | | |
242 | 246 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
602 | 602 | | |
603 | 603 | | |
604 | 604 | | |
| 605 | + | |
| 606 | + | |
605 | 607 | | |
606 | 608 | | |
607 | 609 | | |
608 | 610 | | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
609 | 617 | | |
610 | 618 | | |
611 | 619 | | |
| |||
663 | 671 | | |
664 | 672 | | |
665 | 673 | | |
666 | | - | |
| 674 | + | |
667 | 675 | | |
668 | | - | |
| 676 | + | |
669 | 677 | | |
670 | | - | |
| 678 | + | |
671 | 679 | | |
672 | | - | |
| 680 | + | |
673 | 681 | | |
674 | | - | |
| 682 | + | |
675 | 683 | | |
676 | 684 | | |
677 | 685 | | |
678 | 686 | | |
679 | 687 | | |
680 | 688 | | |
681 | | - | |
| 689 | + | |
682 | 690 | | |
683 | | - | |
| 691 | + | |
684 | 692 | | |
685 | | - | |
| 693 | + | |
686 | 694 | | |
687 | | - | |
| 695 | + | |
688 | 696 | | |
689 | 697 | | |
690 | 698 | | |
| |||
0 commit comments