Commit f8a4c3b5250496f072d9098a641fd5642146d999
Committed by
Linus Torvalds
1 parent
94b3e03c87
Exists in
master
and in
4 other branches
tty: fix tty network driver interactions with TCGET/TCSET calls (x86 fix)
And to go with it Dave's type checking x86 termios headers. I've updated these as the original sent by Dave had some wrong types in it. Signed-off-by: Alan Cox <alan@redhat.com> Cc: "David S. Miller" <davem@davemloft.net> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 45 additions and 29 deletions Side-by-side Diff
include/asm-x86/termios.h
... | ... | @@ -41,6 +41,8 @@ |
41 | 41 | |
42 | 42 | #ifdef __KERNEL__ |
43 | 43 | |
44 | +#include <asm/uaccess.h> | |
45 | + | |
44 | 46 | /* intr=^C quit=^\ erase=del kill=^U |
45 | 47 | eof=^D vtime=\0 vmin=\1 sxtc=\0 |
46 | 48 | start=^Q stop=^S susp=^Z eol=\0 |
47 | 49 | |
48 | 50 | |
49 | 51 | |
50 | 52 | |
51 | 53 | |
... | ... | @@ -58,39 +60,53 @@ |
58 | 60 | *(unsigned short *) &(termios)->x = __tmp; \ |
59 | 61 | } |
60 | 62 | |
61 | -#define user_termio_to_kernel_termios(termios, termio) \ | |
62 | -({ \ | |
63 | - SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); \ | |
64 | - SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); \ | |
65 | - SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); \ | |
66 | - SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); \ | |
67 | - copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ | |
68 | -}) | |
63 | +static inline int user_termio_to_kernel_termios(struct ktermios *termios, | |
64 | + struct termio __user *termio) | |
65 | +{ | |
66 | + SET_LOW_TERMIOS_BITS(termios, termio, c_iflag); | |
67 | + SET_LOW_TERMIOS_BITS(termios, termio, c_oflag); | |
68 | + SET_LOW_TERMIOS_BITS(termios, termio, c_cflag); | |
69 | + SET_LOW_TERMIOS_BITS(termios, termio, c_lflag); | |
70 | + return copy_from_user(termios->c_cc, termio->c_cc, NCC); | |
71 | +} | |
69 | 72 | |
70 | 73 | /* |
71 | 74 | * Translate a "termios" structure into a "termio". Ugh. |
72 | 75 | */ |
73 | -#define kernel_termios_to_user_termio(termio, termios) \ | |
74 | -({ \ | |
75 | - put_user((termios)->c_iflag, &(termio)->c_iflag); \ | |
76 | - put_user((termios)->c_oflag, &(termio)->c_oflag); \ | |
77 | - put_user((termios)->c_cflag, &(termio)->c_cflag); \ | |
78 | - put_user((termios)->c_lflag, &(termio)->c_lflag); \ | |
79 | - put_user((termios)->c_line, &(termio)->c_line); \ | |
80 | - copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | |
81 | -}) | |
76 | +static inline int kernel_termios_to_user_termio(struct termio __user *termio, | |
77 | + struct ktermios *termios) | |
78 | +{ | |
79 | + put_user((termios)->c_iflag, &(termio)->c_iflag); | |
80 | + put_user((termios)->c_oflag, &(termio)->c_oflag); | |
81 | + put_user((termios)->c_cflag, &(termio)->c_cflag); | |
82 | + put_user((termios)->c_lflag, &(termio)->c_lflag); | |
83 | + put_user((termios)->c_line, &(termio)->c_line); | |
84 | + return copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); | |
85 | +} | |
82 | 86 | |
83 | -#define user_termios_to_kernel_termios(k, u) \ | |
84 | - copy_from_user(k, u, sizeof(struct termios2)) | |
87 | +static inline int user_termios_to_kernel_termios(struct ktermios *k, | |
88 | + struct termios2 __user *u) | |
89 | +{ | |
90 | + return copy_from_user(k, u, sizeof(struct termios2)); | |
91 | +} | |
85 | 92 | |
86 | -#define kernel_termios_to_user_termios(u, k) \ | |
87 | - copy_to_user(u, k, sizeof(struct termios2)) | |
93 | +static inline int kernel_termios_to_user_termios(struct termios2 __user *u, | |
94 | + struct ktermios *k) | |
95 | +{ | |
96 | + return copy_to_user(u, k, sizeof(struct termios2)); | |
97 | +} | |
88 | 98 | |
89 | -#define user_termios_to_kernel_termios_1(k, u) \ | |
90 | - copy_from_user(k, u, sizeof(struct termios)) | |
99 | +static inline int user_termios_to_kernel_termios_1(struct ktermios *k, | |
100 | + struct termios __user *u) | |
101 | +{ | |
102 | + return copy_from_user(k, u, sizeof(struct termios)); | |
103 | +} | |
91 | 104 | |
92 | -#define kernel_termios_to_user_termios_1(u, k) \ | |
93 | - copy_to_user(u, k, sizeof(struct termios)) | |
105 | +static inline int kernel_termios_to_user_termios_1(struct termios __user *u, | |
106 | + struct ktermios *k) | |
107 | +{ | |
108 | + return copy_to_user(u, k, sizeof(struct termios)); | |
109 | +} | |
94 | 110 | |
95 | 111 | #endif /* __KERNEL__ */ |
96 | 112 |