ASoC: snprintf() usage fixes
Subsystems (3)
cover ASoC: snprintf() usage fixes
Hi,
this is a series of patches I spotted during debugging other code. Intel skl and ASoC PCM core invokes succeeding calls of snprintf() with the incorrect expectation of the return value, which may lead to a buffer overflow.
The first patch is yet another bug I found during working on this, and it's rather a real bug that can be seen clearly.
Takashi
===
Takashi Iwai (3):
ASoC: intel: skl: Fix pin debug prints
ASoC: intel: skl: Fix possible buffer overflow in debug outputs
ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output
sound/soc/intel/skylake/skl-debug.c | 32 +++++++++++++++++--------------- sound/soc/soc-pcm.c | 16 ++++++++-------- 2 files changed, 25 insertions(+), 23 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/3 ASoC: intel: skl: Fix pin debug prints
skl_print_pins() loops over all given pins but it overwrites the text at the very same position while increasing the returned length. Fix this to show the all pin contents properly.
--- sound/soc/intel/skylake/skl-debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/skylake/skl-debug.c +3 -1
@@ -34,7 +34,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,int i;ssize_t ret =0 ; -for (i =0 ; i < max_pin; i++) +for (i =0 ; i < max_pin; i++) { ret +=snprintf (buf + size,MOD_BUF - size,"%s %d\n\tModule %d\n\tInstance %d\n\t" "In-used %s\n\tType %s\n"
@@ -45,6 +45,8 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf, m_pin[i].in_use ?"Used" :"Unused" , m_pin[i].is_dynamic ?"Dynamic" :"Static" , m_pin[i].pin_state, i); + size += ret; + }return ret; }
Signature · 1 line
2.16.4
Mark Brown
maintainerApplied "ASoC: intel: skl: Fix pin debug prints" to the asoc tree
The patch
ASoC: intel: skl: Fix pin debug prints
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 64bbacc5f08c01954890981c63de744df1f29a30 Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 18 Feb 2020 12:17:35 +0100
Subject: [PATCH] ASoC: intel: skl: Fix pin debug prints
skl_print_pins() loops over all given pins but it overwrites the text at the very same position while increasing the returned length. Fix this to show the all pin contents properly.
--- sound/soc/intel/skylake/skl-debug.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
sound/soc/intel/skylake/skl-debug.c +3 -1
@@ -34,7 +34,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,int i;ssize_t ret =0 ; -for (i =0 ; i < max_pin; i++) +for (i =0 ; i < max_pin; i++) { ret +=snprintf (buf + size,MOD_BUF - size,"%s %d\n\tModule %d\n\tInstance %d\n\t" "In-used %s\n\tType %s\n"
@@ -45,6 +45,8 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf, m_pin[i].in_use ?"Used" :"Unused" , m_pin[i].is_dynamic ?"Dynamic" :"Static" , m_pin[i].pin_state, i); + size += ret; + }return ret; }
Signature · 1 line
2.20.1
PATCH 2/3 ASoC: intel: skl: Fix possible buffer overflow in debug outputs
In reply to Takashi IwaiThe debugfs output of intel skl driver writes strings with multiple snprintf() calls with the fixed size. This was supposed to avoid the buffer overflow but actually it still would, because snprintf() returns the expected size to be output, not the actual output size.
Fix it by replacing snprintf() calls with scnprintf().
--- sound/soc/intel/skylake/skl-debug.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
sound/soc/intel/skylake/skl-debug.c +14 -14
@@ -35,7 +35,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,ssize_t ret =0 ;for (i =0 ; i < max_pin; i++) { - ret += snprintf(buf + size, MOD_BUF - size, + ret += scnprintf(buf + size, MOD_BUF - size, "%s %d\n\tModule %d\n\tInstance %d\n\t" "In-used %s\n\tType %s\n" "\tState %d\n\tIndex %d\n",
@@ -53,7 +53,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,static ssize_t skl_print_fmt (struct skl_module_fmt *fmt,char *buf,ssize_t size,bool direction) { - return snprintf(buf + size, MOD_BUF - size, + return scnprintf(buf + size, MOD_BUF - size, "%s\n\tCh %d\n\tFreq %d\n\tBit depth %d\n\t" "Valid bit depth %d\n\tCh config %#x\n\tInterleaving %d\n\t" "Sample Type %d\n\tCh Map %#x\n",
@@ -77,16 +77,16 @@ static ssize_t module_read(struct file *file, char __user *user_buf,if (!buf)return -ENOMEM ; - ret =snprintf (buf,MOD_BUF ,"Module:\n\tUUID %pUL\n\tModule id %d\n" + ret =scnprintf (buf,MOD_BUF ,"Module:\n\tUUID %pUL\n\tModule id %d\n" "\tInstance id %d\n\tPvt_id %d\n" , mconfig->guid, mconfig->id.module_id, mconfig->id.instance_id, mconfig->id.pvt_id); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Resources:\n\tCPC %#x\n\tIBS %#x\n\tOBS %#x\t\n" , res->cpc, res->ibs, res->obs); - ret += snprintf(buf + ret, MOD_BUF - ret, + ret += scnprintf(buf + ret, MOD_BUF - ret, "Module data:\n\tCore %d\n\tIn queue %d\n\t" "Out queue %d\n\tType %s\n", mconfig->core_id, mconfig->max_in_queue,
@@ -96,38 +96,38 @@ static ssize_t module_read(struct file *file, char __user *user_buf, ret +=skl_print_fmt (mconfig->in_fmt, buf, ret, true); ret +=skl_print_fmt (mconfig->out_fmt, buf, ret, false); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Fixup:\n\tParams %#x\n\tConverter %#x\n" , mconfig->params_fixup, mconfig->converter); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Module Gateway:\n\tType %#x\n\tVbus %#x\n\tHW conn %#x\n\tSlot %#x\n" , mconfig->dev_type, mconfig->vbus_id, mconfig->hw_conn_type, mconfig->time_slot); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Pipeline:\n\tID %d\n\tPriority %d\n\tConn Type %d\n\t" "Pages %#x\n" , mconfig->pipe->ppl_id, mconfig->pipe->pipe_priority, mconfig->pipe->conn_type, mconfig->pipe->memory_pages); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tParams:\n\t\tHost DMA %d\n\t\tLink DMA %d\n" , mconfig->pipe->p_params->host_dma_id, mconfig->pipe->p_params->link_dma_id); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tPCM params:\n\t\tCh %d\n\t\tFreq %d\n\t\tFormat %d\n" , mconfig->pipe->p_params->ch, mconfig->pipe->p_params->s_freq, mconfig->pipe->p_params->s_fmt); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tLink %#x\n\tStream %#x\n" , mconfig->pipe->p_params->linktype, mconfig->pipe->p_params->stream); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tState %d\n\tPassthru %s\n" , mconfig->pipe->state, mconfig->pipe->passthru ?"true" :"false" );
@@ -137,7 +137,7 @@ static ssize_t module_read(struct file *file, char __user *user_buf, ret +=skl_print_pins (mconfig->m_out_pin, buf, mconfig->max_out_queue, ret, false); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Other:\n\tDomain %d\n\tHomogeneous Input %s\n\t" "Homogeneous Output %s\n\tIn Queue Mask %d\n\t" "Out Queue Mask %d\n\tDMA ID %d\n\tMem Pages %d\n\t"
@@ -193,7 +193,7 @@ static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,__ioread32_copy (d->fw_read_buff, fw_reg_addr, w0_stat_sz >>2 );for (offset =0 ; offset <FW_REG_SIZE ; offset +=16 ) { - ret +=snprintf (tmp + ret,FW_REG_BUF - ret,"%#.4x: " , offset); + ret +=scnprintf (tmp + ret,FW_REG_BUF - ret,"%#.4x: " , offset);hex_dump_to_buffer (d->fw_read_buff + offset,16 ,16 ,4 , tmp + ret,FW_REG_BUF - ret,0 ); ret +=strlen (tmp + ret);
Signature · 1 line
2.16.4
Mark Brown
maintainerApplied "ASoC: intel: skl: Fix possible buffer overflow in debug outputs" to the asoc tree
The patch
ASoC: intel: skl: Fix possible buffer overflow in debug outputs
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 549cd0ba04dcfe340c349cd983bd440480fae8ee Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 18 Feb 2020 12:17:36 +0100
Subject: [PATCH] ASoC: intel: skl: Fix possible buffer overflow in debug
outputs
The debugfs output of intel skl driver writes strings with multiple snprintf() calls with the fixed size. This was supposed to avoid the buffer overflow but actually it still would, because snprintf() returns the expected size to be output, not the actual output size.
Fix it by replacing snprintf() calls with scnprintf().
--- sound/soc/intel/skylake/skl-debug.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-)
sound/soc/intel/skylake/skl-debug.c +14 -14
@@ -35,7 +35,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,ssize_t ret =0 ;for (i =0 ; i < max_pin; i++) { - ret += snprintf(buf + size, MOD_BUF - size, + ret += scnprintf(buf + size, MOD_BUF - size, "%s %d\n\tModule %d\n\tInstance %d\n\t" "In-used %s\n\tType %s\n" "\tState %d\n\tIndex %d\n",
@@ -53,7 +53,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,static ssize_t skl_print_fmt (struct skl_module_fmt *fmt,char *buf,ssize_t size,bool direction) { - return snprintf(buf + size, MOD_BUF - size, + return scnprintf(buf + size, MOD_BUF - size, "%s\n\tCh %d\n\tFreq %d\n\tBit depth %d\n\t" "Valid bit depth %d\n\tCh config %#x\n\tInterleaving %d\n\t" "Sample Type %d\n\tCh Map %#x\n",
@@ -77,16 +77,16 @@ static ssize_t module_read(struct file *file, char __user *user_buf,if (!buf)return -ENOMEM ; - ret =snprintf (buf,MOD_BUF ,"Module:\n\tUUID %pUL\n\tModule id %d\n" + ret =scnprintf (buf,MOD_BUF ,"Module:\n\tUUID %pUL\n\tModule id %d\n" "\tInstance id %d\n\tPvt_id %d\n" , mconfig->guid, mconfig->id.module_id, mconfig->id.instance_id, mconfig->id.pvt_id); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Resources:\n\tCPC %#x\n\tIBS %#x\n\tOBS %#x\t\n" , res->cpc, res->ibs, res->obs); - ret += snprintf(buf + ret, MOD_BUF - ret, + ret += scnprintf(buf + ret, MOD_BUF - ret, "Module data:\n\tCore %d\n\tIn queue %d\n\t" "Out queue %d\n\tType %s\n", mconfig->core_id, mconfig->max_in_queue,
@@ -96,38 +96,38 @@ static ssize_t module_read(struct file *file, char __user *user_buf, ret +=skl_print_fmt (mconfig->in_fmt, buf, ret, true); ret +=skl_print_fmt (mconfig->out_fmt, buf, ret, false); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Fixup:\n\tParams %#x\n\tConverter %#x\n" , mconfig->params_fixup, mconfig->converter); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Module Gateway:\n\tType %#x\n\tVbus %#x\n\tHW conn %#x\n\tSlot %#x\n" , mconfig->dev_type, mconfig->vbus_id, mconfig->hw_conn_type, mconfig->time_slot); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Pipeline:\n\tID %d\n\tPriority %d\n\tConn Type %d\n\t" "Pages %#x\n" , mconfig->pipe->ppl_id, mconfig->pipe->pipe_priority, mconfig->pipe->conn_type, mconfig->pipe->memory_pages); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tParams:\n\t\tHost DMA %d\n\t\tLink DMA %d\n" , mconfig->pipe->p_params->host_dma_id, mconfig->pipe->p_params->link_dma_id); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tPCM params:\n\t\tCh %d\n\t\tFreq %d\n\t\tFormat %d\n" , mconfig->pipe->p_params->ch, mconfig->pipe->p_params->s_freq, mconfig->pipe->p_params->s_fmt); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tLink %#x\n\tStream %#x\n" , mconfig->pipe->p_params->linktype, mconfig->pipe->p_params->stream); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"\tState %d\n\tPassthru %s\n" , mconfig->pipe->state, mconfig->pipe->passthru ?"true" :"false" );
@@ -137,7 +137,7 @@ static ssize_t module_read(struct file *file, char __user *user_buf, ret +=skl_print_pins (mconfig->m_out_pin, buf, mconfig->max_out_queue, ret, false); - ret +=snprintf (buf + ret,MOD_BUF - ret, + ret +=scnprintf (buf + ret,MOD_BUF - ret,"Other:\n\tDomain %d\n\tHomogeneous Input %s\n\t" "Homogeneous Output %s\n\tIn Queue Mask %d\n\t" "Out Queue Mask %d\n\tDMA ID %d\n\tMem Pages %d\n\t"
@@ -193,7 +193,7 @@ static ssize_t fw_softreg_read(struct file *file, char __user *user_buf,__ioread32_copy (d->fw_read_buff, fw_reg_addr, w0_stat_sz >>2 );for (offset =0 ; offset <FW_REG_SIZE ; offset +=16 ) { - ret +=snprintf (tmp + ret,FW_REG_BUF - ret,"%#.4x: " , offset); + ret +=scnprintf (tmp + ret,FW_REG_BUF - ret,"%#.4x: " , offset);hex_dump_to_buffer (d->fw_read_buff + offset,16 ,16 ,4 , tmp + ret,FW_REG_BUF - ret,0 ); ret +=strlen (tmp + ret);
Signature · 1 line
2.20.1
PATCH 3/3 ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output
In reply to Takashi Iwaidpcm_show_state() invokes multiple snprintf() calls to concatenate formatted strings on the fixed size buffer. The usage of snprintf() is supposed for avoiding the buffer overflow, but it doesn't work as expected because snprintf() doesn't return the actual output size but the size to be written.
Fix this bug by replacing all snprintf() calls with scnprintf() calls.
--- sound/soc/soc-pcm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/soc-pcm.c +8 -8
@@ -3171,16 +3171,16 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,unsigned long flags;/* FE state */ - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset,"[%s - %s]\n" , fe->dai_link->name, stream ?"Capture" :"Playback" ); - offset +=snprintf (buf + offset, size - offset,"State: %s\n" , + offset +=scnprintf (buf + offset, size - offset,"State: %s\n" ,dpcm_state_string (fe->dpcm[stream].state));if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset += snprintf(buf + offset, size - offset, + offset += scnprintf(buf + offset, size - offset, "Hardware Params: " "Format = %s, Channels = %d, Rate = %d\n", snd_pcm_format_name(params_format(params)),
@@ -3188,10 +3188,10 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, params_rate(params));/* BEs state */ - offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); + offset +=scnprintf (buf + offset, size - offset,"Backends:\n" );if (list_empty (&fe->dpcm[stream].be_clients)) { - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset," No active DSP links\n" ); goto out; }
@@ -3201,16 +3201,16 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be = dpcm->be; params = &dpcm->hw_params; - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset,"- %s\n" , be->dai_link->name); - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset," State: %s\n" ,dpcm_state_string (be->dpcm[stream].state));if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset += snprintf(buf + offset, size - offset, + offset += scnprintf(buf + offset, size - offset, " Hardware Params: " "Format = %s, Channels = %d, Rate = %d\n", snd_pcm_format_name(params_format(params)),
Signature · 1 line
2.16.4
Mark Brown
maintainerApplied "ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output" to the asoc tree
The patch
ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output
has been applied to the asoc tree at
https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git
All 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
From 6c89ffea60aa3b2a33ae7987de1e84bfb89e4c9e Mon Sep 17 00:00:00 2001
From: Takashi Iwai <[email protected]>
Date: Tue, 18 Feb 2020 12:17:37 +0100
Subject: [PATCH] ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs
output
dpcm_show_state() invokes multiple snprintf() calls to concatenate formatted strings on the fixed size buffer. The usage of snprintf() is supposed for avoiding the buffer overflow, but it doesn't work as expected because snprintf() doesn't return the actual output size but the size to be written.
Fix this bug by replacing all snprintf() calls with scnprintf() calls.
--- sound/soc/soc-pcm.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
sound/soc/soc-pcm.c +8 -8
@@ -3171,16 +3171,16 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,unsigned long flags;/* FE state */ - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset,"[%s - %s]\n" , fe->dai_link->name, stream ?"Capture" :"Playback" ); - offset +=snprintf (buf + offset, size - offset,"State: %s\n" , + offset +=scnprintf (buf + offset, size - offset,"State: %s\n" ,dpcm_state_string (fe->dpcm[stream].state));if ((fe->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && (fe->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset += snprintf(buf + offset, size - offset, + offset += scnprintf(buf + offset, size - offset, "Hardware Params: " "Format = %s, Channels = %d, Rate = %d\n", snd_pcm_format_name(params_format(params)),
@@ -3188,10 +3188,10 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe, params_rate(params));/* BEs state */ - offset +=snprintf (buf + offset, size - offset,"Backends:\n" ); + offset +=scnprintf (buf + offset, size - offset,"Backends:\n" );if (list_empty (&fe->dpcm[stream].be_clients)) { - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset," No active DSP links\n" ); goto out; }
@@ -3201,16 +3201,16 @@ static ssize_t dpcm_show_state(struct snd_soc_pcm_runtime *fe,struct snd_soc_pcm_runtime *be = dpcm->be; params = &dpcm->hw_params; - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset,"- %s\n" , be->dai_link->name); - offset +=snprintf (buf + offset, size - offset, + offset +=scnprintf (buf + offset, size - offset," State: %s\n" ,dpcm_state_string (be->dpcm[stream].state));if ((be->dpcm[stream].state >=SND_SOC_DPCM_STATE_HW_PARAMS ) && (be->dpcm[stream].state <=SND_SOC_DPCM_STATE_STOP )) - offset += snprintf(buf + offset, size - offset, + offset += scnprintf(buf + offset, size - offset, " Hardware Params: " "Format = %s, Channels = %d, Rate = %d\n", snd_pcm_format_name(params_format(params)),
Signature · 1 line
2.20.1
Quoted 11 lines · Takashi Iwai
Hi,
this is a series of patches I spotted during debugging other code. Intel skl and ASoC PCM core invokes succeeding calls of
snprintf()with the incorrect expectation of the return value, which may lead to a buffer overflow.The first patch is yet another bug I found during working on this, and it's rather a real bug that can be seen clearly.
Quoted 8 lines
Takashi
===
Takashi Iwai (3):
ASoC: intel: skl: Fix pin debug prints
ASoC: intel: skl: Fix possible buffer overflow in debug outputs
ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output
Thank you, Takashi for the fixes.
s/skl/skylake/g but I don't mind the shortcut usage at all. For the /intel/skylake patches: