Commit b74f2f7
drivers/of: fdt: validate flat DT string properties before string use
Firmware-supplied flat DT properties are raw byte sequences. Several
early FDT helpers fetch properties such as status, model, compatible,
and device_type and then use them as C strings with strcmp(), strlen(),
or pr_info() without first proving that the property is NUL-terminated
within its declared length.
Use fdt_stringlist_get() for these string properties instead. That
preserves the existing behavior for valid DTBs while rejecting malformed
unterminated properties before they are passed to C string helpers.
Signed-off-by: Pengpeng Hou <pengpeng@iscas.ac.cn>
Link: https://patch.msgid.link/20260403164501.1-drivers-of-fdt-v2-pengpeng@iscas.ac.cn
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>1 parent bb04fcc commit b74f2f7
1 file changed
Lines changed: 14 additions & 24 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
71 | | - | |
| 71 | + | |
72 | 72 | | |
73 | 73 | | |
74 | 74 | | |
| |||
677 | 677 | | |
678 | 678 | | |
679 | 679 | | |
680 | | - | |
| 680 | + | |
681 | 681 | | |
682 | 682 | | |
683 | | - | |
684 | | - | |
| 683 | + | |
685 | 684 | | |
686 | | - | |
687 | | - | |
688 | | - | |
689 | | - | |
| 685 | + | |
690 | 686 | | |
691 | 687 | | |
692 | 688 | | |
693 | | - | |
694 | | - | |
695 | | - | |
696 | 689 | | |
697 | 690 | | |
698 | 691 | | |
| |||
741 | 734 | | |
742 | 735 | | |
743 | 736 | | |
744 | | - | |
| 737 | + | |
745 | 738 | | |
746 | | - | |
| 739 | + | |
| 740 | + | |
747 | 741 | | |
748 | 742 | | |
749 | 743 | | |
| |||
775 | 769 | | |
776 | 770 | | |
777 | 771 | | |
778 | | - | |
| 772 | + | |
779 | 773 | | |
780 | 774 | | |
781 | 775 | | |
782 | | - | |
783 | | - | |
784 | | - | |
785 | | - | |
786 | | - | |
787 | | - | |
788 | | - | |
789 | | - | |
790 | | - | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
791 | 780 | | |
792 | 781 | | |
793 | 782 | | |
| |||
1032 | 1021 | | |
1033 | 1022 | | |
1034 | 1023 | | |
1035 | | - | |
| 1024 | + | |
| 1025 | + | |
1036 | 1026 | | |
1037 | 1027 | | |
1038 | 1028 | | |
| |||
0 commit comments