Skip to content

KASAN use-after-free error reported when SSP DAI configuration fails #1497

Closed

Description

@dragosht

For the attached topology file sof-apl-nocodec-ssp5.m4 loading fails right after the DAI SSP configuration error but it also leaves behind a big KASAN dump

[   10.654610] BUG: KASAN: use-after-free in strcmp+0x35/0x60
[   10.660736] Read of size 1 at addr ffff88821f23d840 by task systemd-udevd/2303
[   10.668803] 
[   10.670459] CPU: 0 PID: 2303 Comm: systemd-udevd Not tainted 5.4.0-rc7-quilt+ #72
[   10.678820] Call Trace:
[   10.681551]  dump_stack+0xa0/0xe5
[   10.685254]  ? strcmp+0x35/0x60
[   10.688763]  print_address_description.constprop.4+0x26/0x360
[   10.695185]  ? strcmp+0x35/0x60
[   10.698693]  __kasan_report+0x158/0x1d0
[   10.702978]  ? do_one_initcall+0x99/0x2fa
[   10.707456]  ? do_init_module+0xee/0x36f
[   10.711835]  ? load_module+0x3964/0x4930
[   10.716214]  ? __do_sys_finit_module+0x1b3/0x1e0
[   10.721370]  ? strcmp+0x35/0x60
[   10.724877]  kasan_report+0x12/0x20
[   10.728769]  __asan_load1+0x47/0x50
[   10.732664]  strcmp+0x35/0x60
[   10.735977]  snd_soc_get_pcm_runtime+0x7c/0xe0
[   10.740943]  snd_soc_remove_dai_link+0xe1/0x100
[   10.746007]  snd_soc_tplg_component_remove+0x474/0x970
[   10.751749]  snd_soc_tplg_component_load+0x1a8/0x1b0
[   10.757294]  ? soc_tplg_process_headers+0x4520/0x4520
[   10.762958]  snd_sof_load_topology+0xcd/0x180 [snd_sof]
[   10.768812]  ? sof_dbg_comp_config+0xa0/0xa0 [snd_sof]
[   10.774567]  sof_pcm_probe+0xaa/0x180 [snd_sof]
[   10.779632]  snd_soc_component_probe+0x38/0x50
[   10.784593]  soc_probe_component+0x2d1/0x670
[   10.789361]  snd_soc_instantiate_card+0x82a/0x1400
[   10.794712]  ? soc_cleanup_card_resources+0x530/0x530
[   10.800356]  ? kasan_kmalloc+0x9/0x10
[   10.804444]  ? debug_mutex_init+0x11/0x20
[   10.808921]  snd_soc_register_card+0x26a/0x290
[   10.813881]  devm_snd_soc_register_card+0x48/0x90
[   10.819135]  sof_nocodec_probe+0x20/0x30 [snd_sof_nocodec]
[   10.825262]  platform_drv_probe+0x53/0xf0
[   10.829739]  really_probe+0x3bb/0x6a0
[   10.833831]  driver_probe_device+0x19f/0x1f0
[   10.838601]  __device_attach_driver+0xde/0x170
[   10.843567]  ? driver_allows_async_probing+0xb0/0xb0
[   10.849116]  bus_for_each_drv+0x107/0x170
[   10.853594]  ? bus_rescan_devices+0x20/0x20
[   10.858266]  __device_attach+0x16b/0x220
[   10.862647]  ? device_bind_driver+0x80/0x80
[   10.867318]  device_initial_probe+0x13/0x20
[   10.871985]  bus_probe_device+0x10d/0x130
[   10.876461]  device_add+0x649/0xa80
[   10.880358]  ? uevent_show+0x1c0/0x1c0
[   10.884543]  ? kasan_kmalloc+0x9/0x10
[   10.888631]  platform_device_add+0x1e9/0x410
[   10.893397]  platform_device_register_full+0x23a/0x26a
[   10.899148]  snd_sof_device_probe+0x55d/0x960 [snd_sof]
...

dmesg log:
dmesg.log

sof-logger:
sof.log

