1 /*
2 * This file and its contents are supplied under the terms of the
3 * Common Development and Distribution License ("CDDL"), version 1.0.
4 * You may only use this file in accordance with the terms of version
5 * 1.0 of the CDDL.
6 *
7 * A full copy of the text of the CDDL should have accompanied this
8 * source. A copy of the CDDL is also available via the Internet at
9 * http://www.illumos.org/license/CDDL.
10 */
11
12 /*
13 * Copyright 2021 Oxide Computer Company
14 */
15
16 /*
17 * This program is meant to be a victim process. It will set up its core content
18 * and location into the specific place we indicate in its arguments and then
19 * sleep until we gcore and ABRT it.
20 */
21
22 #include <err.h>
23 #include <stdlib.h>
24 #include <sys/corectl.h>
25 #include <libproc.h>
26 #include <signal.h>
27
28 extern int which_ff(uint32_t, uint32_t);
29
30 int
main(int argc,char * argv[])31 main(int argc, char *argv[])
32 {
33 pid_t me = getpid();
34 core_content_t content;
35 sigset_t set = { 0 };
36
37 if (argc != 3) {
38 errx(EXIT_FAILURE, "<content> <dump path>");
39 }
40
41 if (proc_str2content(argv[1], &content) != 0) {
42 err(EXIT_FAILURE, "failed to parse content %s", argv[1]);
43 }
44
45 if (core_set_process_content(&content, me) != 0) {
46 err(EXIT_FAILURE, "failed to set core content to %s", argv[1]);
47 }
48
49 if (core_set_process_path(argv[2], strlen(argv[2]) + 1, me) != 0) {
50 err(EXIT_FAILURE, "failed to set core path to %s", argv[2]);
51 }
52
53 /*
54 * Call our library function to make sure it's present before we go and
55 * sleep.
56 */
57 (void) which_ff(6, 10);
58
59 for (;;) {
60 (void) sigsuspend(&set);
61 }
62
63 return (0);
64 }
65