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: pass proper pointers from tioclinux()

Pass proper types and proper pointers (the data with an offset) to the
TIOCL_* handlers. So that they need not to cast or add anything to the
passed pointer.

This makes obvious what is passed/consumed.

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-6-jirislaby@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

authored by

Jiri Slaby (SUSE) and committed by
Greg Kroah-Hartman
a0b8a168 b3dd9bef

+15 -14
+4 -4
drivers/tty/vt/selection.c
··· 7 7 * 'int set_selection_kernel(struct tiocl_selection *, struct tty_struct *)' 8 8 * 'void clear_selection(void)' 9 9 * 'int paste_selection(struct tty_struct *)' 10 - * 'int sel_loadlut(char __user *)' 10 + * 'int sel_loadlut(u32 __user *)' 11 11 * 12 12 * Now that /dev/vcs exists, most of this can disappear again. 13 13 */ ··· 111 111 112 112 /** 113 113 * sel_loadlut() - load the LUT table 114 - * @p: user table 114 + * @lut: user table 115 115 * 116 116 * Load the LUT table from user space. The caller must hold the console 117 117 * lock. Make a temporary copy so a partial update doesn't make a mess. 118 118 */ 119 - int sel_loadlut(char __user *p) 119 + int sel_loadlut(u32 __user *lut) 120 120 { 121 121 u32 tmplut[ARRAY_SIZE(inwordLut)]; 122 - if (copy_from_user(tmplut, (u32 __user *)(p+4), sizeof(inwordLut))) 122 + if (copy_from_user(tmplut, lut, sizeof(inwordLut))) 123 123 return -EFAULT; 124 124 memcpy(inwordLut, tmplut, sizeof(inwordLut)); 125 125 return 0;
+10 -9
drivers/tty/vt/vt.c
··· 145 145 static void save_cur(struct vc_data *vc); 146 146 static void reset_terminal(struct vc_data *vc, int do_clear); 147 147 static void con_flush_chars(struct tty_struct *tty); 148 - static int set_vesa_blanking(char __user *p); 148 + static int set_vesa_blanking(u8 __user *mode); 149 149 static void set_cursor(struct vc_data *vc); 150 150 static void hide_cursor(struct vc_data *vc); 151 151 static void console_callback(struct work_struct *ignored); ··· 3134 3134 { 3135 3135 char type, data; 3136 3136 char __user *p = (char __user *)arg; 3137 + void __user *param_aligned32 = (u32 __user *)arg + 1; 3138 + void __user *param = (void __user *)arg + 1; 3137 3139 int lines; 3138 3140 int ret; 3139 3141 ··· 3149 3147 case TIOCL_SETSEL: 3150 3148 if (!capable(CAP_SYS_ADMIN)) 3151 3149 return -EPERM; 3152 - return set_selection_user((struct tiocl_selection 3153 - __user *)(p+1), tty); 3150 + return set_selection_user(param, tty); 3154 3151 case TIOCL_PASTESEL: 3155 3152 if (!capable(CAP_SYS_ADMIN)) 3156 3153 return -EPERM; ··· 3163 3162 if (!capable(CAP_SYS_ADMIN)) 3164 3163 return -EPERM; 3165 3164 console_lock(); 3166 - ret = sel_loadlut(p); 3165 + ret = sel_loadlut(param_aligned32); 3167 3166 console_unlock(); 3168 3167 break; 3169 3168 case TIOCL_GETSHIFTSTATE: ··· 3182 3181 return put_user(data, p); 3183 3182 case TIOCL_SETVESABLANK: 3184 3183 console_lock(); 3185 - ret = set_vesa_blanking(p); 3184 + ret = set_vesa_blanking(param); 3186 3185 console_unlock(); 3187 3186 break; 3188 3187 case TIOCL_GETKMSGREDIRECT: ··· 3205 3204 */ 3206 3205 return fg_console; 3207 3206 case TIOCL_SCROLLCONSOLE: 3208 - if (get_user(lines, (s32 __user *)(p+4))) 3207 + if (get_user(lines, (s32 __user *)param_aligned32)) 3209 3208 return -EFAULT; 3210 3209 3211 3210 /* ··· 4263 4262 * Screen blanking 4264 4263 */ 4265 4264 4266 - static int set_vesa_blanking(char __user *p) 4265 + static int set_vesa_blanking(u8 __user *mode_user) 4267 4266 { 4268 - unsigned int mode; 4267 + u8 mode; 4269 4268 4270 - if (get_user(mode, p + 1)) 4269 + if (get_user(mode, mode_user)) 4271 4270 return -EFAULT; 4272 4271 4273 4272 vesa_blank_mode = (mode < 4) ? mode : 0;
+1 -1
include/linux/selection.h
··· 20 20 extern int set_selection_kernel(struct tiocl_selection *v, 21 21 struct tty_struct *tty); 22 22 extern int paste_selection(struct tty_struct *tty); 23 - extern int sel_loadlut(char __user *p); 23 + extern int sel_loadlut(u32 __user *lut); 24 24 extern int mouse_reporting(void); 25 25 extern void mouse_report(struct tty_struct * tty, int butt, int mrx, int mry); 26 26