Activity

  1. dragosht commented on Nov 15, 2019

    @dragosht
    Author

    Sorry, just figured out this is probably the same issue as #1466 . I tried the patch in #1469 and that also seems to fix this one.

  2. mengdonglin commented on Nov 20, 2019

    @mengdonglin

    @dragosht Is KASAN a device using ApolloLake (APL) SoC?

  3. ranj063 commented on Nov 20, 2019

    @ranj063
    Collaborator

    @dragosht Is KASAN a device using ApolloLake (APL) SoC?

    @mengdonglin KASAN is the kernel memory sanitizer https://www.kernel.org/doc/html/v4.14/dev-tools/kasan.html

  4. plbossart commented on Dec 2, 2019

    @plbossart
    Member

    @dragosht this should be fixed now? If yes can you close this issue?

  5. dragosht commented on Dec 3, 2019

    @dragosht
    Author

    @plbossart I've just tested using the latest topic/sof-dev and I'm still getting the use-after-free warning:

    [   11.359785] sof-audio-pci 0000:00:0e.0: tplg: config SSP5 fmt 0x4001 mclk 24576000 bclk 12288000 fclk 48000 width (32)32 slots 2 mclk id 0 quirks 0
    [   11.374600] sof-audio-pci 0000:00:0e.0: ipc tx: 0x80010000
    [   11.380779] sof-audio-pci 0000:00:0e.0: error: ipc error for 0x80010000 size 12
    [   11.388985] sof-audio-pci 0000:00:0e.0: error: failed to set DAI config for SSP5
    [   11.397294] sof-audio-pci 0000:00:0e.0: ASoC: physical link loading failed
    [   11.405178] ==================================================================
    [   11.413253] BUG: KASAN: use-after-free in strcmp+0x35/0x60
    [   11.419376] Read of size 1 at addr ffff888234cf7c80 by task systemd-udevd/2458
    
    [   11.429098] CPU: 3 PID: 2458 Comm: systemd-udevd Tainted: G        W         5.4.0-rc8-quilt+ #84
    [   11.439006] Call Trace:
    [   11.441737]  dump_stack+0xa0/0xe5
    [   11.445441]  ? strcmp+0x35/0x60
    [   11.448957]  print_address_description.constprop.4+0x26/0x360
    [   11.455381]  ? strcmp+0x35/0x60
    [   11.458887]  __kasan_report+0x158/0x1d0
    [   11.463178]  ? snd_sof_pci_driver_init+0x23/0x1000 [snd_sof_pci]
    [   11.469891]  ? do_one_initcall+0x99/0x2fa
    [   11.474366]  ? do_init_module+0xee/0x36f
    [   11.478746]  ? load_module+0x3964/0x4930
    [   11.483128]  ? strcmp+0x35/0x60
    [   11.486636]  kasan_report+0x12/0x20
    [   11.490531]  __asan_load1+0x47/0x50
    [   11.494424]  strcmp+0x35/0x60
    [   11.497737]  snd_soc_get_pcm_runtime+0x7c/0xe0
    [   11.502698]  snd_soc_remove_dai_link+0xe1/0x100
    [   11.507761]  snd_soc_tplg_component_remove+0x474/0x970
    

    Full kernel log: dmesg.log

  6. plbossart commented on Dec 4, 2019

    @plbossart
    Member

    can you try with the patch posted on alsa-devel
    [alsa-devel] [PATCH v2 12/15] ASoC: soc-core: add missing return value check for soc_link_init()

    It solved some issues in snd_soc_get_pcm_runtime in my case.

    diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c
    index 79a4753..bdae48e 100644
    --- a/sound/soc/soc-core.c
    +++ b/sound/soc/soc-core.c
    @@ -1983,8 +1983,11 @@ static int snd_soc_bind_card(struct snd_soc_card *card)
     		goto probe_end;
     	}
     
    -	for_each_card_rtds(card, rtd)
    -		soc_link_init(card, rtd);
    +	for_each_card_rtds(card, rtd) {
    +		ret = soc_link_init(card, rtd);
    +		if (ret < 0)
    +			goto probe_end;
    +	}
     
     	snd_soc_dapm_link_dai_widgets(card);
     	snd_soc_dapm_connect_dai_link_widgets(card);
    -- 
    2.7.4
  7. dragosht commented on Dec 4, 2019

    @dragosht
    Author

    @plbossart I've tried the patch you mentioned above, but it doesn't seem to make a difference. The change it PR #1591 seems to fix this for me though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions