ASoC: SOF: Refactor rx function for fuzzing
Subsystems (3)
PATCH 1/2 ASoC: SOF: Refactor rx function for fuzzing
From: Curtis Malainey <[email protected]>
Refactor the function so reading the data is done outside the work function so fuzzing can pass data directly into the work callbacks.
Also expose the inner function outside the module so we can call it from the injector.
--- sound/soc/sof/ipc3-priv.h | 2 ++ sound/soc/sof/ipc3.c | 63 ++++++++++++++++++++++++--------------- 2 files changed, 41 insertions(+), 24 deletions(-)
sound/soc/sof/ipc3-priv.h +2 -0
@@ -28,6 +28,8 @@ int sof_ipc3_validate_fw_version(struct snd_sof_dev *sdev);/* dtrace position update */ int ipc3_dtrace_posn_update (struct snd_sof_dev *sdev,struct sof_ipc_dma_trace_posn *posn); +/* RX handler backend */ +void sof_ipc3_do_rx_work (struct snd_sof_dev *sdev,struct sof_ipc_cmd_hdr *hdr,void *msg_buf);/* dtrace platform callback wrappers */ static inline int sof_dtrace_host_init(struct snd_sof_dev *sdev,
sound/soc/sof/ipc3.c +39 -24
94 lines not on this page · raw message
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
PATCH 2/2 ASoC: SOF: Add IPC3 Kernel Injector
From: Curtis Malainey <[email protected]>
Add debugfs path to fake a malicious firmware message for fuzzing purposes.
Skip IPC4 for initial integration
--- sound/soc/sof/Kconfig | 11 ++ sound/soc/sof/Makefile | 2 + .../soc/sof/sof-client-ipc-kernel-injector.c | 162 ++++++++++++++++++ sound/soc/sof/sof-client.c | 52 ++++++ sound/soc/sof/sof-client.h | 1 + 5 files changed, 228 insertions(+) create mode 100644 sound/soc/sof/sof-client-ipc-kernel-injector.c
sound/soc/sof/Kconfig +11 -0
@@ -236,6 +236,17 @@ config SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR Say Y if you want to enable the IPC message injector. If unsure, select "N". +config SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR + tristate "SOF enable IPC kernel injector" + depends on SND_SOC_SOF + select SND_SOC_SOF_CLIENT + help + This option enables the IPC kernel injector which can be used to send + crafted IPC messages to the kernel to test its robustness against + DSP messages. + Say Y if you want to enable the IPC kernel injector. + If unsure, select "N". + config SND_SOC_SOF_DEBUG_RETAIN_DSP_CONTEXT bool "SOF retain DSP context on any FW exceptions" help
sound/soc/sof/Makefile +2 -0
@@ -26,6 +26,7 @@ snd-sof-of-objs := sof-of-dev.o snd-sof-ipc-flood-test-objs := sof-client-ipc-flood-test.o snd-sof-ipc-msg-injector-objs := sof-client-ipc-msg-injector.o +snd-sof-ipc-kernel-injector-objs := sof-client-ipc-kernel-injector.o snd-sof-probes-objs := sof-client-probes.o ifneq ($(CONFIG_SND_SOC_SOF_IPC3),) snd-sof-probes-objs += sof-client-probes-ipc3.o
@@ -49,6 +50,7 @@ obj-$(CONFIG_SND_SOC_SOF_PCI_DEV) += snd-sof-pci.o obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_FLOOD_TEST) += snd-sof-ipc-flood-test.o obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_MSG_INJECTOR) += snd-sof-ipc-msg-injector.o +obj-$(CONFIG_SND_SOC_SOF_DEBUG_IPC_KERNEL_INJECTOR) += snd-sof-ipc-kernel-injector.o obj-$(CONFIG_SND_SOC_SOF_DEBUG_PROBES) += snd-sof-probes.o obj-$(CONFIG_SND_SOC_SOF_INTEL_TOPLEVEL) += intel/
sound/soc/sof/sof-client-ipc-kernel-injector.c new file +162 -0
162 lines not on this page · raw message
sound/soc/sof/sof-client.c +52 -0
88 lines not on this page · raw message
sound/soc/sof/sof-client.h +1 -0
@@ -75,5 +75,6 @@ int sof_client_register_fw_state_handler(struct sof_client_dev *cdev, sof_client_fw_state_callback callback);void sof_client_unregister_fw_state_handler (struct sof_client_dev *cdev);enum sof_fw_state sof_client_get_fw_state (struct sof_client_dev *cdev); +int sof_client_ipc_rx_message (struct sof_client_dev *cdev,void *ipc_msg,void *msg_buf);#endif /* __SOC_SOF_CLIENT_H */
Signature · 1 line
2.41.0.162.gfafddb0af9-goog
Mark Brown
maintainerQuoted 8 lines · On Thu, 08 Jun 2023 15:18:15 -0700, [email protected] wrote:
Refactor the function so reading the data is done outside the work function so fuzzing can pass data directly into the work callbacks.
Also expose the inner function outside the module so we can call it from the injector.
[...]
Applied to
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next
Thanks!
[1/2] ASoC: SOF: Refactor rx function for fuzzing
commit: 12c41c779fad54714ce4901757374f6006a88644
[2/2] ASoC: SOF: Add IPC3 Kernel Injector
commit: 70dad53ddff0778c4920a1ee9eb1cfea539d4e91All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted.
You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed.
If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced.
Please add any relevant lists and maintainers to the CCs when replying to this mail.
Thanks,
Mark