Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 1991, 1992 Paul Kranenburg <pk@cs.few.eur.nl> |
| 3 | * Copyright (c) 1993 Branko Lankester <branko@hacktic.nl> |
| 4 | * Copyright (c) 1993, 1994, 1995, 1996 Rick Sladkey <jrs@world.std.com> |
Wichert Akkerman | 4dc8a2a | 1999-12-23 14:20:14 +0000 | [diff] [blame] | 5 | * Copyright (c) 1996-1999 Wichert Akkerman <wichert@cistron.nl> |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 6 | * Copyright (c) 1999-2018 The strace developers. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 7 | * All rights reserved. |
| 8 | * |
| 9 | * Redistribution and use in source and binary forms, with or without |
| 10 | * modification, are permitted provided that the following conditions |
| 11 | * are met: |
| 12 | * 1. Redistributions of source code must retain the above copyright |
| 13 | * notice, this list of conditions and the following disclaimer. |
| 14 | * 2. Redistributions in binary form must reproduce the above copyright |
| 15 | * notice, this list of conditions and the following disclaimer in the |
| 16 | * documentation and/or other materials provided with the distribution. |
| 17 | * 3. The name of the author may not be used to endorse or promote products |
| 18 | * derived from this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 21 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 22 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 23 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 24 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 25 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 26 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 29 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 30 | */ |
| 31 | |
| 32 | #include "defs.h" |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 33 | #include "xstring.h" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 34 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 35 | SYS_FUNC(close) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 36 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 37 | printfd(tcp, tcp->u_arg[0]); |
| 38 | |
| 39 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 40 | } |
| 41 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 42 | SYS_FUNC(dup) |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 43 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 44 | printfd(tcp, tcp->u_arg[0]); |
| 45 | |
| 46 | return RVAL_DECODED | RVAL_FD; |
Zubin Mithra | 64aa1b1 | 2014-06-04 08:30:41 +0530 | [diff] [blame] | 47 | } |
| 48 | |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 49 | static int |
| 50 | do_dup2(struct tcb *tcp, int flags_arg) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 51 | { |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 52 | printfd(tcp, tcp->u_arg[0]); |
| 53 | tprints(", "); |
| 54 | printfd(tcp, tcp->u_arg[1]); |
| 55 | if (flags_arg >= 0) { |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 56 | tprints(", "); |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 57 | printflags(open_mode_flags, tcp->u_arg[flags_arg], "O_???"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 58 | } |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 59 | |
| 60 | return RVAL_DECODED | RVAL_FD; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 61 | } |
| 62 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 63 | SYS_FUNC(dup2) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 64 | { |
| 65 | return do_dup2(tcp, -1); |
| 66 | } |
| 67 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 68 | SYS_FUNC(dup3) |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 69 | { |
| 70 | return do_dup2(tcp, 2); |
| 71 | } |
Dmitry V. Levin | 4371b10 | 2008-11-10 22:53:02 +0000 | [diff] [blame] | 72 | |
Dmitry V. Levin | c2982b5 | 2013-11-05 23:00:22 +0000 | [diff] [blame] | 73 | static int |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 74 | decode_select(struct tcb *const tcp, const kernel_ulong_t *const args, |
| 75 | void (*const print_tv_ts) (struct tcb *, kernel_ulong_t), |
| 76 | const char * (*const sprint_tv_ts) (struct tcb *, kernel_ulong_t)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 77 | { |
Denys Vlasenko | ad5155a | 2011-09-01 18:18:04 +0200 | [diff] [blame] | 78 | int i, j; |
Denys Vlasenko | 1f65c3c | 2013-11-05 16:20:16 +0100 | [diff] [blame] | 79 | int nfds, fdsize; |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 80 | fd_set *fds = NULL; |
Dmitry V. Levin | 30145dd | 2010-09-06 22:08:24 +0000 | [diff] [blame] | 81 | const char *sep; |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 82 | kernel_ulong_t addr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 83 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 84 | /* Kernel truncates args[0] to int, we do the same. */ |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 85 | nfds = (int) args[0]; |
| 86 | |
| 87 | /* Kernel rejects negative nfds, so we don't parse it either. */ |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 88 | if (nfds < 0) |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 89 | nfds = 0; |
Dmitry V. Levin | 6522f13 | 2014-09-09 22:42:12 +0000 | [diff] [blame] | 90 | |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 91 | /* Beware of select(2^31-1, NULL, NULL, NULL) and similar... */ |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 92 | if (nfds > 1024*1024) |
| 93 | nfds = 1024*1024; |
| 94 | |
| 95 | /* |
| 96 | * We had bugs a-la "while (j < args[0])" and "umoven(args[0])" below. |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 97 | * Instead of args[0], use nfds for fd count, fdsize for array lengths. |
| 98 | */ |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 99 | fdsize = (((nfds + 7) / 8) + current_wordsize-1) & -current_wordsize; |
Denys Vlasenko | 79a79ea | 2011-09-01 16:35:44 +0200 | [diff] [blame] | 100 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 101 | if (entering(tcp)) { |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 102 | tprintf("%d", (int) args[0]); |
| 103 | |
Dmitry V. Levin | 3e9d71f | 2015-05-25 20:41:02 +0000 | [diff] [blame] | 104 | if (verbose(tcp) && fdsize > 0) |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 105 | fds = malloc(fdsize); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 106 | for (i = 0; i < 3; i++) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 107 | addr = args[i+1]; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 108 | tprints(", "); |
Dmitry V. Levin | 2fc5d80 | 2015-01-28 01:26:04 +0000 | [diff] [blame] | 109 | if (!fds) { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 110 | printaddr(addr); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 111 | continue; |
| 112 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 113 | if (umoven_or_printaddr(tcp, addr, fdsize, fds)) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 114 | continue; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 115 | tprints("["); |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 116 | for (j = 0, sep = "";; j++) { |
| 117 | j = next_set_bit(fds, j, nfds); |
| 118 | if (j < 0) |
| 119 | break; |
| 120 | tprints(sep); |
| 121 | printfd(tcp, j); |
| 122 | sep = " "; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 123 | } |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 124 | tprints("]"); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 125 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 126 | free(fds); |
Denys Vlasenko | 60fe8c1 | 2011-09-01 10:00:28 +0200 | [diff] [blame] | 127 | tprints(", "); |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 128 | print_tv_ts(tcp, args[4]); |
Dmitry V. Levin | df0c18c | 2015-07-20 16:59:50 +0000 | [diff] [blame] | 129 | } else { |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 130 | static char outstr[1024]; |
| 131 | char *outptr; |
| 132 | #define end_outstr (outstr + sizeof(outstr)) |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 133 | int ready_fds; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 134 | |
| 135 | if (syserror(tcp)) |
| 136 | return 0; |
| 137 | |
Dr. David Alan Gilbert | 025f108 | 2013-11-05 11:54:51 +0100 | [diff] [blame] | 138 | ready_fds = tcp->u_rval; |
| 139 | if (ready_fds == 0) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 140 | tcp->auxstr = "Timeout"; |
| 141 | return RVAL_STR; |
| 142 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 143 | |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 144 | fds = malloc(fdsize); |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 145 | |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 146 | outptr = outstr; |
| 147 | sep = ""; |
Dmitry V. Levin | f3696b3 | 2013-11-05 22:46:43 +0000 | [diff] [blame] | 148 | for (i = 0; i < 3 && ready_fds > 0; i++) { |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 149 | int first = 1; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 150 | |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 151 | addr = args[i+1]; |
| 152 | if (!addr || !fds || umoven(tcp, addr, fdsize, fds) < 0) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 153 | continue; |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 154 | for (j = 0;; j++) { |
| 155 | j = next_set_bit(fds, j, nfds); |
| 156 | if (j < 0) |
| 157 | break; |
| 158 | /* +2 chars needed at the end: ']',NUL */ |
| 159 | if (outptr < end_outstr - (sizeof(", except [") + sizeof(int)*3 + 2)) { |
| 160 | if (first) { |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 161 | outptr = xappendstr(outstr, |
| 162 | outptr, |
| 163 | "%s%s [%u", |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 164 | sep, |
| 165 | i == 0 ? "in" : i == 1 ? "out" : "except", |
| 166 | j |
| 167 | ); |
| 168 | first = 0; |
| 169 | sep = ", "; |
Elliott Hughes | dc75b01 | 2017-07-05 13:54:44 -0700 | [diff] [blame] | 170 | } else { |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 171 | outptr = xappendstr(outstr, |
| 172 | outptr, |
| 173 | " %u", j); |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 174 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 175 | } |
Denys Vlasenko | b338f2d | 2013-11-09 20:40:31 +0100 | [diff] [blame] | 176 | if (--ready_fds == 0) |
| 177 | break; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 178 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 179 | if (outptr != outstr) |
| 180 | *outptr++ = ']'; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 181 | } |
Roland McGrath | e85aaa4 | 2005-02-06 01:55:12 +0000 | [diff] [blame] | 182 | free(fds); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 183 | /* This contains no useful information on SunOS. */ |
| 184 | if (args[4]) { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 185 | const char *str = sprint_tv_ts(tcp, args[4]); |
| 186 | if (outptr + sizeof("left ") + strlen(sep) + strlen(str) < end_outstr) { |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 187 | outptr = xappendstr(outstr, outptr, |
| 188 | "%sleft %s", sep, str); |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 189 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 190 | } |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 191 | *outptr = '\0'; |
Denys Vlasenko | 1161725 | 2011-09-01 11:27:37 +0200 | [diff] [blame] | 192 | tcp->auxstr = outstr; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 193 | return RVAL_STR; |
Denys Vlasenko | 2fb4db3 | 2011-08-31 12:26:03 +0200 | [diff] [blame] | 194 | #undef end_outstr |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 195 | } |
| 196 | return 0; |
| 197 | } |
| 198 | |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 199 | #if HAVE_ARCH_OLD_SELECT |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 200 | SYS_FUNC(oldselect) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 201 | { |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 202 | kernel_ulong_t *args = |
| 203 | fetch_indirect_syscall_args(tcp, tcp->u_arg[0], 5); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 204 | |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 205 | if (args) { |
| 206 | return decode_select(tcp, args, print_timeval, sprint_timeval); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 207 | } else { |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 208 | if (entering(tcp)) |
| 209 | printaddr(tcp->u_arg[0]); |
| 210 | return RVAL_DECODED; |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 211 | } |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 212 | } |
Elliott Hughes | b755614 | 2018-02-20 17:03:16 -0800 | [diff] [blame] | 213 | #endif /* HAVE_ARCH_OLD_SELECT */ |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 214 | |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 215 | #ifdef ALPHA |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 216 | SYS_FUNC(osf_select) |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 217 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 218 | return decode_select(tcp, tcp->u_arg, print_timeval32, sprint_timeval32); |
Wichert Akkerman | f5eeabb | 1999-11-18 17:09:47 +0000 | [diff] [blame] | 219 | } |
| 220 | #endif |
| 221 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 222 | SYS_FUNC(select) |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 223 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 224 | return decode_select(tcp, tcp->u_arg, print_timeval, sprint_timeval); |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 225 | } |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 226 | |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 227 | static int |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 228 | umove_kulong_array_or_printaddr(struct tcb *const tcp, const kernel_ulong_t addr, |
| 229 | kernel_ulong_t *const ptr, const size_t n) |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 230 | { |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 231 | #ifndef current_klongsize |
| 232 | if (current_klongsize < sizeof(*ptr)) { |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 233 | uint32_t ptr32[n]; |
| 234 | int r = umove_or_printaddr(tcp, addr, &ptr32); |
| 235 | if (!r) { |
| 236 | size_t i; |
| 237 | |
| 238 | for (i = 0; i < n; ++i) |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 239 | ptr[i] = ptr32[i]; |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 240 | } |
| 241 | return r; |
| 242 | } |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 243 | #endif /* !current_klongsize */ |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 244 | return umoven_or_printaddr(tcp, addr, n * sizeof(*ptr), ptr); |
| 245 | } |
| 246 | |
Dmitry V. Levin | a0bd374 | 2015-04-07 01:36:50 +0000 | [diff] [blame] | 247 | SYS_FUNC(pselect6) |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 248 | { |
Dmitry V. Levin | 4cb5ccc | 2015-09-18 18:02:50 +0000 | [diff] [blame] | 249 | int rc = decode_select(tcp, tcp->u_arg, print_timespec, sprint_timespec); |
Roland McGrath | fe10aa7 | 2007-11-01 21:52:20 +0000 | [diff] [blame] | 250 | if (entering(tcp)) { |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 251 | kernel_ulong_t data[2]; |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 252 | |
| 253 | tprints(", "); |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 254 | if (!umove_kulong_array_or_printaddr(tcp, tcp->u_arg[5], |
| 255 | data, ARRAY_SIZE(data))) { |
Dmitry V. Levin | e6019fd | 2015-07-20 16:44:51 +0000 | [diff] [blame] | 256 | tprints("{"); |
Elliott Hughes | d35df49 | 2017-02-15 15:19:05 -0800 | [diff] [blame] | 257 | /* NB: kernel requires data[1] == NSIG_BYTES */ |
| 258 | print_sigset_addr_len(tcp, data[0], data[1]); |
| 259 | tprintf(", %" PRI_klu "}", data[1]); |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 260 | } |
| 261 | } |
Dmitry V. Levin | 4408e85 | 2015-11-27 04:37:46 +0000 | [diff] [blame] | 262 | |
Dmitry V. Levin | 95ebf5a | 2006-10-13 20:25:12 +0000 | [diff] [blame] | 263 | return rc; |
| 264 | } |