aboutsummaryrefslogtreecommitdiffstats
path: root/pkg/csource/linux_common.go
diff options
context:
space:
mode:
authorDmitry Vyukov <dvyukov@google.com>2018-06-11 10:02:51 +0200
committerDmitry Vyukov <dvyukov@google.com>2018-06-11 12:12:01 +0300
commitdeb0e69e1028ba3152631c3f1d2fac98c12e33a5 (patch)
tree376f668a931b30657534770b00405c23588e8839 /pkg/csource/linux_common.go
parent9cff2eb96ab1d23a15740ee9e0161078b8fd01f1 (diff)
executor: always use errors=continue when mounting ext2/3/4
For ext2/3/4 we have to have errors=continue because the image can contain errors=panic flag and can legally crash kernel. Fixes #599
Diffstat (limited to 'pkg/csource/linux_common.go')
-rw-r--r--pkg/csource/linux_common.go21
1 files changed, 16 insertions, 5 deletions
diff --git a/pkg/csource/linux_common.go b/pkg/csource/linux_common.go
index 1aa454f9e..2ceb0b9d4 100644
--- a/pkg/csource/linux_common.go
+++ b/pkg/csource/linux_common.go
@@ -1054,9 +1054,9 @@ error:
#endif
#if defined(SYZ_EXECUTOR) || defined(__NR_syz_mount_image)
-static uintptr_t syz_mount_image(uintptr_t fs, uintptr_t dir, uintptr_t size, uintptr_t nsegs, uintptr_t segments, uintptr_t flags, uintptr_t opts)
+static uintptr_t syz_mount_image(uintptr_t fsarg, uintptr_t dir, uintptr_t size, uintptr_t nsegs, uintptr_t segments, uintptr_t flags, uintptr_t optsarg)
{
- char loopname[64];
+ char loopname[64], fs[32], opts[256];
int loopfd, err = 0, res = -1;
uintptr_t i;
struct fs_image_segment* segs = (struct fs_image_segment*)segments;
@@ -1107,12 +1107,23 @@ static uintptr_t syz_mount_image(uintptr_t fs, uintptr_t dir, uintptr_t size, ui
}
}
mkdir((char*)dir, 0777);
- NONFAILING(if (strcmp((char*)fs, "iso9660") == 0) flags |= MS_RDONLY);
- debug("syz_mount_image: size=%llu segs=%llu loop='%s' dir='%s' fs='%s' opts='%s'\n", (uint64)size, (uint64)nsegs, loopname, (char*)dir, (char*)fs, (char*)opts);
+ memset(fs, 0, sizeof(fs));
+ NONFAILING(strncpy(fs, (char*)fsarg, sizeof(fs) - 1));
+ memset(opts, 0, sizeof(opts));
+ NONFAILING(strncpy(opts, (char*)optsarg, sizeof(opts) - 32));
+ if (strcmp(fs, "iso9660") == 0) {
+ flags |= MS_RDONLY;
+ } else if (strncmp(fs, "ext", 3) == 0) {
+ if (strstr(opts, "errors=panic") || strstr(opts, "errors=remount-ro") == 0)
+ strcat(opts, ",errors=continue");
+ } else if (strcmp(fs, "xfs") == 0) {
+ strcat(opts, ",nouuid");
+ }
+ debug("syz_mount_image: size=%llu segs=%llu loop='%s' dir='%s' fs='%s' flags=%llu opts='%s'\n", (uint64)size, (uint64)nsegs, loopname, (char*)dir, fs, (uint64)flags, opts);
#if defined(SYZ_EXECUTOR)
cover_reset(0);
#endif
- if (mount(loopname, (char*)dir, (char*)fs, flags, (char*)opts)) {
+ if (mount(loopname, (char*)dir, fs, flags, opts)) {
err = errno;
goto error_clear_loop;
}