Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

tty: vt: sanitize consw::con_putcs() parameters

Similar to con_putc() in the previous patch:
* make the pointer to charattr a pointer to u16, and
* make x, y, and count unsigned as they are strictly non-negative.

And again, document that hook.

Signed-off-by: "Jiri Slaby (SUSE)" <jirislaby@kernel.org>
Tested-by: Helge Deller <deller@gmx.de> # parisc STI console
Link: https://lore.kernel.org/r/20240122110401.7289-27-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
bfd7de49 338c2810

+22 -19
+5 -5
drivers/video/console/dummycon.c
··· 59 59 raw_notifier_call_chain(&dummycon_output_nh, 0, NULL); 60 60 } 61 61 62 - static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, 63 - int count, int ypos, int xpos) 62 + static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, 63 + unsigned int ypos, unsigned int xpos) 64 64 { 65 - int i; 65 + unsigned int i; 66 66 67 67 if (!dummycon_putc_called) { 68 68 /* Ignore erases */ ··· 87 87 #else 88 88 static void dummycon_putc(struct vc_data *vc, u16 c, unsigned int y, 89 89 unsigned int x) { } 90 - static void dummycon_putcs(struct vc_data *vc, const unsigned short *s, 91 - int count, int ypos, int xpos) { } 90 + static void dummycon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, 91 + unsigned int ypos, unsigned int xpos) { } 92 92 static int dummycon_blank(struct vc_data *vc, int blank, int mode_switch) 93 93 { 94 94 return 0;
+2 -2
drivers/video/console/mdacon.c
··· 427 427 return mda_vram_base + y * mda_num_columns + x; 428 428 } 429 429 430 - static void mdacon_putcs(struct vc_data *c, const unsigned short *s, 431 - int count, int y, int x) 430 + static void mdacon_putcs(struct vc_data *c, const u16 *s, unsigned int count, 431 + unsigned int y, unsigned int x) 432 432 { 433 433 u16 *dest = mda_addr(x, y); 434 434
+5 -4
drivers/video/console/newport_con.c
··· 396 396 RENDER(npregs, p); 397 397 } 398 398 399 - static void newport_putcs(struct vc_data *vc, const unsigned short *s, 400 - int count, int ypos, int xpos) 399 + static void newport_putcs(struct vc_data *vc, const u16 *s, 400 + unsigned int count, unsigned int ypos, 401 + unsigned int xpos) 401 402 { 402 - int i; 403 - int charattr; 404 403 unsigned char *p; 404 + unsigned int i; 405 + u16 charattr; 405 406 406 407 charattr = (scr_readw(s) >> 8) & 0xff; 407 408
+2 -2
drivers/video/console/sticon.c
··· 71 71 return "STI console"; 72 72 } 73 73 74 - static void sticon_putcs(struct vc_data *conp, const unsigned short *s, 75 - int count, int ypos, int xpos) 74 + static void sticon_putcs(struct vc_data *conp, const u16 *s, unsigned int count, 75 + unsigned int ypos, unsigned int xpos) 76 76 { 77 77 if (vga_is_gfx || console_blanked) 78 78 return;
+2 -2
drivers/video/console/vgacon.c
··· 1193 1193 1194 1194 static void vgacon_clear(struct vc_data *vc, unsigned int sy, unsigned int sx, 1195 1195 unsigned int width) { } 1196 - static void vgacon_putcs(struct vc_data *vc, const unsigned short *s, 1197 - int count, int ypos, int xpos) { } 1196 + static void vgacon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, 1197 + unsigned int ypos, unsigned int xpos) { } 1198 1198 1199 1199 const struct consw vga_con = { 1200 1200 .owner = THIS_MODULE,
+2 -2
drivers/video/fbdev/core/fbcon.c
··· 1279 1279 __fbcon_clear(vc, sy, sx, 1, width); 1280 1280 } 1281 1281 1282 - static void fbcon_putcs(struct vc_data *vc, const unsigned short *s, 1283 - int count, int ypos, int xpos) 1282 + static void fbcon_putcs(struct vc_data *vc, const u16 *s, unsigned int count, 1283 + unsigned int ypos, unsigned int xpos) 1284 1284 { 1285 1285 struct fb_info *info = fbcon_info_from_console(vc->vc_num); 1286 1286 struct fbcon_display *p = &fb_display[vc->vc_num];
+4 -2
include/linux/console.h
··· 41 41 * @con_clear: erase @count characters at [@x, @y] on @vc. @count >= 1. 42 42 * @con_putc: emit one character with attributes @ca to [@x, @y] on @vc. 43 43 * (optional -- @con_putcs would be called instead) 44 + * @con_putcs: emit @count characters with attributes @s to [@x, @y] on @vc. 44 45 * @con_scroll: move lines from @top to @bottom in direction @dir by @lines. 45 46 * Return true if no generic handling should be done. 46 47 * Invoked by csi_M and printing to the console. ··· 58 57 unsigned int x, unsigned int count); 59 58 void (*con_putc)(struct vc_data *vc, u16 ca, unsigned int y, 60 59 unsigned int x); 61 - void (*con_putcs)(struct vc_data *vc, const unsigned short *s, 62 - int count, int ypos, int xpos); 60 + void (*con_putcs)(struct vc_data *vc, const u16 *s, 61 + unsigned int count, unsigned int ypos, 62 + unsigned int xpos); 63 63 void (*con_cursor)(struct vc_data *vc, int mode); 64 64 bool (*con_scroll)(struct vc_data *vc, unsigned int top, 65 65 unsigned int bottom, enum con_scroll dir,