-
Notifications
You must be signed in to change notification settings - Fork 362
Expand file tree
/
Copy pathlibreprl-posix.c
More file actions
627 lines (537 loc) · 20.7 KB
/
libreprl-posix.c
File metadata and controls
627 lines (537 loc) · 20.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
// Copyright 2019 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#if !defined(_WIN32)
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#include "libreprl.h"
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <poll.h>
#include <signal.h>
#include <stdarg.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/types.h>
#include <sys/utsname.h>
#include <sys/wait.h>
#include <time.h>
#include <unistd.h>
#ifdef __linux__
# ifdef __has_include
# if __has_include(<linux/close_range.h>)
# define HAS_CLOSE_RANGE_HEADERS
# endif
# elif defined(__FreeBSD__)
# ifdef CLOSE_RANGE_CLOEXEC
# define HAS_CLOSE_RANGE_HEADERS
# endif
# endif
#endif
// Well-known file descriptor numbers for reprl <-> child communication, child process side
// Make sure you modify reprl_fds[] below if you change these.
#define REPRL_CHILD_CTRL_IN 100
#define REPRL_CHILD_CTRL_OUT 101
#define REPRL_CHILD_DATA_IN 102
#define REPRL_CHILD_DATA_OUT 103
static const int reprl_fds[] = {
REPRL_CHILD_CTRL_IN,
REPRL_CHILD_CTRL_OUT,
REPRL_CHILD_DATA_IN,
REPRL_CHILD_DATA_OUT
};
/// Maximum timeout in microseconds. Mostly just limited by the fact that the timeout in milliseconds has to fit into a 32-bit integer.
#define REPRL_MAX_TIMEOUT_IN_MICROSECONDS ((uint64_t)(INT_MAX) * 1000)
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static size_t min(size_t x, size_t y) {
return x < y ? x : y;
}
static uint64_t current_usecs()
{
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return ts.tv_sec * 1000000 + ts.tv_nsec / 1000;
}
static char** copy_string_array(const char** orig)
{
size_t num_entries = 0;
for (const char** current = orig; *current; current++) {
num_entries += 1;
}
char** copy = calloc(num_entries + 1, sizeof(char*));
for (size_t i = 0; i < num_entries; i++) {
copy[i] = strdup(orig[i]);
}
return copy;
}
static void free_string_array(char** arr)
{
if (!arr) return;
for (char** current = arr; *current; current++) {
free(*current);
}
free(arr);
}
static int getdtablesize_or_crash() {
const int tablesize = getdtablesize();
if (tablesize < 0) {
fprintf(stderr, "getdtablesize() failed: %s. This likely means the system is borked.\n",
strerror(errno));
abort();
}
return tablesize;
}
static bool system_supports_close_range() {
#ifdef HAS_CLOSE_RANGE_HEADERS
# ifdef __linux__
struct utsname buffer;
int major, minor, patch;
(void)uname(&buffer); // Linux uname can only throw EFAULT if buf is invalid.
if (sscanf(buffer.release, "%d.%d.%d", &major, &minor, &patch) != 3) {
return false;
}
return major > 5 || (major == 5 && minor >= 9);
# elif defined(__FreeBSD__)
// TODO: Technically, FreeBSD does support close_range, but I don't need support for it right
// now, so leaving this unimplemented. Don't have a platform to test on.
// https://man.freebsd.org/cgi/man.cgi?close_range(2)
return false;
# else
return false;
# endif
#else
return false;
#endif
}
static int fd_qsort_compare(const void* a, const void* b) {
int fd_a = *(const int*)a;
int fd_b = *(const int*)b;
return (fd_a > fd_b) - (fd_a < fd_b);
}
/// Fast path which uses close_range() to close ranges of fds.
static void close_all_non_reprl_fds_fast() {
#ifdef HAS_CLOSE_RANGE_HEADERS
// Unfortunately we cannot trust the reprl_fds array to be sorted since an accidental edit to
// reprl_fds could have broken that assumption. So let's create a new sorted array. It's cheap
// anyways.
int sorted_reprl_fds[ARRAY_SIZE(reprl_fds) + 2];
sorted_reprl_fds[0] = 3; // Skip the well-known stdin, stdout, stderr fds.
memcpy(sorted_reprl_fds + 1, reprl_fds, sizeof(reprl_fds));
sorted_reprl_fds[ARRAY_SIZE(sorted_reprl_fds) - 1] = getdtablesize_or_crash();
qsort(sorted_reprl_fds, ARRAY_SIZE(sorted_reprl_fds), sizeof(int), fd_qsort_compare);
// Cool, now we will iterate the sorted fds in ranges and close everything in between.
int start_fd = 3, end_fd;
for (size_t i = 0; i < ARRAY_SIZE(sorted_reprl_fds); i++) {
end_fd = sorted_reprl_fds[i];
if (start_fd < end_fd) {
// Close the range [start_fd, end_fd)
close_range(start_fd, end_fd - 1, 0);
}
start_fd = end_fd + 1;
}
#else
fprintf(stderr, "close_all_non_reprl_fds_fast() called on a system which does not support "
"close_range(). This is likely a programming bug.\n");
abort();
#endif
}
/// Fallback path which makes a close() syscall for each non-REPRL fd.
static void close_all_non_reprl_fds_slow() {
const int tablesize = getdtablesize_or_crash();
for (int i = 3; i < tablesize; i++) {
bool is_reprl_fd = false;
for (size_t j = 0; j < ARRAY_SIZE(reprl_fds); j++) {
if (i == reprl_fds[j]) {
is_reprl_fd = true;
break;
}
}
if (!is_reprl_fd) {
close(i);
}
}
}
/// Close all file descriptors except the well-known REPRL and stdio fds.
static void close_all_non_reprl_fds() {
system_supports_close_range() ? close_all_non_reprl_fds_fast() : close_all_non_reprl_fds_slow();
}
// A unidirectional communication channel for larger amounts of data, up to a maximum size (REPRL_MAX_DATA_SIZE).
// Implemented as a (RAM-backed) file for which the file descriptor is shared with the child process and which is mapped into our address space.
struct data_channel {
// File descriptor of the underlying file. Directly shared with the child process.
int fd;
// Memory mapping of the file, always of size REPRL_MAX_DATA_SIZE.
char* mapping;
};
struct reprl_context {
// Whether reprl_initialize has been successfully performed on this context.
int initialized;
// Read file descriptor of the control pipe. Only valid if a child process is running (i.e. pid is nonzero).
int ctrl_in;
// Write file descriptor of the control pipe. Only valid if a child process is running (i.e. pid is nonzero).
int ctrl_out;
// Data channel REPRL -> Child
struct data_channel* data_in;
// Data channel Child -> REPRL
struct data_channel* data_out;
// Optional data channel for the child's stdout and stderr.
struct data_channel* child_stdout;
struct data_channel* child_stderr;
// PID of the child process. Will be zero if no child process is currently running.
pid_t pid;
// Arguments and environment for the child process.
char** argv;
char** envp;
// A malloc'd string containing a description of the last error that occurred.
char* last_error;
};
static int reprl_error(struct reprl_context* ctx, const char *format, ...)
{
va_list args;
va_start(args, format);
free(ctx->last_error);
vasprintf(&ctx->last_error, format, args);
return -1;
}
static struct data_channel* reprl_create_data_channel(struct reprl_context* ctx)
{
#ifdef __linux__
int fd = memfd_create("REPRL_DATA_CHANNEL", MFD_CLOEXEC);
#else
char path[] = "/tmp/reprl_data_channel_XXXXXXXX";
int fd = mkostemp(path, O_CLOEXEC);
unlink(path);
#endif
if (fd == -1 || ftruncate(fd, REPRL_MAX_DATA_SIZE) != 0) {
reprl_error(ctx, "Failed to create data channel file: %s", strerror(errno));
return NULL;
}
char* mapping = mmap(0, REPRL_MAX_DATA_SIZE, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (mapping == MAP_FAILED) {
reprl_error(ctx, "Failed to mmap data channel file: %s", strerror(errno));
return NULL;
}
struct data_channel* channel = malloc(sizeof(struct data_channel));
channel->fd = fd;
channel->mapping = mapping;
return channel;
}
static void reprl_destroy_data_channel(struct data_channel* channel)
{
if (!channel) return;
close(channel->fd);
munmap(channel->mapping, REPRL_MAX_DATA_SIZE);
free(channel);
}
static void reprl_child_terminated(struct reprl_context* ctx)
{
if (!ctx->pid) return;
ctx->pid = 0;
close(ctx->ctrl_in);
close(ctx->ctrl_out);
}
static void reprl_terminate_child(struct reprl_context* ctx)
{
if (!ctx->pid) return;
int status;
kill(ctx->pid, SIGKILL);
waitpid(ctx->pid, &status, 0);
reprl_child_terminated(ctx);
}
static int reprl_spawn_child(struct reprl_context* ctx)
{
// This is also a good time to ensure the data channel backing files don't grow too large.
ftruncate(ctx->data_in->fd, REPRL_MAX_DATA_SIZE);
ftruncate(ctx->data_out->fd, REPRL_MAX_DATA_SIZE);
if (ctx->child_stdout) ftruncate(ctx->child_stdout->fd, REPRL_MAX_DATA_SIZE);
if (ctx->child_stderr) ftruncate(ctx->child_stderr->fd, REPRL_MAX_DATA_SIZE);
int crpipe[2] = { 0, 0 }; // control pipe child -> reprl
int cwpipe[2] = { 0, 0 }; // control pipe reprl -> child
if (pipe(crpipe) != 0) {
return reprl_error(ctx, "Could not create pipe for REPRL communication: %s", strerror(errno));
}
if (pipe(cwpipe) != 0) {
close(crpipe[0]);
close(crpipe[1]);
return reprl_error(ctx, "Could not create pipe for REPRL communication: %s", strerror(errno));
}
ctx->ctrl_in = crpipe[0];
ctx->ctrl_out = cwpipe[1];
fcntl(ctx->ctrl_in, F_SETFD, FD_CLOEXEC);
fcntl(ctx->ctrl_out, F_SETFD, FD_CLOEXEC);
#ifdef __linux__
// Use vfork() on Linux as that considerably improves the fuzzer performance. See also https://github.com/googleprojectzero/fuzzilli/issues/174
// Due to vfork, the code executed in the child process *must not* modify any memory apart from its stack, as it will share the page table of its parent.
pid_t pid = vfork();
#else
pid_t pid = fork();
#endif
if (pid == 0) {
if (dup2(cwpipe[0], REPRL_CHILD_CTRL_IN) < 0 ||
dup2(crpipe[1], REPRL_CHILD_CTRL_OUT) < 0 ||
dup2(ctx->data_out->fd, REPRL_CHILD_DATA_IN) < 0 ||
dup2(ctx->data_in->fd, REPRL_CHILD_DATA_OUT) < 0) {
fprintf(stderr, "dup2 failed in the child: %s\n", strerror(errno));
_exit(-1);
}
#ifdef __linux__
// Set RLIMIT_CORE to 0, such that we don't produce core dumps. The
// added benefit of doing this here, in the child process, is that we
// can still get core dumps when Fuzzilli crashes.
struct rlimit core_limit;
core_limit.rlim_cur = 0;
core_limit.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &core_limit) < 0) {
fprintf(stderr, "setrlimit failed in the child: %s\n", strerror(errno));
_exit(-1);
};
#endif
// Unblock any blocked signals. It seems that libdispatch sometimes blocks delivery of certain signals.
sigset_t newset;
sigemptyset(&newset);
if (sigprocmask(SIG_SETMASK, &newset, NULL) != 0) {
fprintf(stderr, "sigprocmask failed in the child: %s\n", strerror(errno));
_exit(-1);
}
close(cwpipe[0]);
close(crpipe[1]);
int devnull = open("/dev/null", O_RDWR);
dup2(devnull, 0);
if (ctx->child_stdout) dup2(ctx->child_stdout->fd, 1);
else dup2(devnull, 1);
if (ctx->child_stderr) dup2(ctx->child_stderr->fd, 2);
else dup2(devnull, 2);
close(devnull);
// close all other FDs. We try to use FD_CLOEXEC everywhere, but let's be extra sure we don't leak any fds to the child.
close_all_non_reprl_fds();
execve(ctx->argv[0], ctx->argv, ctx->envp);
fprintf(stderr, "Failed to execute child process %s: %s\n", ctx->argv[0], strerror(errno));
fflush(stderr);
_exit(-1);
}
close(crpipe[1]);
close(cwpipe[0]);
if (pid < 0) {
close(ctx->ctrl_in);
close(ctx->ctrl_out);
return reprl_error(ctx, "Failed to fork: %s", strerror(errno));
}
ctx->pid = pid;
char helo[5] = { 0 };
if (read(ctx->ctrl_in, helo, 4) != 4) {
reprl_terminate_child(ctx);
return reprl_error(ctx, "Did not receive HELO message from child: %s", strerror(errno));
}
if (strncmp(helo, "HELO", 4) != 0) {
reprl_terminate_child(ctx);
return reprl_error(ctx, "Received invalid HELO message from child: %s", helo);
}
if (write(ctx->ctrl_out, helo, 4) != 4) {
reprl_terminate_child(ctx);
return reprl_error(ctx, "Failed to send HELO reply message to child: %s", strerror(errno));
}
#ifdef __linux__
struct rlimit core_limit = {};
if (prlimit(pid, RLIMIT_CORE, NULL, &core_limit) < 0) {
reprl_terminate_child(ctx);
return reprl_error(ctx, "prlimit failed: %s\n", strerror(errno));
}
if (core_limit.rlim_cur != 0 || core_limit.rlim_max != 0) {
reprl_terminate_child(ctx);
return reprl_error(ctx, "Detected non-zero RLIMIT_CORE. Check that the child does not set RLIMIT_CORE manually.\n");
}
#endif
return 0;
}
struct reprl_context* reprl_create_context()
{
// "Reserve" the well-known REPRL fds so no other fd collides with them.
// This would cause various kinds of issues in reprl_spawn_child.
// It would be enough to do this once per process in the case of multiple
// REPRL instances, but it's probably not worth the implementation effort.
int devnull = open("/dev/null", O_RDWR);
dup2(devnull, REPRL_CHILD_CTRL_IN);
dup2(devnull, REPRL_CHILD_CTRL_OUT);
dup2(devnull, REPRL_CHILD_DATA_IN);
dup2(devnull, REPRL_CHILD_DATA_OUT);
close(devnull);
return calloc(1, sizeof(struct reprl_context));
}
int reprl_initialize_context(struct reprl_context* ctx, const char** argv, const char** envp, int capture_stdout, int capture_stderr)
{
if (ctx->initialized) {
return reprl_error(ctx, "Context is already initialized");
}
// We need to ignore SIGPIPE since we could end up writing to a pipe after our child process has exited.
signal(SIGPIPE, SIG_IGN);
ctx->argv = copy_string_array(argv);
ctx->envp = copy_string_array(envp);
ctx->data_in = reprl_create_data_channel(ctx);
ctx->data_out = reprl_create_data_channel(ctx);
if (capture_stdout) {
ctx->child_stdout = reprl_create_data_channel(ctx);
}
if (capture_stderr) {
ctx->child_stderr = reprl_create_data_channel(ctx);
}
if (!ctx->data_in || !ctx->data_out || (capture_stdout && !ctx->child_stdout) || (capture_stderr && !ctx->child_stderr)) {
// Proper error message will have been set by reprl_create_data_channel
return -1;
}
ctx->initialized = 1;
return 0;
}
void reprl_destroy_context(struct reprl_context* ctx)
{
reprl_terminate_child(ctx);
free_string_array(ctx->argv);
free_string_array(ctx->envp);
reprl_destroy_data_channel(ctx->data_in);
reprl_destroy_data_channel(ctx->data_out);
reprl_destroy_data_channel(ctx->child_stdout);
reprl_destroy_data_channel(ctx->child_stderr);
free(ctx->last_error);
free(ctx);
}
int reprl_execute(struct reprl_context* ctx, const char* script, uint64_t script_size, uint64_t timeout, uint64_t* execution_time, int fresh_instance)
{
if (!ctx->initialized) {
return reprl_error(ctx, "REPRL context is not initialized");
}
if (script_size > REPRL_MAX_DATA_SIZE) {
return reprl_error(ctx, "Script too large");
}
if (timeout > REPRL_MAX_TIMEOUT_IN_MICROSECONDS) {
return reprl_error(ctx, "Timeout too large");
}
int timeout_ms = (int)(timeout / 1000);
// Terminate any existing instance if requested.
if (fresh_instance && ctx->pid) {
reprl_terminate_child(ctx);
}
// Reset file position so the child can simply read(2) and write(2) to these fds.
lseek(ctx->data_out->fd, 0, SEEK_SET);
lseek(ctx->data_in->fd, 0, SEEK_SET);
if (ctx->child_stdout) {
lseek(ctx->child_stdout->fd, 0, SEEK_SET);
}
if (ctx->child_stderr) {
lseek(ctx->child_stderr->fd, 0, SEEK_SET);
}
// Spawn a new instance if necessary.
if (!ctx->pid) {
int r = reprl_spawn_child(ctx);
if (r != 0) return r;
}
// Copy the script to the data channel.
memcpy(ctx->data_out->mapping, script, script_size);
// Tell child to execute the script.
if (write(ctx->ctrl_out, "exec", 4) != 4 ||
write(ctx->ctrl_out, &script_size, 8) != 8) {
// These can fail if the child unexpectedly terminated between executions.
// Check for that here to be able to provide a better error message.
int status;
if (waitpid(ctx->pid, &status, WNOHANG) == ctx->pid) {
reprl_child_terminated(ctx);
if (WIFEXITED(status)) {
return reprl_error(ctx, "Child unexpectedly exited with status %i between executions", WEXITSTATUS(status));
} else {
return reprl_error(ctx, "Child unexpectedly terminated with signal %i between executions", WTERMSIG(status));
}
}
return reprl_error(ctx, "Failed to send command to child process: %s", strerror(errno));
}
// Wait for child to finish execution (or crash).
uint64_t start_time = current_usecs();
struct pollfd fds = {.fd = ctx->ctrl_in, .events = POLLIN, .revents = 0};
int res = poll(&fds, 1, timeout_ms);
*execution_time = current_usecs() - start_time;
if (res == 0) {
// Execution timed out. Kill child and return a timeout status.
reprl_terminate_child(ctx);
return 1 << 16;
} else if (res != 1) {
// An error occurred.
// We expect all signal handlers to be installed with SA_RESTART, so receiving EINTR here is unexpected and thus also an error.
return reprl_error(ctx, "Failed to poll: %s", strerror(errno));
}
// Poll succeeded, so there must be something to read now (either the status or EOF).
int status;
ssize_t rv = read(ctx->ctrl_in, &status, 4);
if (rv < 0) {
return reprl_error(ctx, "Failed to read from control pipe: %s", strerror(errno));
} else if (rv != 4) {
// Most likely, the child process crashed and closed the write end of the control pipe.
// Unfortunately, there probably is nothing that guarantees that waitpid() will immediately succeed now,
// and we also don't want to block here. So just retry waitpid() a few times...
int success = 0;
do {
success = waitpid(ctx->pid, &status, WNOHANG) == ctx->pid;
if (!success) usleep(10);
} while (!success && current_usecs() - start_time < timeout);
if (!success) {
// Wait failed, so something weird must have happened. Maybe somehow the control pipe was closed without the child exiting?
// Probably the best we can do is kill the child and return an error.
reprl_terminate_child(ctx);
return reprl_error(ctx, "Child in weird state after execution");
}
// Cleanup any state related to this child process.
reprl_child_terminated(ctx);
if (WIFEXITED(status)) {
status = WEXITSTATUS(status) << 8;
} else if (WIFSIGNALED(status)) {
status = WTERMSIG(status);
} else {
// This shouldn't happen, since we don't specify WUNTRACED for waitpid...
return reprl_error(ctx, "Waitpid returned unexpected child state %i", status);
}
}
// The status must be a positive number, see the status encoding format below.
// We also don't allow the child process to indicate a timeout. If we wanted,
// we could treat it as an error if the upper bits are set.
status &= 0xffff;
return status;
}
static const char* fetch_data_channel_content(struct data_channel* channel)
{
if (!channel) return "";
size_t pos = lseek(channel->fd, 0, SEEK_CUR);
pos = min(pos, REPRL_MAX_DATA_SIZE - 1);
channel->mapping[pos] = 0;
return channel->mapping;
}
const char* reprl_fetch_fuzzout(struct reprl_context* ctx)
{
return fetch_data_channel_content(ctx->data_in);
}
const char* reprl_fetch_stdout(struct reprl_context* ctx)
{
return fetch_data_channel_content(ctx->child_stdout);
}
const char* reprl_fetch_stderr(struct reprl_context* ctx)
{
return fetch_data_channel_content(ctx->child_stderr);
}
const char* reprl_get_last_error(struct reprl_context* ctx)
{
return ctx->last_error;
}
#endif