// https://syzkaller.appspot.com/bug?id=92fd199c9854486a9ae4546b8ee8fc7cebf3883b // autogenerated by syzkaller (https://github.com/google/syzkaller) #define _GNU_SOURCE #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #ifndef __NR_memfd_create #define __NR_memfd_create 319 #endif static unsigned long long procid; static bool write_file(const char* file, const char* what, ...) { char buf[1024]; va_list args; va_start(args, what); vsnprintf(buf, sizeof(buf), what, args); va_end(args); buf[sizeof(buf) - 1] = 0; int len = strlen(buf); int fd = open(file, O_WRONLY | O_CLOEXEC); if (fd == -1) return false; if (write(fd, buf, len) != len) { int err = errno; close(fd); errno = err; return false; } close(fd); return true; } #define BTPROTO_HCI 1 #define ACL_LINK 1 #define SCAN_PAGE 2 typedef struct { uint8_t b[6]; } __attribute__((packed)) bdaddr_t; #define HCI_COMMAND_PKT 1 #define HCI_EVENT_PKT 4 #define HCI_VENDOR_PKT 0xff struct hci_command_hdr { uint16_t opcode; uint8_t plen; } __attribute__((packed)); struct hci_event_hdr { uint8_t evt; uint8_t plen; } __attribute__((packed)); #define HCI_EV_CONN_COMPLETE 0x03 struct hci_ev_conn_complete { uint8_t status; uint16_t handle; bdaddr_t bdaddr; uint8_t link_type; uint8_t encr_mode; } __attribute__((packed)); #define HCI_EV_CONN_REQUEST 0x04 struct hci_ev_conn_request { bdaddr_t bdaddr; uint8_t dev_class[3]; uint8_t link_type; } __attribute__((packed)); #define HCI_EV_REMOTE_FEATURES 0x0b struct hci_ev_remote_features { uint8_t status; uint16_t handle; uint8_t features[8]; } __attribute__((packed)); #define HCI_EV_CMD_COMPLETE 0x0e struct hci_ev_cmd_complete { uint8_t ncmd; uint16_t opcode; } __attribute__((packed)); #define HCI_OP_WRITE_SCAN_ENABLE 0x0c1a #define HCI_OP_READ_BUFFER_SIZE 0x1005 struct hci_rp_read_buffer_size { uint8_t status; uint16_t acl_mtu; uint8_t sco_mtu; uint16_t acl_max_pkt; uint16_t sco_max_pkt; } __attribute__((packed)); #define HCI_OP_READ_BD_ADDR 0x1009 struct hci_rp_read_bd_addr { uint8_t status; bdaddr_t bdaddr; } __attribute__((packed)); #define HCI_EV_LE_META 0x3e struct hci_ev_le_meta { uint8_t subevent; } __attribute__((packed)); #define HCI_EV_LE_CONN_COMPLETE 0x01 struct hci_ev_le_conn_complete { uint8_t status; uint16_t handle; uint8_t role; uint8_t bdaddr_type; bdaddr_t bdaddr; uint16_t interval; uint16_t latency; uint16_t supervision_timeout; uint8_t clk_accurancy; } __attribute__((packed)); struct hci_dev_req { uint16_t dev_id; uint32_t dev_opt; }; struct vhci_vendor_pkt_request { uint8_t type; uint8_t opcode; } __attribute__((packed)); struct vhci_pkt { uint8_t type; union { struct { uint8_t opcode; uint16_t id; } __attribute__((packed)) vendor_pkt; struct hci_command_hdr command_hdr; }; } __attribute__((packed)); #define HCIDEVUP _IOW('H', 201, int) #define HCISETSCAN _IOW('H', 221, int) static int vhci_fd = -1; static void rfkill_unblock_all() { int fd = open("/dev/rfkill", O_WRONLY); if (fd < 0) exit(1); struct rfkill_event event = {0}; event.idx = 0; event.type = RFKILL_TYPE_ALL; event.op = RFKILL_OP_CHANGE_ALL; event.soft = 0; event.hard = 0; if (write(fd, &event, sizeof(event)) < 0) exit(1); close(fd); } static void hci_send_event_packet(int fd, uint8_t evt, void* data, size_t data_len) { struct iovec iv[3]; struct hci_event_hdr hdr; hdr.evt = evt; hdr.plen = data_len; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = data; iv[2].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static void hci_send_event_cmd_complete(int fd, uint16_t opcode, void* data, size_t data_len) { struct iovec iv[4]; struct hci_event_hdr hdr; hdr.evt = HCI_EV_CMD_COMPLETE; hdr.plen = sizeof(struct hci_ev_cmd_complete) + data_len; struct hci_ev_cmd_complete evt_hdr; evt_hdr.ncmd = 1; evt_hdr.opcode = opcode; uint8_t type = HCI_EVENT_PKT; iv[0].iov_base = &type; iv[0].iov_len = sizeof(type); iv[1].iov_base = &hdr; iv[1].iov_len = sizeof(hdr); iv[2].iov_base = &evt_hdr; iv[2].iov_len = sizeof(evt_hdr); iv[3].iov_base = data; iv[3].iov_len = data_len; if (writev(fd, iv, sizeof(iv) / sizeof(struct iovec)) < 0) exit(1); } static bool process_command_pkt(int fd, char* buf, ssize_t buf_size) { struct hci_command_hdr* hdr = (struct hci_command_hdr*)buf; if (buf_size < (ssize_t)sizeof(struct hci_command_hdr) || hdr->plen != buf_size - sizeof(struct hci_command_hdr)) exit(1); switch (hdr->opcode) { case HCI_OP_WRITE_SCAN_ENABLE: { uint8_t status = 0; hci_send_event_cmd_complete(fd, hdr->opcode, &status, sizeof(status)); return true; } case HCI_OP_READ_BD_ADDR: { struct hci_rp_read_bd_addr rp = {0}; rp.status = 0; memset(&rp.bdaddr, 0xaa, 6); hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } case HCI_OP_READ_BUFFER_SIZE: { struct hci_rp_read_buffer_size rp = {0}; rp.status = 0; rp.acl_mtu = 1021; rp.sco_mtu = 96; rp.acl_max_pkt = 4; rp.sco_max_pkt = 6; hci_send_event_cmd_complete(fd, hdr->opcode, &rp, sizeof(rp)); return false; } } char dummy[0xf9] = {0}; hci_send_event_cmd_complete(fd, hdr->opcode, dummy, sizeof(dummy)); return false; } static void* event_thread(void* arg) { while (1) { char buf[1024] = {0}; ssize_t buf_size = read(vhci_fd, buf, sizeof(buf)); if (buf_size < 0) exit(1); if (buf_size > 0 && buf[0] == HCI_COMMAND_PKT) { if (process_command_pkt(vhci_fd, buf + 1, buf_size - 1)) break; } } return NULL; } #define HCI_HANDLE_1 200 #define HCI_HANDLE_2 201 #define HCI_PRIMARY 0 #define HCI_OP_RESET 0x0c03 static void initialize_vhci() { int hci_sock = socket(AF_BLUETOOTH, SOCK_RAW, BTPROTO_HCI); if (hci_sock < 0) exit(1); vhci_fd = open("/dev/vhci", O_RDWR); if (vhci_fd == -1) exit(1); const int kVhciFd = 202; if (dup2(vhci_fd, kVhciFd) < 0) exit(1); close(vhci_fd); vhci_fd = kVhciFd; struct vhci_vendor_pkt_request vendor_pkt_req = {HCI_VENDOR_PKT, HCI_PRIMARY}; if (write(vhci_fd, &vendor_pkt_req, sizeof(vendor_pkt_req)) != sizeof(vendor_pkt_req)) exit(1); struct vhci_pkt vhci_pkt; if (read(vhci_fd, &vhci_pkt, sizeof(vhci_pkt)) != sizeof(vhci_pkt)) exit(1); if (vhci_pkt.type == HCI_COMMAND_PKT && vhci_pkt.command_hdr.opcode == HCI_OP_RESET) { char response[1] = {0}; hci_send_event_cmd_complete(vhci_fd, HCI_OP_RESET, response, sizeof(response)); if (read(vhci_fd, &vhci_pkt, sizeof(vhci_pkt)) != sizeof(vhci_pkt)) exit(1); } if (vhci_pkt.type != HCI_VENDOR_PKT) exit(1); int dev_id = vhci_pkt.vendor_pkt.id; pthread_t th; if (pthread_create(&th, NULL, event_thread, NULL)) exit(1); int ret = ioctl(hci_sock, HCIDEVUP, dev_id); if (ret) { if (errno == ERFKILL) { rfkill_unblock_all(); ret = ioctl(hci_sock, HCIDEVUP, dev_id); } if (ret && errno != EALREADY) exit(1); } struct hci_dev_req dr = {0}; dr.dev_id = dev_id; dr.dev_opt = SCAN_PAGE; if (ioctl(hci_sock, HCISETSCAN, &dr)) exit(1); struct hci_ev_conn_request request; memset(&request, 0, sizeof(request)); memset(&request.bdaddr, 0xaa, 6); *(uint8_t*)&request.bdaddr.b[5] = 0x10; request.link_type = ACL_LINK; hci_send_event_packet(vhci_fd, HCI_EV_CONN_REQUEST, &request, sizeof(request)); struct hci_ev_conn_complete complete; memset(&complete, 0, sizeof(complete)); complete.status = 0; complete.handle = HCI_HANDLE_1; memset(&complete.bdaddr, 0xaa, 6); *(uint8_t*)&complete.bdaddr.b[5] = 0x10; complete.link_type = ACL_LINK; complete.encr_mode = 0; hci_send_event_packet(vhci_fd, HCI_EV_CONN_COMPLETE, &complete, sizeof(complete)); struct hci_ev_remote_features features; memset(&features, 0, sizeof(features)); features.status = 0; features.handle = HCI_HANDLE_1; hci_send_event_packet(vhci_fd, HCI_EV_REMOTE_FEATURES, &features, sizeof(features)); struct { struct hci_ev_le_meta le_meta; struct hci_ev_le_conn_complete le_conn; } le_conn; memset(&le_conn, 0, sizeof(le_conn)); le_conn.le_meta.subevent = HCI_EV_LE_CONN_COMPLETE; memset(&le_conn.le_conn.bdaddr, 0xaa, 6); *(uint8_t*)&le_conn.le_conn.bdaddr.b[5] = 0x11; le_conn.le_conn.role = 1; le_conn.le_conn.handle = HCI_HANDLE_2; hci_send_event_packet(vhci_fd, HCI_EV_LE_META, &le_conn, sizeof(le_conn)); pthread_join(th, NULL); close(hci_sock); } //% This code is derived from puff.{c,h}, found in the zlib development. The //% original files come with the following copyright notice: //% Copyright (C) 2002-2013 Mark Adler, all rights reserved //% version 2.3, 21 Jan 2013 //% This software is provided 'as-is', without any express or implied //% warranty. In no event will the author be held liable for any damages //% arising from the use of this software. //% Permission is granted to anyone to use this software for any purpose, //% including commercial applications, and to alter it and redistribute it //% freely, subject to the following restrictions: //% 1. The origin of this software must not be misrepresented; you must not //% claim that you wrote the original software. If you use this software //% in a product, an acknowledgment in the product documentation would be //% appreciated but is not required. //% 2. Altered source versions must be plainly marked as such, and must not be //% misrepresented as being the original software. //% 3. This notice may not be removed or altered from any source distribution. //% Mark Adler madler@alumni.caltech.edu //% BEGIN CODE DERIVED FROM puff.{c,h} #define MAXBITS 15 #define MAXLCODES 286 #define MAXDCODES 30 #define MAXCODES (MAXLCODES + MAXDCODES) #define FIXLCODES 288 struct puff_state { unsigned char* out; unsigned long outlen; unsigned long outcnt; const unsigned char* in; unsigned long inlen; unsigned long incnt; int bitbuf; int bitcnt; jmp_buf env; }; static int puff_bits(struct puff_state* s, int need) { long val = s->bitbuf; while (s->bitcnt < need) { if (s->incnt == s->inlen) longjmp(s->env, 1); val |= (long)(s->in[s->incnt++]) << s->bitcnt; s->bitcnt += 8; } s->bitbuf = (int)(val >> need); s->bitcnt -= need; return (int)(val & ((1L << need) - 1)); } static int puff_stored(struct puff_state* s) { s->bitbuf = 0; s->bitcnt = 0; if (s->incnt + 4 > s->inlen) return 2; unsigned len = s->in[s->incnt++]; len |= s->in[s->incnt++] << 8; if (s->in[s->incnt++] != (~len & 0xff) || s->in[s->incnt++] != ((~len >> 8) & 0xff)) return -2; if (s->incnt + len > s->inlen) return 2; if (s->outcnt + len > s->outlen) return 1; for (; len--; s->outcnt++, s->incnt++) { if (s->in[s->incnt]) s->out[s->outcnt] = s->in[s->incnt]; } return 0; } struct puff_huffman { short* count; short* symbol; }; static int puff_decode(struct puff_state* s, const struct puff_huffman* h) { int first = 0; int index = 0; int bitbuf = s->bitbuf; int left = s->bitcnt; int code = first = index = 0; int len = 1; short* next = h->count + 1; while (1) { while (left--) { code |= bitbuf & 1; bitbuf >>= 1; int count = *next++; if (code - count < first) { s->bitbuf = bitbuf; s->bitcnt = (s->bitcnt - len) & 7; return h->symbol[index + (code - first)]; } index += count; first += count; first <<= 1; code <<= 1; len++; } left = (MAXBITS + 1) - len; if (left == 0) break; if (s->incnt == s->inlen) longjmp(s->env, 1); bitbuf = s->in[s->incnt++]; if (left > 8) left = 8; } return -10; } static int puff_construct(struct puff_huffman* h, const short* length, int n) { int len; for (len = 0; len <= MAXBITS; len++) h->count[len] = 0; int symbol; for (symbol = 0; symbol < n; symbol++) (h->count[length[symbol]])++; if (h->count[0] == n) return 0; int left = 1; for (len = 1; len <= MAXBITS; len++) { left <<= 1; left -= h->count[len]; if (left < 0) return left; } short offs[MAXBITS + 1]; offs[1] = 0; for (len = 1; len < MAXBITS; len++) offs[len + 1] = offs[len] + h->count[len]; for (symbol = 0; symbol < n; symbol++) if (length[symbol] != 0) h->symbol[offs[length[symbol]]++] = symbol; return left; } static int puff_codes(struct puff_state* s, const struct puff_huffman* lencode, const struct puff_huffman* distcode) { static const short lens[29] = {3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258}; static const short lext[29] = {0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0}; static const short dists[30] = { 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577}; static const short dext[30] = {0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13}; int symbol; do { symbol = puff_decode(s, lencode); if (symbol < 0) return symbol; if (symbol < 256) { if (s->outcnt == s->outlen) return 1; if (symbol) s->out[s->outcnt] = symbol; s->outcnt++; } else if (symbol > 256) { symbol -= 257; if (symbol >= 29) return -10; int len = lens[symbol] + puff_bits(s, lext[symbol]); symbol = puff_decode(s, distcode); if (symbol < 0) return symbol; unsigned dist = dists[symbol] + puff_bits(s, dext[symbol]); if (dist > s->outcnt) return -11; if (s->outcnt + len > s->outlen) return 1; while (len--) { if (dist <= s->outcnt && s->out[s->outcnt - dist]) s->out[s->outcnt] = s->out[s->outcnt - dist]; s->outcnt++; } } } while (symbol != 256); return 0; } static int puff_fixed(struct puff_state* s) { static int virgin = 1; static short lencnt[MAXBITS + 1], lensym[FIXLCODES]; static short distcnt[MAXBITS + 1], distsym[MAXDCODES]; static struct puff_huffman lencode, distcode; if (virgin) { lencode.count = lencnt; lencode.symbol = lensym; distcode.count = distcnt; distcode.symbol = distsym; short lengths[FIXLCODES]; int symbol; for (symbol = 0; symbol < 144; symbol++) lengths[symbol] = 8; for (; symbol < 256; symbol++) lengths[symbol] = 9; for (; symbol < 280; symbol++) lengths[symbol] = 7; for (; symbol < FIXLCODES; symbol++) lengths[symbol] = 8; puff_construct(&lencode, lengths, FIXLCODES); for (symbol = 0; symbol < MAXDCODES; symbol++) lengths[symbol] = 5; puff_construct(&distcode, lengths, MAXDCODES); virgin = 0; } return puff_codes(s, &lencode, &distcode); } static int puff_dynamic(struct puff_state* s) { static const short order[19] = {16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15}; int nlen = puff_bits(s, 5) + 257; int ndist = puff_bits(s, 5) + 1; int ncode = puff_bits(s, 4) + 4; if (nlen > MAXLCODES || ndist > MAXDCODES) return -3; short lengths[MAXCODES]; int index; for (index = 0; index < ncode; index++) lengths[order[index]] = puff_bits(s, 3); for (; index < 19; index++) lengths[order[index]] = 0; short lencnt[MAXBITS + 1], lensym[MAXLCODES]; struct puff_huffman lencode = {lencnt, lensym}; int err = puff_construct(&lencode, lengths, 19); if (err != 0) return -4; index = 0; while (index < nlen + ndist) { int symbol; int len; symbol = puff_decode(s, &lencode); if (symbol < 0) return symbol; if (symbol < 16) lengths[index++] = symbol; else { len = 0; if (symbol == 16) { if (index == 0) return -5; len = lengths[index - 1]; symbol = 3 + puff_bits(s, 2); } else if (symbol == 17) symbol = 3 + puff_bits(s, 3); else symbol = 11 + puff_bits(s, 7); if (index + symbol > nlen + ndist) return -6; while (symbol--) lengths[index++] = len; } } if (lengths[256] == 0) return -9; err = puff_construct(&lencode, lengths, nlen); if (err && (err < 0 || nlen != lencode.count[0] + lencode.count[1])) return -7; short distcnt[MAXBITS + 1], distsym[MAXDCODES]; struct puff_huffman distcode = {distcnt, distsym}; err = puff_construct(&distcode, lengths + nlen, ndist); if (err && (err < 0 || ndist != distcode.count[0] + distcode.count[1])) return -8; return puff_codes(s, &lencode, &distcode); } static int puff(unsigned char* dest, unsigned long* destlen, const unsigned char* source, unsigned long sourcelen) { struct puff_state s = { .out = dest, .outlen = *destlen, .outcnt = 0, .in = source, .inlen = sourcelen, .incnt = 0, .bitbuf = 0, .bitcnt = 0, }; int err; if (setjmp(s.env) != 0) err = 2; else { int last; do { last = puff_bits(&s, 1); int type = puff_bits(&s, 2); err = type == 0 ? puff_stored(&s) : (type == 1 ? puff_fixed(&s) : (type == 2 ? puff_dynamic(&s) : -1)); if (err != 0) break; } while (!last); } *destlen = s.outcnt; return err; } //% END CODE DERIVED FROM puff.{c,h} #define ZLIB_HEADER_WIDTH 2 static int puff_zlib_to_file(const unsigned char* source, unsigned long sourcelen, int dest_fd) { if (sourcelen < ZLIB_HEADER_WIDTH) return 0; source += ZLIB_HEADER_WIDTH; sourcelen -= ZLIB_HEADER_WIDTH; const unsigned long max_destlen = 132 << 20; void* ret = mmap(0, max_destlen, PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANON, -1, 0); if (ret == MAP_FAILED) return -1; unsigned char* dest = (unsigned char*)ret; unsigned long destlen = max_destlen; int err = puff(dest, &destlen, source, sourcelen); if (err) { munmap(dest, max_destlen); errno = -err; return -1; } if (write(dest_fd, dest, destlen) != (ssize_t)destlen) { munmap(dest, max_destlen); return -1; } return munmap(dest, max_destlen); } static int setup_loop_device(unsigned char* data, unsigned long size, const char* loopname, int* loopfd_p) { int err = 0, loopfd = -1; int memfd = syscall(__NR_memfd_create, "syzkaller", 0); if (memfd == -1) { err = errno; goto error; } if (puff_zlib_to_file(data, size, memfd)) { err = errno; goto error_close_memfd; } loopfd = open(loopname, O_RDWR); if (loopfd == -1) { err = errno; goto error_close_memfd; } if (ioctl(loopfd, LOOP_SET_FD, memfd)) { if (errno != EBUSY) { err = errno; goto error_close_loop; } ioctl(loopfd, LOOP_CLR_FD, 0); usleep(1000); if (ioctl(loopfd, LOOP_SET_FD, memfd)) { err = errno; goto error_close_loop; } } close(memfd); *loopfd_p = loopfd; return 0; error_close_loop: close(loopfd); error_close_memfd: close(memfd); error: errno = err; return -1; } static long syz_mount_image(volatile long fsarg, volatile long dir, volatile long flags, volatile long optsarg, volatile long change_dir, volatile unsigned long size, volatile long image) { unsigned char* data = (unsigned char*)image; int res = -1, err = 0, loopfd = -1, need_loop_device = !!size; char* mount_opts = (char*)optsarg; char* target = (char*)dir; char* fs = (char*)fsarg; char* source = NULL; char loopname[64]; if (need_loop_device) { memset(loopname, 0, sizeof(loopname)); snprintf(loopname, sizeof(loopname), "/dev/loop%llu", procid); if (setup_loop_device(data, size, loopname, &loopfd) == -1) return -1; source = loopname; } mkdir(target, 0777); char opts[256]; memset(opts, 0, sizeof(opts)); if (strlen(mount_opts) > (sizeof(opts) - 32)) { } strncpy(opts, mount_opts, sizeof(opts) - 32); if (strcmp(fs, "iso9660") == 0) { flags |= MS_RDONLY; } else if (strncmp(fs, "ext", 3) == 0) { bool has_remount_ro = false; char* remount_ro_start = strstr(opts, "errors=remount-ro"); if (remount_ro_start != NULL) { char after = *(remount_ro_start + strlen("errors=remount-ro")); char before = remount_ro_start == opts ? '\0' : *(remount_ro_start - 1); has_remount_ro = ((before == '\0' || before == ',') && (after == '\0' || after == ',')); } if (strstr(opts, "errors=panic") || !has_remount_ro) strcat(opts, ",errors=continue"); } else if (strcmp(fs, "xfs") == 0) { strcat(opts, ",nouuid"); } res = mount(source, target, fs, flags, opts); if (res == -1) { err = errno; goto error_clear_loop; } res = open(target, O_RDONLY | O_DIRECTORY); if (res == -1) { err = errno; goto error_clear_loop; } if (change_dir) { res = chdir(target); if (res == -1) { err = errno; } } error_clear_loop: if (need_loop_device) { ioctl(loopfd, LOOP_CLR_FD, 0); close(loopfd); } errno = err; return res; } static void setup_common() { if (mount(0, "/sys/fs/fuse/connections", "fusectl", 0, 0)) { } } static void setup_binderfs() { if (mkdir("/dev/binderfs", 0777)) { } if (mount("binder", "/dev/binderfs", "binder", 0, NULL)) { } if (symlink("/dev/binderfs", "./binderfs")) { } } static void loop(); static void sandbox_common() { prctl(PR_SET_PDEATHSIG, SIGKILL, 0, 0, 0); setsid(); struct rlimit rlim; rlim.rlim_cur = rlim.rlim_max = (200 << 20); setrlimit(RLIMIT_AS, &rlim); rlim.rlim_cur = rlim.rlim_max = 32 << 20; setrlimit(RLIMIT_MEMLOCK, &rlim); rlim.rlim_cur = rlim.rlim_max = 136 << 20; setrlimit(RLIMIT_FSIZE, &rlim); rlim.rlim_cur = rlim.rlim_max = 1 << 20; setrlimit(RLIMIT_STACK, &rlim); rlim.rlim_cur = rlim.rlim_max = 128 << 20; setrlimit(RLIMIT_CORE, &rlim); rlim.rlim_cur = rlim.rlim_max = 256; setrlimit(RLIMIT_NOFILE, &rlim); if (unshare(CLONE_NEWNS)) { } if (mount(NULL, "/", NULL, MS_REC | MS_PRIVATE, NULL)) { } if (unshare(CLONE_NEWIPC)) { } if (unshare(0x02000000)) { } if (unshare(CLONE_NEWUTS)) { } if (unshare(CLONE_SYSVSEM)) { } typedef struct { const char* name; const char* value; } sysctl_t; static const sysctl_t sysctls[] = { {"/proc/sys/kernel/shmmax", "16777216"}, {"/proc/sys/kernel/shmall", "536870912"}, {"/proc/sys/kernel/shmmni", "1024"}, {"/proc/sys/kernel/msgmax", "8192"}, {"/proc/sys/kernel/msgmni", "1024"}, {"/proc/sys/kernel/msgmnb", "1024"}, {"/proc/sys/kernel/sem", "1024 1048576 500 1024"}, }; unsigned i; for (i = 0; i < sizeof(sysctls) / sizeof(sysctls[0]); i++) write_file(sysctls[i].name, sysctls[i].value); } static int wait_for_loop(int pid) { if (pid < 0) exit(1); int status = 0; while (waitpid(-1, &status, __WALL) != pid) { } return WEXITSTATUS(status); } static void drop_caps(void) { struct __user_cap_header_struct cap_hdr = {}; struct __user_cap_data_struct cap_data[2] = {}; cap_hdr.version = _LINUX_CAPABILITY_VERSION_3; cap_hdr.pid = getpid(); if (syscall(SYS_capget, &cap_hdr, &cap_data)) exit(1); const int drop = (1 << CAP_SYS_PTRACE) | (1 << CAP_SYS_NICE); cap_data[0].effective &= ~drop; cap_data[0].permitted &= ~drop; cap_data[0].inheritable &= ~drop; if (syscall(SYS_capset, &cap_hdr, &cap_data)) exit(1); } static int do_sandbox_none(void) { if (unshare(CLONE_NEWPID)) { } int pid = fork(); if (pid != 0) return wait_for_loop(pid); setup_common(); initialize_vhci(); sandbox_common(); drop_caps(); if (unshare(CLONE_NEWNET)) { } write_file("/proc/sys/net/ipv4/ping_group_range", "0 65535"); setup_binderfs(); loop(); exit(1); } void loop(void) { memcpy((void*)0x200000c0, "udf\000", 4); memcpy((void*)0x20000100, "\023\023w\305\3745\324\024T\325\324\035)\255\032`)" "Y\201F\346\276\026nA\255\r\275@T\003<\2373\273\332\202$" "\242\363\327r\347cnH\263<\277p\203r\350\361\271\223>" "\305\022wC\276\"\006 \236\360-\371\313\362\366\350\200\3238/\000", 78); *(uint32_t*)0x20000240 = 0; sprintf((char*)0x20000244, "%023llo", (long long)-1); *(uint32_t*)0x2000025b = 0; sprintf((char*)0x2000025f, "%020llu", (long long)0); *(uint8_t*)0x20000273 = 0; *(uint16_t*)0x20000274 = -1; sprintf((char*)0x20000276, "%020llu", (long long)0); *(uint32_t*)0x2000028a = -1; memcpy( (void*)0x20000480, "\x78\x9c\xec\xdd\x5f\x6c\x5d\xf7\x5d\x00\xf0\xef\xef\xc4\x8e\x9d\x16\x6d" "\x97\xae\x49\xbb\x51\x4d\xb7\x9d\xe8\x42\xc6\x82\xed\x2c\x4d\x2b\x4f\xa2" "\xa1\xc6\x30\x96\xb5\xa6\x8e\x37\xa0\x3c\xf4\x26\x76\xc2\x25\x8e\x7d\x65" "\x3b\x5d\x52\xc1\x56\xc4\x43\x1f\x40\xc2\x0c\x89\x17\x86\x04\x42\x43\x15" "\x0f\x93\x79\x18\x12\x3c\x0d\x09\x09\x21\x21\x61\xa1\x49\x08\x10\x52\xe8" "\xb6\x52\x84\x90\xee\xc3\xaa\xbe\xa0\x1a\x9d\x73\x7f\xd7\xbe\x76\xdc\xc6" "\xab\xe3\x38\x49\x3f\x1f\x29\xf9\x9e\x7b\xce\xf7\x77\xee\xef\xcf\xe9\x39" "\xe7\xde\xdf\x3d\x4d\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x11\x3f\xf3\xb3\xa7\x87\x86\xd3\x7e\xd7\x02\x00\xb8\x9d\x9e\x9d\x7c" "\x7e\x68\xc4\xf5\x1f\x00\x3e\x50\xce\xfa\xfc\x0f\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x77\xba\x14\x45\xbc\x19\x29\xbe\xfc\x48\x3b\xbd\x58" "\xbd\xee\x18\x3c\xd3\x9c\xbb\x72\x75\x6a\x6c\x7c\xfb\x62\x87\x52\x55\xf2" "\x40\x95\x5f\xfe\x19\x1c\x1e\x39\xf1\x99\x93\x4f\x9c\x7a\xb2\x1b\xdf\xbb" "\xfc\xad\xf6\xd1\x78\x6e\xf2\xec\xe9\xfa\x33\xf3\x97\x5b\x0b\x33\x8b\x8b" "\x33\xd3\xf5\xa9\xb9\xe6\xf9\xf9\xe9\x99\x1d\xef\x61\xb7\xe5\xb7\x3a\x56" "\x75\x40\xfd\xf2\xa5\x2b\xd3\x17\x2e\x2c\xd6\x47\x8e\x9f\xd8\xb4\xf9\x6a" "\xed\x8d\x81\xfb\x8f\xd4\x46\x4f\x0d\xbf\x70\xb8\x9b\x3b\x35\x36\x3e\x3e" "\xd9\x93\xd3\xd7\xff\xbe\xdf\x7d\x93\x7f\x5a\xde\x18\xd7\xad\x0e\x46\x11" "\x17\x22\xc5\xa5\xd7\xde\x4c\x8d\x88\x28\x62\x9b\xbe\xf8\x6e\xed\x87\xea" "\x8b\x9b\x1c\x3b\x7b\xed\x50\xd5\x88\x63\x55\x23\xa6\xc6\xc6\xab\x86\xcc" "\x36\x1b\x73\x4b\xe5\xc6\x89\x6e\x47\x14\x11\xb5\x9e\x42\x4f\x77\x8f\xfd" "\x3d\x1e\x8b\x5d\xab\x47\xbc\x52\x56\xbf\xac\xf0\xb1\xb2\x79\x93\xad\xc6" "\x42\xe3\xdc\xec\x4c\x7d\xa2\xb1\xb0\xd4\x5c\x6a\xce\xcf\x4d\xa4\x4e\x6d" "\x53\x95\x5e\xc4\x93\x29\xa2\x15\x11\xed\x81\x1b\x77\xd7\x1f\x45\x7c\x25" "\x52\xbc\xfa\xf5\x76\x3a\x17\x11\x07\xba\xfd\xf0\xa9\xea\xc1\xe0\x9b\xd7" "\xa7\xd8\x83\x36\xee\x40\x5f\x44\xd4\xfa\x23\x56\x8b\xbb\x60\xcc\xee\x60" "\x03\x51\xc4\x37\x23\xc5\xd7\xbe\x3a\x14\xe7\x73\xbf\x56\xdd\xf6\x78\xc4" "\x17\xca\x78\x24\xe2\x4a\x19\xaf\x47\x2c\x97\xf1\xe3\x11\xa9\x3c\x40\x1e" "\x8c\x78\x6b\x9b\xe3\x89\xbb\x4b\x5f\x14\xf1\x3b\x91\xe2\x07\xa3\xed\x34" "\xdd\x1d\xfb\xea\xbc\x72\xe6\x8b\xf5\xcf\xcd\x5d\x98\xef\xc9\xed\x9e\x57" "\x76\x7b\xad\xdc\xf7\xeb\xc3\xed\x74\x87\x9f\x9b\x06\xa3\x88\x46\x75\xc6" "\x6f\xa7\xf7\x7f\xb3\x03\x00\x00\x00\x00\xc0\x9d\xa7\x88\xdf\x8f\x14\x8f" "\x7e\xe7\x68\x6a\x45\xef\x9c\x62\x73\xee\x62\xfd\x6c\xe3\xdc\x6c\xe7\x5b" "\xe1\xee\x77\xff\xf5\x5c\x6a\x6d\x6d\x6d\xad\x96\x3a\x71\x28\xc7\x89\x1c" "\x5b\x39\x2e\xe7\xb8\x92\xe3\x6a\x8e\xed\x1c\x6b\x45\x2e\x9f\xe3\x44\x8e" "\xad\x1c\x97\x73\x5c\x29\xe2\xc7\x4f\x96\xe5\xf3\xeb\x76\x8e\xb5\x03\xb9" "\x7c\x8e\x13\x39\xb6\x72\x5c\xce\x71\x25\xc7\xd5\x1c\xdb\x39\xd6\xfa\x72" "\xf9\x1c\x27\x72\x6c\xe5\xb8\x9c\xe3\x4a\x8e\xab\x39\xb6\xfb\xf6\x71\xb8" "\x00\x00\x00\x00\x00\x00\x00\x60\x1b\x87\xa2\x88\x2f\x45\x8a\xc7\x7f\xea" "\xa5\xea\xb9\xe2\xa8\x9e\x4b\xff\xf0\xe8\xa9\xe7\x8f\xff\x42\xef\x33\xe3" "\x0f\xdf\x64\x3f\x65\xee\xf1\x88\x58\x29\x76\xf6\x4c\xee\xc1\xfc\xe8\xf0" "\x44\x9a\x48\x69\x9f\x9e\x21\xa6\xf3\xfc\xdf\x6f\xe6\xe7\xff\x7e\x6b\xbf" "\x2b\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\xec\xab\x22\x8a\x78\x2c\x52\xbc" "\xf4\xad\x76\x8a\x14\x11\xf5\x88\x17\xa3\x13\xaf\x0f\xec\x77\xed\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x5b\x61\x30\x15\xf1\x56\xa4\xf8" "\xc3\xcf\x0f\x56\xaf\x57\x8b\x88\x5f\x89\x88\x77\xd6\xde\x59\x8b\x88\xeb" "\xef\xac\xed\xd2\xbf\xfd\xc3\x96\x15\xfb\xdd\x62\x00\x00\x00\x00\x00\x00" "\x00\xb8\x07\xa5\x22\xae\x45\x8a\xc7\x9e\x6f\xa7\x5a\x44\x5c\xad\xbd\x31" "\x70\xff\x91\xda\xe8\xa9\xe1\x17\x0e\x1f\x88\x03\x91\xca\x94\xde\xfc\xe7" "\x26\xcf\x9e\xae\x3f\x33\x7f\xb9\xb5\x30\xb3\xb8\x38\x33\x5d\x9f\x9a\x6b" "\x9e\x9f\x9f\x9e\xd9\xe9\xdb\x0d\x9e\x69\xce\x5d\xb9\x3a\x35\x36\xbe\x27" "\x8d\xb9\xa9\x43\x7b\x5c\xff\x43\x83\xcf\xcc\xb7\xae\x2d\x34\x2f\xfe\xda" "\xd2\xb6\xdb\xef\x1b\x3c\x7d\x6e\x71\x69\xa1\x71\x7e\xfb\xcd\x71\x28\x8a" "\x88\x7a\xef\x9a\x63\x55\x85\xa7\xc6\xc6\xab\x4a\xcf\x36\x1b\x73\x55\xd1" "\x89\xb4\xd3\x1a\x03\x00\x00\x00\x00\x00\x00\xf0\x41\xd0\x9f\x8a\x78\x27" "\x52\xbc\xfa\xe7\xaf\xad\xcf\x3b\xf7\x75\xe6\xfc\xfb\xb6\xe6\x7e\xe3\xb3" "\x11\x45\x5e\x1e\xcb\xf3\xcf\xeb\xd3\xd0\xd5\xef\x06\x3e\x54\xfd\x6e\xa0" "\xb3\xfc\xe1\xd1\x53\xbf\x38\xf2\xb1\xde\xe5\x6d\xa7\xac\x8f\x55\x13\xea" "\xf5\xa9\xb1\xf1\xf1\xc9\x9e\xd5\x7d\xfd\x37\xa6\x0e\xe6\xf7\x1d\xda\x5d" "\x93\xe9\x51\x8e\xff\x52\xa4\xf8\xdd\x3f\xae\xa7\x47\xf3\xba\xcd\xe3\x7f" "\x60\x3d\xf7\x1b\xbf\xb1\x31\xde\xaf\x6c\xdd\xd1\xbb\x8c\xf9\x6e\xc7\xff" "\x47\x7b\xd6\x95\xef\x99\x52\x11\x7f\x19\x29\x7e\xec\x97\x1e\x8e\x47\xab" "\x7a\xde\x17\x37\xfc\x66\x22\xe7\x7d\x3e\x52\xfc\xf2\xca\x23\x39\x2f\x0e" "\x96\x79\x8f\xe5\xed\x0f\x54\x7f\x0f\x5e\x68\xce\xce\x0c\x95\xb9\x57\x23" "\xc5\xdf\x5e\xd9\x9c\xfb\x78\xce\xfd\xc8\x46\xee\xf0\x8e\x3b\xf6\x2e\x51" "\x8e\xff\x63\x91\xe2\x7f\x7e\x75\x65\xbd\x6f\xf2\xf8\xe7\x11\xd8\x18\xb5" "\xde\xf1\xff\xd8\xd6\xa3\x63\x8f\xc6\xff\x81\x9e\x75\xb5\xfc\xbe\x9f\xb8" "\x35\x4d\x27\x22\x16\xaf\xbd\x7c\xa9\x31\x3b\x3b\xb3\x60\xc1\x82\x05\x0b" "\xeb\x0b\xef\x7d\xde\x38\x74\xbb\x4e\x50\xec\xa9\xf2\xfa\xff\xa5\x48\xf1" "\x37\x7f\xf0\xef\xeb\xf7\x3b\xf9\xfa\xff\x23\x9d\x57\x1b\xf7\x7f\x6f\x7f" "\x65\xe3\xfa\x3f\xba\x75\x47\x7b\x74\xfd\xff\x48\xcf\xba\xd1\x7c\x37\xd2" "\xdf\x17\x31\xb8\x74\xb9\xd5\xff\x50\xc4\xe0\xe2\xb5\x97\x3f\xdd\xbc\xdc" "\xb8\x38\x73\x71\x66\xee\xc4\xa9\xa7\x9e\x18\x19\x7a\x6a\x78\xe8\x44\xff" "\xc1\xee\xcd\xdd\xc6\xd2\xae\xfb\xea\x5e\x54\x8e\xff\xaf\x47\x8a\x6f\xbe" "\xfe\x17\xf1\xc9\xbc\x6e\xf3\xfd\xdf\xf6\xf7\xff\xf7\x6d\xdd\xd1\x1e\x8d" "\xff\x83\x3d\xeb\xee\xdb\x74\xbf\xb2\xeb\xa6\x93\xc7\xff\xff\x22\xc5\xdf" "\x8f\x7d\x3b\x8e\xe6\x75\xef\x75\xff\xdf\xfd\xfc\x7f\x34\xdf\x84\xaf\xdf" "\x9f\xef\xd1\xf8\x1f\xee\x59\x57\x7d\xc6\xfb\x50\xc4\x4f\xf4\xac\x3b\x7a" "\x38\xe2\x9e\xfb\x50\x06\x00\x00\x00\xb7\x58\x4a\x45\x7c\x3b\xcf\xa7\x0e" "\xdd\x64\x3e\xf5\xef\x22\xc5\xcb\xff\xfd\x93\x39\x2f\x1d\x29\xf3\x9e\xce" "\xdb\x6b\xd5\xdf\x83\xcf\xce\xcf\x7d\xfa\xf4\xec\xec\xfc\xf9\xc6\x52\xe3" "\xdc\xec\x4c\x7d\xb2\xd5\x38\x3f\x53\x96\xfd\x5e\xa4\x68\xff\xd9\x23\xb9" "\x6c\x51\xcd\xaf\x76\xe7\x9b\x3b\x73\xbc\x1b\x73\xb1\xff\x1c\x29\x9e\xfa" "\xf9\x6e\x6e\x67\x2e\xb6\xfb\xdd\xd4\x83\x1b\xb9\xc3\x65\xee\xf1\x48\xf1" "\x7b\xcf\x6e\xce\xed\x7e\x8f\x71\x78\x23\x77\xa4\xcc\xfd\x8f\x48\x31\xfc" "\xc2\xf6\xb9\x47\x36\x72\x4f\x94\xb9\xff\x15\x29\xde\xfe\xa3\x7a\x37\xf7" "\x4f\x7f\xfb\x1f\xbf\xff\x89\x85\xfa\xc9\x2a\xeb\xa1\x8d\xdc\xe3\xe7\xe7" "\x67\xa7\xf7\x64\x60\x00\x00\x00\x00\x00\x60\x17\xfa\x53\x11\x4f\x44\x8a" "\xbf\x3e\xd1\x97\x3e\x9b\xd7\xed\xe4\xf7\x9f\x37\x7c\xe9\xbd\x47\xbf\xff" "\x7b\xa8\x67\xdd\xf4\x6d\x7a\x5e\x65\xd7\x9d\x0a\x00\x77\xb8\xf2\xfa\x7f" "\xb4\xbc\xaa\xff\xf4\x9f\xac\xcf\xe5\x6f\xbe\xfe\x6f\xfc\x7f\x00\x7a\xaf" "\xff\x5b\xf5\xfe\xbb\x01\xef\xb6\xfc\x7e\xae\xff\xb5\x5b\xd3\x4c\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00" "\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\x0f" "\x9c\x14\x45\xcc\x47\x8a\x2f\x3f\xd2\x4e\xd7\x07\xca\xd7\x1d\x83\x67\x9a" "\x73\x57\xae\x4e\x8d\x8d\x6f\x5f\xec\x50\xaa\x4a\x1e\xa8\xf2\xcb\x3f\x83" "\xc3\x23\x27\x3e\x73\xf2\x89\x53\x4f\x76\xe3\x7b\x97\xbf\xd5\x3e\x1a\xcf" "\x4d\x9e\x3d\x5d\x7f\x66\xfe\x72\x6b\x61\x66\x71\x71\x66\xba\x3e\x35\xd7" "\x3c\x3f\x3f\x3d\xb3\xe3\x3d\xec\xb6\xfc\x56\xc7\xaa\x0e\xa8\x5f\xbe\x74" "\x65\xfa\xc2\x85\xc5\xfa\xc8\xf1\x13\x9b\x36\x5f\xad\xbd\x31\x70\xff\x91" "\xda\xe8\xa9\xe1\x17\x0e\x77\x73\xa7\xc6\xc6\xc7\x27\x7b\x72\xfa\xfa\xdf" "\xf7\xbb\xdf\x20\xbd\xcb\xfa\x83\x51\xc4\xff\x46\x8a\x4b\xaf\xbd\x99\xfe" "\x73\x20\xa2\x88\xdd\xf7\xc5\x4d\x8e\x9d\xbd\x76\xa8\x6a\xc4\xb1\xaa\x11" "\x53\x63\xe3\x55\x43\x66\x9b\x8d\xb9\xa5\x72\xe3\x44\xb7\x23\x8a\x88\x5a" "\x4f\xa1\xa7\xbb\x7d\x74\x1b\xc6\x62\x57\xea\x11\xaf\x94\xd5\x2f\x2b\x7c" "\xac\x6c\xde\x64\xab\xb1\xd0\x38\x37\x3b\x53\x9f\x68\x2c\x2c\x35\x97\x9a" "\xf3\x73\x13\xa9\x53\xdb\x54\xa5\x17\xf1\x64\x8a\x68\x45\x44\x7b\xe0\xc6" "\xdd\xf5\x47\x11\xfd\x91\xe2\xd5\xaf\xb7\xd3\xeb\x03\x11\x07\xba\xfd\xf0" "\xa9\x67\x27\x9f\x1f\x1a\xb9\x79\x7d\x8a\x3d\x68\xe3\x0e\xf4\x45\x44\xad" "\x3f\x62\xb5\xb8\x0b\xc6\xec\x0e\x36\x10\x45\x9c\x8c\x14\x5f\xfb\xea\x50" "\x7c\x77\xa0\xd3\xaf\x55\xb7\x3d\x1e\xf1\x85\x32\x1e\x89\xb8\x52\xc6\xeb" "\x11\xcb\x65\xfc\x78\x44\x2a\x0f\x90\x07\x23\xde\xda\xe6\x78\xe2\xee\xd2" "\x17\x45\x3c\x10\x29\x7e\x30\xda\x4e\xdf\x1b\xc8\x63\x5f\x9d\x57\xce\x7c" "\xb1\xfe\xb9\xb9\x0b\xf3\x3d\xb9\xdd\xf3\xca\x5d\x7f\x7d\xb8\x9d\xee\xf0" "\x73\xd3\x60\x14\xf1\x66\x75\xc6\x6f\xa7\xef\xfb\xef\x19\x00\x00\x00\x00" "\xe0\x1e\x52\xc4\xc3\x91\xe2\xd1\xef\x1c\x4d\xd5\xfc\xe0\xfa\x9c\x62\x73" "\xee\x62\xfd\x6c\xe3\xdc\x6c\xe7\x6b\xfd\xee\x77\xff\xf5\x5c\x6a\x6d\x6d" "\x6d\xad\x96\x3a\x71\x28\xc7\x89\x1c\x5b\x29\x7e\xae\x8c\xcb\xf9\xf5\x4a" "\x8e\xab\x39\xb6\xd3\xb5\xd7\xff\xf5\xb9\x87\xfe\xe5\xaf\xc6\x73\xf9\x22" "\x97\xcf\xb1\x95\xe3\x72\x8e\x2b\x39\xae\xe6\xd8\xce\xb1\x76\x20\x97\xcf" "\x71\x22\xc7\x56\x8e\xcb\x39\xae\xe4\xb8\x9a\x63\x3b\xc7\x5a\x5f\x2e\x9f" "\xe3\x44\x8e\xad\x1c\x97\x73\x5c\xc9\x71\x35\xc7\x76\xdf\x7e\x8e\x17\x00" "\x00\x00\x00\x00\x00\xc0\xf6\x8a\x28\xe2\x93\x91\xe2\xa5\x6f\xb5\xd3\xda" "\x40\x67\x82\xf7\xc5\xe8\xc4\xeb\x9e\x07\xba\xe7\xfd\x7f\x00\x00\x00\xff" "\xff\x75\x81\x60\x2f", 3101); syz_mount_image(/*fs=*/0x200000c0, /*dir=*/0x20000100, /*flags=*/0x300000a, /*opts=*/0x20000240, /*chdir=*/0xfe, /*size=*/0xc1d, /*img=*/0x20000480); memcpy((void*)0x20000240, "./file2\000", 8); syscall(__NR_unlink, /*path=*/0x20000240ul); memcpy((void*)0x20000200, "./file3\000", 8); memcpy((void*)0x20000140, "./file2\000", 8); syscall(__NR_rename, /*old=*/0x20000200ul, /*new=*/0x20000140ul); } int main(void) { syscall(__NR_mmap, /*addr=*/0x1ffff000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x20000000ul, /*len=*/0x1000000ul, /*prot=*/7ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); syscall(__NR_mmap, /*addr=*/0x21000000ul, /*len=*/0x1000ul, /*prot=*/0ul, /*flags=*/0x32ul, /*fd=*/-1, /*offset=*/0ul); do_sandbox_none(); return 0; }