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

[S390] termio <-> termios conversion error handling.

Get rid of our own user_termio_to_kernel_termios() and
kernel_termios_to_user_termio() macros which didn't check for errors
on user space accesses. Instead use the generic functions which
handle this properly.
In addition the generic version of user_termio_to_kernel_termios()
also copies the c_line member which was missing in our variant.

Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>

authored by

Heiko Carstens and committed by
Martin Schwidefsky
654452a4 bba125a6

+1 -33
+1 -33
include/asm-s390/termios.h
··· 75 75 */ 76 76 #define INIT_C_CC "\003\034\177\025\004\0\1\0\021\023\032\0\022\017\027\026\0" 77 77 78 - /* 79 - * Translate a "termio" structure into a "termios". Ugh. 80 - */ 81 - #define SET_LOW_TERMIOS_BITS(termios, termio, x) { \ 82 - unsigned short __tmp; \ 83 - get_user(__tmp,&(termio)->x); \ 84 - (termios)->x = (0xffff0000 & ((termios)->x)) | __tmp; \ 85 - } 86 - 87 - #define user_termio_to_kernel_termios(termios, termio) \ 88 - ({ \ 89 - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ 90 - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ 91 - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ 92 - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ 93 - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ 94 - }) 95 - 96 - /* 97 - * Translate a "termios" structure into a "termio". Ugh. 98 - */ 99 - #define kernel_termios_to_user_termio(termio, termios) \ 100 - ({ \ 101 - put_user((termios)->c_iflag, &(termio)->c_iflag); \ 102 - put_user((termios)->c_oflag, &(termio)->c_oflag); \ 103 - put_user((termios)->c_cflag, &(termio)->c_cflag); \ 104 - put_user((termios)->c_lflag, &(termio)->c_lflag); \ 105 - put_user((termios)->c_line, &(termio)->c_line); \ 106 - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ 107 - }) 108 - 109 - #define user_termios_to_kernel_termios(k, u) copy_from_user(k, u, sizeof(struct termios)) 110 - #define kernel_termios_to_user_termios(u, k) copy_to_user(u, k, sizeof(struct termios)) 78 + #include <asm-generic/termios.h> 111 79 112 80 #endif /* __KERNEL__ */ 113 81