Commit 82ff1e4
audio: module_adapter: bound large_config fragment reassembly to buffer size
md->new_cfg_size, used to bound every SET_LARGE_CONFIG reassembly copy
in module_set_configuration, is written in two places:
- module_set_large_config, sets it unconditionally on a FIRST fragment
- module_set_configuration, sets it while allocating md->runtime_params
to that size
Nothing keeps the two in sync when a second FIRST fragment arrives
mid-reassembly. module_set_large_config allows to overwrite new_cfg_size
with a new (larger) value while runtime_params still holds the previous,
smaller allocation.
A following MIDDLE/LAST fragment then passes the memcpy_s bound check
and writes host-controlled mailbox data out of bounds of the heap
buffer.
Fix it in the reassembly path:
- module_set_large_config: reject a FIRST fragment with -EBUSY when a
reassembly is already in progress, before overwriting new_cfg_size.
- module_set_configuration: commit new_cfg_size only after
runtime_params is allocated, so the two always match, and reject an
intermediate/last fragment whose host-supplied offset or size does not
fit in the buffer, which otherwise underflows the memcpy_s destination
bound.
Closes #11153
Signed-off-by: Tomasz Leman <tomasz.m.leman@intel.com>1 parent f7dc508 commit 82ff1e4
2 files changed
Lines changed: 18 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
839 | 839 | | |
840 | 840 | | |
841 | 841 | | |
842 | | - | |
843 | 842 | | |
844 | 843 | | |
845 | 844 | | |
846 | | - | |
| 845 | + | |
847 | 846 | | |
848 | 847 | | |
849 | 848 | | |
850 | | - | |
| 849 | + | |
851 | 850 | | |
852 | 851 | | |
853 | | - | |
854 | | - | |
855 | | - | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
856 | 855 | | |
857 | 856 | | |
858 | 857 | | |
859 | 858 | | |
860 | 859 | | |
861 | 860 | | |
862 | | - | |
| 861 | + | |
863 | 862 | | |
864 | 863 | | |
865 | 864 | | |
866 | 865 | | |
867 | 866 | | |
| 867 | + | |
| 868 | + | |
868 | 869 | | |
869 | 870 | | |
870 | 871 | | |
| |||
875 | 876 | | |
876 | 877 | | |
877 | 878 | | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
878 | 885 | | |
879 | 886 | | |
880 | 887 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
243 | 243 | | |
244 | 244 | | |
245 | 245 | | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
246 | 250 | | |
247 | 251 | | |
248 | 252 | | |
| |||
0 commit comments