Patch "drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer" has been added to the 6.6-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

    drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer

to the 6.6-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:
     drm-bridge-parade-ps8640-never-store-more-than-msg-s.patch
and it can be found in the queue-6.6 subdirectory.

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



commit 4b3b4003280beb9ca9f950193e9244fc3aff313d
Author: Douglas Anderson <dianders@xxxxxxxxxxxx>
Date:   Thu Dec 14 12:37:51 2023 -0800

    drm/bridge: parade-ps8640: Never store more than msg->size bytes in AUX xfer
    
    [ Upstream commit 3164c8a70073d43629b4e11e083d3d2798f7750f ]
    
    While testing, I happened to notice a random crash that looked like:
    
      Kernel panic - not syncing: stack-protector:
      Kernel stack is corrupted in: drm_dp_dpcd_probe+0x120/0x120
    
    Analysis of drm_dp_dpcd_probe() shows that we pass in a 1-byte buffer
    (allocated on the stack) to the aux->transfer() function. Presumably
    if the aux->transfer() writes more than one byte to this buffer then
    we're in a bad shape.
    
    Dropping into kgdb, I noticed that "aux->transfer" pointed at
    ps8640_aux_transfer().
    
    Reading through ps8640_aux_transfer(), I can see that there are cases
    where it could write more bytes to msg->buffer than were specified by
    msg->size. This could happen if the hardware reported back something
    bogus to us. Let's fix this so we never write more than msg->size
    bytes. We'll still read all the bytes from the hardware just in case
    the hardware requires it since the aux transfer data comes through an
    auto-incrementing register.
    
    NOTE: I have no actual way to reproduce this issue but it seems likely
    this is what was happening in the crash I looked at.
    
    Fixes: 13afcdd7277e ("drm/bridge: parade-ps8640: Add support for AUX channel")
    Reviewed-by: Stephen Boyd <swboyd@xxxxxxxxxxxx>
    Reviewed-by: Guenter Roeck <groeck@xxxxxxxxxxxx>
    Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>
    Link: https://patchwork.freedesktop.org/patch/msgid/20231214123752.v3.1.I9d1afcaad76a3e2c0ca046dc4adbc2b632c22eda@changeid
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpu/drm/bridge/parade-ps8640.c b/drivers/gpu/drm/bridge/parade-ps8640.c
index 8161b1a1a4b12..d264b80d909de 100644
--- a/drivers/gpu/drm/bridge/parade-ps8640.c
+++ b/drivers/gpu/drm/bridge/parade-ps8640.c
@@ -330,11 +330,12 @@ static ssize_t ps8640_aux_transfer_msg(struct drm_dp_aux *aux,
 				return ret;
 			}
 
-			buf[i] = data;
+			if (i < msg->size)
+				buf[i] = data;
 		}
 	}
 
-	return len;
+	return min(len, msg->size);
 }
 
 static ssize_t ps8640_aux_transfer(struct drm_dp_aux *aux,




[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