Repository navigation
Conversation
| return -EINVAL; | ||
| } | ||
| if (fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { | ||
| if (be_substream && fe_substream->pcm->nonatomic && !be_substream->pcm->nonatomic) { |
There was a problem hiding this comment.
interesting. In this case we are creating a loophole that misaligned 'atomicity' can slip through?
commented
Dec 9, 2022
|
@kv2019i see suggested extension in plbossart@3998038 and configuration changes in #4092 |
Fix a NULL dereference in dpcm_process_paths() in a case where there are multiple BEs, but one of them does not have a substream. [ 94.483796] RIP: 0010:dpcm_process_paths+0x1c4/0x585 ... [ 94.483882] dpcm_fe_dai_open+0x8f/0x791 [ 94.483901] snd_pcm_open_substream+0x554/0x7f2 [ 94.483911] snd_pcm_open+0xd2/0x1fa Fixes: bbf7d3b ("ASoC: soc-pcm: align BE 'atomicity' with that of the FE") Link: thesofproject#4083 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
Fix a NULL dereference in snd_soc_dpcm_stream_lock_irqsave_nested() in a case where there are multiple BEs, but one of them does not have a substream. Fixes: b2ae806 ("ASoC: soc-pcm: serialize BE triggers") Link: thesofproject#4083 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
When performing actions on BEs using for_each_dpcm_be(), there are multiple places where the BE substream is assumed to be non-NULL. It is possible however to define such topologies in machine drivers and the soc_pcm functions should handle such errors gracefully without kernel oops on NULL dereference. Link: thesofproject#4083 Signed-off-by: Kai Vehmanen <kai.vehmanen@linux.intel.com>
b78b280 to
80afc9e
Compare
commented
Dec 14, 2022
|
@plbossart wrote:
V2 uploaded with a patch added. Given the original oops is fixed with other means, I'm now wondering whether I should squash all three patches and remove the Fixes-tag. And just keep a link to the SOF issue for reference. That might be more appropriate now. |
| be_substream->runtime = NULL; | ||
| if (be_substream) { | ||
| __soc_pcm_close(be, be_substream); | ||
| be_substream->runtime = NULL; |
There was a problem hiding this comment.
Line 1569 is still using the be_substream. Not clear to me why you chose to protect the close() but not the hw_free()?
There was a problem hiding this comment.
actually you do protect the hw_free in the other case line 1946 now, so it's inconsistent.
There was a problem hiding this comment.
@plbossart Ran out of time, but I now realized some of the checks are superfluous as "be->dpcm[stream].state" can only be in limited states when BE substream is NULL. Need to go through all the additions. E.g. I think the case of L1946 is not needed.
There was a problem hiding this comment.
In dpcm_be_dai_stop(), be->dpcm[stream].users will be NULL as the BE is skipped in dai_startup(), so this check is not needed.
left a comment
There was a problem hiding this comment.
@plbossart I went through all cases and it seems it was no accident we only hit a NULL deref in the two places (covered by first two patches) in soc-pcm.c. The other code locations where be_substream is used, are already protected via either stream-state or users-count (see comments inline). So I'm thinking of going back to the original two patches.
| be_substream->runtime = NULL; | ||
| if (be_substream) { | ||
| __soc_pcm_close(be, be_substream); | ||
| be_substream->runtime = NULL; |
There was a problem hiding this comment.
In dpcm_be_dai_stop(), be->dpcm[stream].users will be NULL as the BE is skipped in dai_startup(), so this check is not needed.
|
|
||
| __soc_pcm_hw_free(be, be_substream); | ||
| if (be_substream) | ||
| __soc_pcm_hw_free(be, be_substream); |
There was a problem hiding this comment.
Here checks on "be->dpcm[stream].state" at L1935 protect against NULL be_substream usage.
|
|
||
| if (!be_substream) | ||
| continue; | ||
|
|
There was a problem hiding this comment.
Same here, checks on stream state on L2013 help to avoid NULL usage.
|
|
||
| if (!be_substream) | ||
| continue; | ||
|
|
There was a problem hiding this comment.
Ditto here, checks on L2050.
|
|
||
| if (!be_substream) | ||
| continue; | ||
|
|
commented
Dec 16, 2022
I don't have the time today to look into this is details, so will trust your analysis @kv2019i. Maybe just add a comment in the commit message that all other cases are already protected via either stream-state or users-count. |
commented
Apr 17, 2023
|
@kv2019i what do you want to do with this PR? Merge it as it and send upstream, or close it? |
commented
May 9, 2023
|
Closing until I have bandwidth to work on this. |
Fix a few regressions related to handling cases where there are multiple BEs but one of the BE substreams is NULL.
This happens e.g. with echo reference PCM when it is opened with the playback stream not running. FW will return -ENODATA in this case, but with curent kernel, the kernel with hit an OOPS.