diff options
author | David S. Miller <davem@davemloft.net> | 2005-06-24 23:11:03 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2005-06-24 23:11:03 -0400 |
commit | e55c57e0b51c68d78845549505057169c6c3cba6 (patch) | |
tree | 0cd6da51ab2341c67b58d690c61edb4c6dda976b /include | |
parent | 37616578539a47d9ace5e907ae73ea93a8cde740 (diff) |
[SPARC64]: Report any user access faults in termios accessors.
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-sparc64/termios.h | 78 |
1 files changed, 41 insertions, 37 deletions
diff --git a/include/asm-sparc64/termios.h b/include/asm-sparc64/termios.h index 8effce0da087..9777a9cca88a 100644 --- a/include/asm-sparc64/termios.h +++ b/include/asm-sparc64/termios.h | |||
@@ -100,16 +100,17 @@ struct winsize { | |||
100 | #define user_termio_to_kernel_termios(termios, termio) \ | 100 | #define user_termio_to_kernel_termios(termios, termio) \ |
101 | ({ \ | 101 | ({ \ |
102 | unsigned short tmp; \ | 102 | unsigned short tmp; \ |
103 | get_user(tmp, &(termio)->c_iflag); \ | 103 | int err; \ |
104 | err = get_user(tmp, &(termio)->c_iflag); \ | ||
104 | (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \ | 105 | (termios)->c_iflag = (0xffff0000 & ((termios)->c_iflag)) | tmp; \ |
105 | get_user(tmp, &(termio)->c_oflag); \ | 106 | err |= get_user(tmp, &(termio)->c_oflag); \ |
106 | (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \ | 107 | (termios)->c_oflag = (0xffff0000 & ((termios)->c_oflag)) | tmp; \ |
107 | get_user(tmp, &(termio)->c_cflag); \ | 108 | err |= get_user(tmp, &(termio)->c_cflag); \ |
108 | (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \ | 109 | (termios)->c_cflag = (0xffff0000 & ((termios)->c_cflag)) | tmp; \ |
109 | get_user(tmp, &(termio)->c_lflag); \ | 110 | err |= get_user(tmp, &(termio)->c_lflag); \ |
110 | (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \ | 111 | (termios)->c_lflag = (0xffff0000 & ((termios)->c_lflag)) | tmp; \ |
111 | copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ | 112 | err |= copy_from_user((termios)->c_cc, (termio)->c_cc, NCC); \ |
112 | 0; \ | 113 | err; \ |
113 | }) | 114 | }) |
114 | 115 | ||
115 | /* | 116 | /* |
@@ -119,53 +120,56 @@ struct winsize { | |||
119 | */ | 120 | */ |
120 | #define kernel_termios_to_user_termio(termio, termios) \ | 121 | #define kernel_termios_to_user_termio(termio, termios) \ |
121 | ({ \ | 122 | ({ \ |
122 | put_user((termios)->c_iflag, &(termio)->c_iflag); \ | 123 | int err; \ |
123 | put_user((termios)->c_oflag, &(termio)->c_oflag); \ | 124 | err = put_user((termios)->c_iflag, &(termio)->c_iflag); \ |
124 | put_user((termios)->c_cflag, &(termio)->c_cflag); \ | 125 | err |= put_user((termios)->c_oflag, &(termio)->c_oflag); \ |
125 | put_user((termios)->c_lflag, &(termio)->c_lflag); \ | 126 | err |= put_user((termios)->c_cflag, &(termio)->c_cflag); \ |
126 | put_user((termios)->c_line, &(termio)->c_line); \ | 127 | err |= put_user((termios)->c_lflag, &(termio)->c_lflag); \ |
127 | copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | 128 | err |= put_user((termios)->c_line, &(termio)->c_line); \ |
129 | err |= copy_to_user((termio)->c_cc, (termios)->c_cc, NCC); \ | ||
128 | if (!((termios)->c_lflag & ICANON)) { \ | 130 | if (!((termios)->c_lflag & ICANON)) { \ |
129 | put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \ | 131 | err |= put_user((termios)->c_cc[VMIN], &(termio)->c_cc[_VMIN]); \ |
130 | put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \ | 132 | err |= put_user((termios)->c_cc[VTIME], &(termio)->c_cc[_VTIME]); \ |
131 | } \ | 133 | } \ |
132 | 0; \ | 134 | err; \ |
133 | }) | 135 | }) |
134 | 136 | ||
135 | #define user_termios_to_kernel_termios(k, u) \ | 137 | #define user_termios_to_kernel_termios(k, u) \ |
136 | ({ \ | 138 | ({ \ |
137 | get_user((k)->c_iflag, &(u)->c_iflag); \ | 139 | int err; \ |
138 | get_user((k)->c_oflag, &(u)->c_oflag); \ | 140 | err = get_user((k)->c_iflag, &(u)->c_iflag); \ |
139 | get_user((k)->c_cflag, &(u)->c_cflag); \ | 141 | err |= get_user((k)->c_oflag, &(u)->c_oflag); \ |
140 | get_user((k)->c_lflag, &(u)->c_lflag); \ | 142 | err |= get_user((k)->c_cflag, &(u)->c_cflag); \ |
141 | get_user((k)->c_line, &(u)->c_line); \ | 143 | err |= get_user((k)->c_lflag, &(u)->c_lflag); \ |
142 | copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \ | 144 | err |= get_user((k)->c_line, &(u)->c_line); \ |
145 | err |= copy_from_user((k)->c_cc, (u)->c_cc, NCCS); \ | ||
143 | if((k)->c_lflag & ICANON) { \ | 146 | if((k)->c_lflag & ICANON) { \ |
144 | get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ | 147 | err |= get_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ |
145 | get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ | 148 | err |= get_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ |
146 | } else { \ | 149 | } else { \ |
147 | get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ | 150 | err |= get_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ |
148 | get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ | 151 | err |= get_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ |
149 | } \ | 152 | } \ |
150 | 0; \ | 153 | err; \ |
151 | }) | 154 | }) |
152 | 155 | ||
153 | #define kernel_termios_to_user_termios(u, k) \ | 156 | #define kernel_termios_to_user_termios(u, k) \ |
154 | ({ \ | 157 | ({ \ |
155 | put_user((k)->c_iflag, &(u)->c_iflag); \ | 158 | int err; \ |
156 | put_user((k)->c_oflag, &(u)->c_oflag); \ | 159 | err = put_user((k)->c_iflag, &(u)->c_iflag); \ |
157 | put_user((k)->c_cflag, &(u)->c_cflag); \ | 160 | err |= put_user((k)->c_oflag, &(u)->c_oflag); \ |
158 | put_user((k)->c_lflag, &(u)->c_lflag); \ | 161 | err |= put_user((k)->c_cflag, &(u)->c_cflag); \ |
159 | put_user((k)->c_line, &(u)->c_line); \ | 162 | err |= put_user((k)->c_lflag, &(u)->c_lflag); \ |
160 | copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \ | 163 | err |= put_user((k)->c_line, &(u)->c_line); \ |
164 | err |= copy_to_user((u)->c_cc, (k)->c_cc, NCCS); \ | ||
161 | if(!((k)->c_lflag & ICANON)) { \ | 165 | if(!((k)->c_lflag & ICANON)) { \ |
162 | put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ | 166 | err |= put_user((k)->c_cc[VMIN], &(u)->c_cc[_VMIN]); \ |
163 | put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ | 167 | err |= put_user((k)->c_cc[VTIME], &(u)->c_cc[_VTIME]); \ |
164 | } else { \ | 168 | } else { \ |
165 | put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ | 169 | err |= put_user((k)->c_cc[VEOF], &(u)->c_cc[VEOF]); \ |
166 | put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ | 170 | err |= put_user((k)->c_cc[VEOL], &(u)->c_cc[VEOL]); \ |
167 | } \ | 171 | } \ |
168 | 0; \ | 172 | err; \ |
169 | }) | 173 | }) |
170 | 174 | ||
171 | #endif /* __KERNEL__ */ | 175 | #endif /* __KERNEL__ */ |