Commit 231b64f
committed
core: spmc: reject too small mem_access_size
The endpoint memory access descriptor array in an FF-A memory
transaction is described by mem_access_size, mem_access_count and
mem_access_offs, read from a normal-world (or SP) descriptor.
spmc_read_mem_transaction() checks that the array fits in the fragment
but does not bound mem_access_size from below.
Each array element is dereferenced as struct ffa_mem_access_common by
its users: get_acc_perms(), spmc_sp_add_share(), ffa_mem_retrieve(),
is_sp_op() and thread_spmc_populate_mobj_from_rx(). With mem_access_size
smaller than that structure the array-fit check no longer keeps each
element read in range; with mem_access_size 0 and mem_access_offs equal
to frag_len the read lands past the mapped buffer, an out-of-bounds read
in the SPMC.
Check mem_access_size against sizeof(struct ffa_mem_access_common) in
each user of the descriptor. Also reject mem_access_count 0 in
ffa_mem_retrieve() and thread_spmc_populate_mobj_from_rx(), which
dereference the first descriptor before the count is otherwise checked.
Signed-off-by: Guled Hasan <Law.Zoldyck@proton.me>1 parent a85cb55 commit 231b64f
2 files changed
Lines changed: 21 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
344 | 344 | | |
345 | 345 | | |
346 | 346 | | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
347 | 352 | | |
348 | 353 | | |
349 | 354 | | |
| |||
672 | 677 | | |
673 | 678 | | |
674 | 679 | | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
| 683 | + | |
| 684 | + | |
| 685 | + | |
675 | 686 | | |
676 | 687 | | |
677 | 688 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1078 | 1078 | | |
1079 | 1079 | | |
1080 | 1080 | | |
| 1081 | + | |
| 1082 | + | |
| 1083 | + | |
1081 | 1084 | | |
1082 | 1085 | | |
1083 | 1086 | | |
| |||
1207 | 1210 | | |
1208 | 1211 | | |
1209 | 1212 | | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
1210 | 1216 | | |
1211 | 1217 | | |
1212 | 1218 | | |
| |||
2867 | 2873 | | |
2868 | 2874 | | |
2869 | 2875 | | |
| 2876 | + | |
| 2877 | + | |
| 2878 | + | |
| 2879 | + | |
2870 | 2880 | | |
2871 | 2881 | | |
2872 | 2882 | | |
| |||
0 commit comments