Skip to contentSkip to conversation

dm: video: check bounds for column and row

PATCH New Heinrich Schuchardt 3 participants 4 messages Sep 19, 2018 – Sep 26, 2018 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: video: check bounds for column and row

CSI H can be used to position the cursor. The calling application may specify a location that is beyond the limits of the screen. This may lead to an illegal memory access.

---
 drivers/video/vidconsole-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/video/vidconsole-uclass.c +8 -0
index f1d3ad3611..0c36a5de0a 100644
@@ -213,6 +213,14 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 		s++;    /* ; */
 		s = parsenum(s, &col);
 
+		/*
+		 * Ensure we stay in the bounds of the screen.
+		 */
+		if (row >= priv->rows)
+			row = priv->rows - 1;
+		if (col >= priv->cols)
+			col = priv->cols - 1;
+
 		priv->ycur = row * priv->y_charsize;
 		priv->xcur_frac = priv->xstart_frac +
 			VID_TO_POS(col * priv->x_charsize);
Signature · 1 line
2.18.0
#1 lore raw

PATCH 1/1 dm: video: check bounds for column and row

Quoted 5 lines · Heinrich Schuchardt

CSI H can be used to position the cursor. The calling application may specify a location that is beyond the limits of the screen. This may lead to an illegal memory access.

I'll be happy to take this in via efi-next if nobody beats me to it, as it fixes a test failure we're not triggering otherwise.

Alex

Quoted 24 lines
---
 drivers/video/vidconsole-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/video/vidconsole-uclass.c +8 -0
index f1d3ad3611..0c36a5de0a 100644
@@ -213,6 +213,14 @@ static void vidconsole_escape_char(struct udevice *dev, char ch)
 		s++;    /* ; */
 		s = parsenum(s, &col);
 
+		/*
+		 * Ensure we stay in the bounds of the screen.
+		 */
+		if (row >= priv->rows)
+			row = priv->rows - 1;
+		if (col >= priv->cols)
+			col = priv->cols - 1;
+
 		priv->ycur = row * priv->y_charsize;
 		priv->xcur_frac = priv->xstart_frac +
 			VID_TO_POS(col * priv->x_charsize);
#2 lore raw

PATCH 1/1 dm: video: check bounds for column and row

On Sun, 23 Sep 2018 13:35:16 +0200
Alexander Graf agraf at suse.de wrote:
...

Quoted 2 lines

I'll be happy to take this in via efi-next if nobody beats me to it, as it fixes a test failure we're not triggering otherwise.

I've applied this to video tree since later video patches depend on it. Thanks,

--
Anatolij

#3 lore raw

PATCH 1/1 dm: video: check bounds for column and row

In reply to Heinrich Schuchardt
Quoted 8 lines · On Wed, 19 Sep 2018 19:15:14 +0200 Heinrich Schuchardt xypron.glpk at gmx.de…

CSI H can be used to position the cursor. The calling application may specify a location that is beyond the limits of the screen. This may lead to an illegal memory access.

---
 drivers/video/vidconsole-uclass.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Applied to u-boot-video/master, thanks!

--
Anatolij