Commit 8e47d29
smb: client: validate the whole DACL before rewriting it in cifsacl
[ Upstream commit 0a8cf16 ]
build_sec_desc() and id_mode_to_cifs_acl() derive a DACL pointer from a
server-supplied dacloffset and then use the incoming ACL to rebuild the
chmod/chown security descriptor.
The original fix only checked that the struct smb_acl header fits before
reading dacl_ptr->size or dacl_ptr->num_aces. That avoids the immediate
header-field OOB read, but the rewrite helpers still walk ACEs based on
pdacl->num_aces with no structural validation of the incoming DACL body.
A malicious server can return a truncated DACL that still contains a
header, claims one or more ACEs, and then drive
replace_sids_and_copy_aces() or set_chmod_dacl() past the validated
extent while they compare or copy attacker-controlled ACEs.
Factor the DACL structural checks into validate_dacl(), extend them to
validate each ACE against the DACL bounds, and use the shared validator
before the chmod/chown rebuild paths. parse_dacl() reuses the same
validator so the read-side parser and write-side rewrite paths agree on
what constitutes a well-formed incoming DACL.
Fixes: bc3e9dd ("cifs: Change SIDs in ACEs while transferring file ownership.")
Cc: stable@vger.kernel.org
Assisted-by: Claude:claude-opus-4-6
Assisted-by: Codex:gpt-5-4
Signed-off-by: Michael Bommarito <michael.bommarito@gmail.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
[ no kmalloc_objs ]
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>1 parent 325d4ac commit 8e47d29
1 file changed
Lines changed: 85 additions & 31 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
758 | 758 | | |
759 | 759 | | |
760 | 760 | | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
761 | 832 | | |
762 | 833 | | |
763 | 834 | | |
764 | 835 | | |
765 | 836 | | |
766 | 837 | | |
767 | 838 | | |
768 | | - | |
| 839 | + | |
769 | 840 | | |
770 | 841 | | |
771 | 842 | | |
| |||
777 | 848 | | |
778 | 849 | | |
779 | 850 | | |
780 | | - | |
781 | | - | |
782 | | - | |
783 | | - | |
| 851 | + | |
784 | 852 | | |
785 | | - | |
786 | 853 | | |
787 | 854 | | |
788 | 855 | | |
| |||
793 | 860 | | |
794 | 861 | | |
795 | 862 | | |
| 863 | + | |
796 | 864 | | |
797 | 865 | | |
798 | 866 | | |
799 | 867 | | |
800 | 868 | | |
801 | 869 | | |
802 | 870 | | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | | - | |
807 | | - | |
808 | 871 | | |
809 | 872 | | |
810 | 873 | | |
811 | 874 | | |
812 | 875 | | |
813 | 876 | | |
814 | | - | |
815 | | - | |
816 | | - | |
817 | 877 | | |
818 | | - | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
824 | | - | |
825 | | - | |
826 | | - | |
827 | | - | |
828 | | - | |
829 | | - | |
830 | 878 | | |
831 | 879 | | |
832 | | - | |
| 880 | + | |
833 | 881 | | |
834 | 882 | | |
835 | 883 | | |
| |||
872 | 920 | | |
873 | 921 | | |
874 | 922 | | |
| 923 | + | |
875 | 924 | | |
876 | 925 | | |
877 | 926 | | |
| |||
1317 | 1366 | | |
1318 | 1367 | | |
1319 | 1368 | | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
1324 | 1372 | | |
1325 | 1373 | | |
1326 | 1374 | | |
| |||
1697 | 1745 | | |
1698 | 1746 | | |
1699 | 1747 | | |
| 1748 | + | |
| 1749 | + | |
| 1750 | + | |
| 1751 | + | |
| 1752 | + | |
| 1753 | + | |
1700 | 1754 | | |
1701 | 1755 | | |
1702 | 1756 | | |
| |||
0 commit comments