tty: vt: sanitize arguments of consw::con_clear()
[ Upstream commit 559f01a0ee6d924c6fec3eaf6a5b078b15e71070 ] In consw::con_clear(): * Height is always 1, so drop it. * Offsets and width are always unsigned values, so re-type them as such. This needs a new __fbcon_clear() in the fbcon code to still handle height which might not be 1 when called internally. Note that tests for negative count/width are left in place -- they are taken care of in the next patches. And document the hook. Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org> Cc: Helge Deller <deller@gmx.de> Cc: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com> Cc: Daniel Vetter <daniel@ffwll.ch> Cc: linux-fbdev@vger.kernel.org Cc: dri-devel@lists.freedesktop.org Cc: linux-parisc@vger.kernel.org Tested-by: Helge Deller <deller@gmx.de> # parisc STI console Link: https://lore.kernel.org/r/20240122110401.7289-22-jirislaby@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Stable-dep-of: 03bcbbb3995b ("dummycon: Trigger redraw when switching consoles with deferred takeover") Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
0b10b5ab7d
commit
e9ba8c528b
@@ -1582,7 +1582,7 @@ static void csi_X(struct vc_data *vc, unsigned int vpar)
|
|||||||
vc_uniscr_clear_line(vc, vc->state.x, count);
|
vc_uniscr_clear_line(vc, vc->state.x, count);
|
||||||
scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
|
scr_memsetw((unsigned short *)vc->vc_pos, vc->vc_video_erase_char, 2 * count);
|
||||||
if (con_should_update(vc))
|
if (con_should_update(vc))
|
||||||
vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, 1, count);
|
vc->vc_sw->con_clear(vc, vc->state.y, vc->state.x, count);
|
||||||
vc->vc_need_wrap = 0;
|
vc->vc_need_wrap = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -108,8 +108,8 @@ static void dummycon_init(struct vc_data *vc, bool init)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void dummycon_deinit(struct vc_data *vc) { }
|
static void dummycon_deinit(struct vc_data *vc) { }
|
||||||
static void dummycon_clear(struct vc_data *vc, int sy, int sx, int height,
|
static void dummycon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
|
||||||
int width) { }
|
unsigned int width) { }
|
||||||
static void dummycon_cursor(struct vc_data *vc, int mode) { }
|
static void dummycon_cursor(struct vc_data *vc, int mode) { }
|
||||||
|
|
||||||
static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
|
static bool dummycon_scroll(struct vc_data *vc, unsigned int top,
|
||||||
|
@@ -442,23 +442,18 @@ static void mdacon_putcs(struct vc_data *c, const unsigned short *s,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mdacon_clear(struct vc_data *c, int y, int x,
|
static void mdacon_clear(struct vc_data *c, unsigned int y, unsigned int x,
|
||||||
int height, int width)
|
unsigned int width)
|
||||||
{
|
{
|
||||||
u16 *dest = mda_addr(x, y);
|
u16 *dest = mda_addr(x, y);
|
||||||
u16 eattr = mda_convert_attr(c->vc_video_erase_char);
|
u16 eattr = mda_convert_attr(c->vc_video_erase_char);
|
||||||
|
|
||||||
if (width <= 0 || height <= 0)
|
if (width <= 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (x==0 && width==mda_num_columns) {
|
scr_memsetw(dest, eattr, width * 2);
|
||||||
scr_memsetw(dest, eattr, height*width*2);
|
|
||||||
} else {
|
|
||||||
for (; height > 0; height--, dest+=mda_num_columns)
|
|
||||||
scr_memsetw(dest, eattr, width*2);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mdacon_switch(struct vc_data *c)
|
static int mdacon_switch(struct vc_data *c)
|
||||||
{
|
{
|
||||||
return 1; /* redrawing needed */
|
return 1; /* redrawing needed */
|
||||||
|
@@ -346,12 +346,12 @@ static void newport_deinit(struct vc_data *c)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void newport_clear(struct vc_data *vc, int sy, int sx, int height,
|
static void newport_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
|
||||||
int width)
|
unsigned int width)
|
||||||
{
|
{
|
||||||
int xend = ((sx + width) << 3) - 1;
|
int xend = ((sx + width) << 3) - 1;
|
||||||
int ystart = ((sy << 4) + topscan) & 0x3ff;
|
int ystart = ((sy << 4) + topscan) & 0x3ff;
|
||||||
int yend = (((sy + height) << 4) + topscan - 1) & 0x3ff;
|
int yend = (((sy + 1) << 4) + topscan - 1) & 0x3ff;
|
||||||
|
|
||||||
if (logo_active)
|
if (logo_active)
|
||||||
return;
|
return;
|
||||||
|
@@ -300,13 +300,13 @@ static void sticon_deinit(struct vc_data *c)
|
|||||||
sticon_set_def_font(i);
|
sticon_set_def_font(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void sticon_clear(struct vc_data *conp, int sy, int sx, int height,
|
static void sticon_clear(struct vc_data *conp, unsigned int sy, unsigned int sx,
|
||||||
int width)
|
unsigned int width)
|
||||||
{
|
{
|
||||||
if (!height || !width)
|
if (!width)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sti_clear(sticon_sti, sy, sx, height, width,
|
sti_clear(sticon_sti, sy, sx, 1, width,
|
||||||
conp->vc_video_erase_char, font_data[conp->vc_num]);
|
conp->vc_video_erase_char, font_data[conp->vc_num]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1156,8 +1156,8 @@ static bool vgacon_scroll(struct vc_data *c, unsigned int t, unsigned int b,
|
|||||||
* The console `switch' structure for the VGA based console
|
* The console `switch' structure for the VGA based console
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void vgacon_clear(struct vc_data *vc, int sy, int sx, int height,
|
static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
|
||||||
int width) { }
|
unsigned int width) { }
|
||||||
static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
|
static void vgacon_putc(struct vc_data *vc, int c, int ypos, int xpos) { }
|
||||||
static void vgacon_putcs(struct vc_data *vc, const unsigned short *s,
|
static void vgacon_putcs(struct vc_data *vc, const unsigned short *s,
|
||||||
int count, int ypos, int xpos) { }
|
int count, int ypos, int xpos) { }
|
||||||
|
@@ -1240,8 +1240,8 @@ finished:
|
|||||||
* restriction is simplicity & efficiency at the moment.
|
* restriction is simplicity & efficiency at the moment.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
|
static void __fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
|
||||||
int width)
|
unsigned int height, unsigned int width)
|
||||||
{
|
{
|
||||||
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
|
struct fb_info *info = fbcon_info_from_console(vc->vc_num);
|
||||||
struct fbcon_ops *ops = info->fbcon_par;
|
struct fbcon_ops *ops = info->fbcon_par;
|
||||||
@@ -1280,6 +1280,12 @@ static void fbcon_clear(struct vc_data *vc, int sy, int sx, int height,
|
|||||||
ops->clear(vc, info, real_y(p, sy), sx, height, width, fg, bg);
|
ops->clear(vc, info, real_y(p, sy), sx, height, width, fg, bg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void fbcon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx,
|
||||||
|
unsigned int width)
|
||||||
|
{
|
||||||
|
__fbcon_clear(vc, sy, sx, 1, width);
|
||||||
|
}
|
||||||
|
|
||||||
static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
|
static void fbcon_putcs(struct vc_data *vc, const unsigned short *s,
|
||||||
int count, int ypos, int xpos)
|
int count, int ypos, int xpos)
|
||||||
{
|
{
|
||||||
@@ -1767,7 +1773,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
case SCROLL_MOVE:
|
case SCROLL_MOVE:
|
||||||
fbcon_redraw_blit(vc, info, p, t, b - t - count,
|
fbcon_redraw_blit(vc, info, p, t, b - t - count,
|
||||||
count);
|
count);
|
||||||
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
||||||
scr_memsetw((unsigned short *) (vc->vc_origin +
|
scr_memsetw((unsigned short *) (vc->vc_origin +
|
||||||
vc->vc_size_row *
|
vc->vc_size_row *
|
||||||
(b - count)),
|
(b - count)),
|
||||||
@@ -1790,7 +1796,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
b - t - count, vc->vc_cols);
|
b - t - count, vc->vc_cols);
|
||||||
else
|
else
|
||||||
goto redraw_up;
|
goto redraw_up;
|
||||||
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_PAN_REDRAW:
|
case SCROLL_PAN_REDRAW:
|
||||||
@@ -1808,7 +1814,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
vc->vc_rows - b, b);
|
vc->vc_rows - b, b);
|
||||||
} else
|
} else
|
||||||
fbcon_redraw_move(vc, p, t + count, b - t - count, t);
|
fbcon_redraw_move(vc, p, t + count, b - t - count, t);
|
||||||
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_PAN_MOVE:
|
case SCROLL_PAN_MOVE:
|
||||||
@@ -1831,14 +1837,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
b - t - count, vc->vc_cols);
|
b - t - count, vc->vc_cols);
|
||||||
else
|
else
|
||||||
goto redraw_up;
|
goto redraw_up;
|
||||||
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_REDRAW:
|
case SCROLL_REDRAW:
|
||||||
redraw_up:
|
redraw_up:
|
||||||
fbcon_redraw(vc, t, b - t - count,
|
fbcon_redraw(vc, t, b - t - count,
|
||||||
count * vc->vc_cols);
|
count * vc->vc_cols);
|
||||||
fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, b - count, 0, count, vc->vc_cols);
|
||||||
scr_memsetw((unsigned short *) (vc->vc_origin +
|
scr_memsetw((unsigned short *) (vc->vc_origin +
|
||||||
vc->vc_size_row *
|
vc->vc_size_row *
|
||||||
(b - count)),
|
(b - count)),
|
||||||
@@ -1855,7 +1861,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
case SCROLL_MOVE:
|
case SCROLL_MOVE:
|
||||||
fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
|
fbcon_redraw_blit(vc, info, p, b - 1, b - t - count,
|
||||||
-count);
|
-count);
|
||||||
fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
||||||
scr_memsetw((unsigned short *) (vc->vc_origin +
|
scr_memsetw((unsigned short *) (vc->vc_origin +
|
||||||
vc->vc_size_row *
|
vc->vc_size_row *
|
||||||
t),
|
t),
|
||||||
@@ -1878,7 +1884,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
b - t - count, vc->vc_cols);
|
b - t - count, vc->vc_cols);
|
||||||
else
|
else
|
||||||
goto redraw_down;
|
goto redraw_down;
|
||||||
fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_PAN_MOVE:
|
case SCROLL_PAN_MOVE:
|
||||||
@@ -1900,7 +1906,7 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
b - t - count, vc->vc_cols);
|
b - t - count, vc->vc_cols);
|
||||||
else
|
else
|
||||||
goto redraw_down;
|
goto redraw_down;
|
||||||
fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_PAN_REDRAW:
|
case SCROLL_PAN_REDRAW:
|
||||||
@@ -1917,14 +1923,14 @@ static bool fbcon_scroll(struct vc_data *vc, unsigned int t, unsigned int b,
|
|||||||
fbcon_redraw_move(vc, p, count, t, 0);
|
fbcon_redraw_move(vc, p, count, t, 0);
|
||||||
} else
|
} else
|
||||||
fbcon_redraw_move(vc, p, t, b - t - count, t + count);
|
fbcon_redraw_move(vc, p, t, b - t - count, t + count);
|
||||||
fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SCROLL_REDRAW:
|
case SCROLL_REDRAW:
|
||||||
redraw_down:
|
redraw_down:
|
||||||
fbcon_redraw(vc, b - 1, b - t - count,
|
fbcon_redraw(vc, b - 1, b - t - count,
|
||||||
-count * vc->vc_cols);
|
-count * vc->vc_cols);
|
||||||
fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
__fbcon_clear(vc, t, 0, count, vc->vc_cols);
|
||||||
scr_memsetw((unsigned short *) (vc->vc_origin +
|
scr_memsetw((unsigned short *) (vc->vc_origin +
|
||||||
vc->vc_size_row *
|
vc->vc_size_row *
|
||||||
t),
|
t),
|
||||||
@@ -2203,7 +2209,7 @@ static void fbcon_generic_blank(struct vc_data *vc, struct fb_info *info,
|
|||||||
|
|
||||||
oldc = vc->vc_video_erase_char;
|
oldc = vc->vc_video_erase_char;
|
||||||
vc->vc_video_erase_char &= charmask;
|
vc->vc_video_erase_char &= charmask;
|
||||||
fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
|
__fbcon_clear(vc, 0, 0, vc->vc_rows, vc->vc_cols);
|
||||||
vc->vc_video_erase_char = oldc;
|
vc->vc_video_erase_char = oldc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -38,6 +38,7 @@ enum vc_intensity;
|
|||||||
*
|
*
|
||||||
* @con_init: initialize the console on @vc. @init is true for the very first
|
* @con_init: initialize the console on @vc. @init is true for the very first
|
||||||
* call on this @vc.
|
* call on this @vc.
|
||||||
|
* @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1.
|
||||||
* @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
|
* @con_scroll: move lines from @top to @bottom in direction @dir by @lines.
|
||||||
* Return true if no generic handling should be done.
|
* Return true if no generic handling should be done.
|
||||||
* Invoked by csi_M and printing to the console.
|
* Invoked by csi_M and printing to the console.
|
||||||
@@ -50,8 +51,8 @@ struct consw {
|
|||||||
const char *(*con_startup)(void);
|
const char *(*con_startup)(void);
|
||||||
void (*con_init)(struct vc_data *vc, bool init);
|
void (*con_init)(struct vc_data *vc, bool init);
|
||||||
void (*con_deinit)(struct vc_data *vc);
|
void (*con_deinit)(struct vc_data *vc);
|
||||||
void (*con_clear)(struct vc_data *vc, int sy, int sx, int height,
|
void (*con_clear)(struct vc_data *vc, unsigned int y,
|
||||||
int width);
|
unsigned int x, unsigned int count);
|
||||||
void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
|
void (*con_putc)(struct vc_data *vc, int c, int ypos, int xpos);
|
||||||
void (*con_putcs)(struct vc_data *vc, const unsigned short *s,
|
void (*con_putcs)(struct vc_data *vc, const unsigned short *s,
|
||||||
int count, int ypos, int xpos);
|
int count, int ypos, int xpos);
|
||||||
|
Reference in New Issue
Block a user