Patch "soundwire: qcom: gracefully handle too many ports in DT" has been added to the 6.3-stable tree

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

 



This is a note to let you know that I've just added the patch titled

    soundwire: qcom: gracefully handle too many ports in DT

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     soundwire-qcom-gracefully-handle-too-many-ports-in-d.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 9aefd71f65dd7b708f89f728b3c691fd9de754b0
Author: Krzysztof Kozlowski <krzysztof.kozlowski@xxxxxxxxxx>
Date:   Wed Feb 22 15:44:12 2023 +0100

    soundwire: qcom: gracefully handle too many ports in DT
    
    [ Upstream commit 2367e0ecb498764e95cfda691ff0828f7d25f9a4 ]
    
    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@xxxxxxxxxx>
    Reviewed-by: Srinivas Kandagatla <srinivas.kandagatla@xxxxxxxxxx>
    Reviewed-by: Konrad Dybcio <konrad.dybcio@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230222144412.237832-2-krzysztof.kozlowski@xxxxxxxxxx
    Signed-off-by: Vinod Koul <vkoul@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/soundwire/qcom.c b/drivers/soundwire/qcom.c
index ba502129150d5..30575ed20947e 100644
--- a/drivers/soundwire/qcom.c
+++ b/drivers/soundwire/qcom.c
@@ -1217,6 +1217,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);



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux