[bug report] ASoC: fsl_asrc_m2m: Add memory to memory function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Hello Shengjiu Wang,

Commit 24a01710f627 ("ASoC: fsl_asrc_m2m: Add memory to memory
function") from Dec 12, 2024 (linux-next), leads to the following
Smatch static checker warning:

	include/sound/pcm.h:1514 pcm_format_to_bits()
	error: undefined (user controlled) shift '1 << pcm_format'

sound/soc/fsl/fsl_asrc_m2m.c
   347  static int fsl_asrc_m2m_comp_set_params(struct snd_compr_stream *stream,
   348                                          struct snd_compr_params *params)
   349  {
   350          struct fsl_asrc *asrc = stream->private_data;
   351          struct snd_compr_runtime *runtime = stream->runtime;
   352          struct fsl_asrc_pair *pair = runtime->private_data;
   353          struct fsl_asrc_m2m_cap cap;
   354          int ret, i;
   355  
   356          ret = asrc->m2m_get_cap(&cap);
   357          if (ret)
   358                  return -EINVAL;
   359  
   360          if (pcm_format_to_bits((__force snd_pcm_format_t)params->codec.format) & cap.fmt_in)
                                                                 ^^^^^^^^^^^^^^^^^^^^
This comes from the user via snd_compr_set_params().  Syzbot will
eventually discover this undefined behavior and generate a stack trace
etc.  Normally we would add a check for invalid codec.format values in
snd_compress_check_input().

   361                  pair->sample_format[IN] = (__force snd_pcm_format_t)params->codec.format;
   362          else
   363                  return -EINVAL;
   364  
   365          if (pcm_format_to_bits((__force snd_pcm_format_t)params->codec.pcm_format) & cap.fmt_out)
   366                  pair->sample_format[OUT] = (__force snd_pcm_format_t)params->codec.pcm_format;
   367          else
   368                  return -EINVAL;
   369  

regards,
dan carpenter




[Index of Archives]     [Pulseaudio]     [Linux Audio Users]     [ALSA Devel]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]

  Powered by Linux