From: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
To: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>,
Andy Gross <agross@kernel.org>,
Bjorn Andersson <andersson@kernel.org>,
Konrad Dybcio <konrad.dybcio@linaro.org>,
Vinod Koul <vkoul@kernel.org>,
Bard Liao <yung-chuan.liao@linux.intel.com>,
Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>,
Sanyog Kale <sanyog.r.kale@intel.com>,
linux-arm-msm@vger.kernel.org, alsa-devel@alsa-project.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] soundwire: qcom: gracefully handle too many ports in DT
Date: Wed, 15 Mar 2023 13:55:47 +0000 [thread overview]
Message-ID: <109ec760-a139-73b7-81a3-230bb040ca15@linaro.org> (raw)
In-Reply-To: <20230222144412.237832-2-krzysztof.kozlowski@linaro.org>
On 22/02/2023 14:44, Krzysztof Kozlowski wrote:
> There are two issues related to the number of ports coming from
> Devicetree when exceeding in total QCOM_SDW_MAX_PORTS. Both lead to
> incorrect memory accesses:
> 1. With DTS having too big value of input or output ports, the driver,
> when copying port parameters from local/stack arrays into 'pconfig'
> array in 'struct qcom_swrm_ctrl', will iterate over their sizes.
>
> 2. If DTS also has too many parameters for these ports (e.g.
> qcom,ports-sinterval-low), the driver will overflow buffers on the
> stack when reading these properties from DTS.
>
> Add a sanity check so incorrect DTS will not cause kernel memory
> corruption.
>
> Signed-off-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
> ---
Thanks Krzysztof, it make sense.
Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
--srini
> drivers/soundwire/qcom.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
> index 79bebcecde6d..c296e0bf897b 100644
> --- a/drivers/soundwire/qcom.c
> +++ b/drivers/soundwire/qcom.c
> @@ -1218,6 +1218,9 @@ static int qcom_swrm_get_port_config(struct qcom_swrm_ctrl *ctrl)
> ctrl->num_dout_ports = val;
>
> nports = ctrl->num_dout_ports + ctrl->num_din_ports;
> + if (nports > QCOM_SDW_MAX_PORTS)
> + return -EINVAL;
> +
> /* Valid port numbers are from 1-14, so mask out port 0 explicitly */
> set_bit(0, &ctrl->dout_port_mask);
> set_bit(0, &ctrl->din_port_mask);
next prev parent reply other threads:[~2023-03-15 13:56 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-22 14:44 [PATCH 1/2] soundwire: qcom: define hardcoded version magic numbers Krzysztof Kozlowski
2023-02-22 14:44 ` [PATCH 2/2] soundwire: qcom: gracefully handle too many ports in DT Krzysztof Kozlowski
2023-02-22 14:47 ` Konrad Dybcio
2023-02-22 14:50 ` Krzysztof Kozlowski
2023-02-22 14:53 ` Konrad Dybcio
2023-03-15 13:55 ` Srinivas Kandagatla [this message]
2023-02-22 14:45 ` [PATCH 1/2] soundwire: qcom: define hardcoded version magic numbers Konrad Dybcio
2023-03-15 13:55 ` Srinivas Kandagatla
2023-03-15 14:13 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=109ec760-a139-73b7-81a3-230bb040ca15@linaro.org \
--to=srinivas.kandagatla@linaro.org \
--cc=agross@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=andersson@kernel.org \
--cc=konrad.dybcio@linaro.org \
--cc=krzysztof.kozlowski@linaro.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=pierre-louis.bossart@linux.intel.com \
--cc=sanyog.r.kale@intel.com \
--cc=vkoul@kernel.org \
--cc=yung-chuan.liao@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox