mckernel overlay: replace mcoverlayfs with a soft userspace overlay

mcoverlayfs has a high maintenance burden and does not work on rhel8's 4.18
kernel (while it works on vanilla 4.18...); instead of debugging this further
time is better spent making it independent from overlayfs.

Change-Id: I7454ae95b0fbb3373c256aa2fd83cdfec466c009
This commit is contained in:
Dominique Martinet
2019-01-28 11:26:57 +09:00
committed by Masamichi Takagi
parent 6fc9ec1c92
commit 9bf225d193
8 changed files with 673 additions and 425 deletions

2
configure vendored
View File

@ -3766,7 +3766,7 @@ fi
if test "${enable_mcoverlayfs+set}" = set; then :
enableval=$enable_mcoverlayfs; ENABLE_MCOVERLAYFS=$enableval
else
ENABLE_MCOVERLAYFS=yes
ENABLE_MCOVERLAYFS=no
fi

View File

@ -193,7 +193,7 @@ AC_ARG_ENABLE([mcoverlayfs],
AC_HELP_STRING([--enable-mcoverlayfs],
[enable mcoverlayfs implementation]),
[ENABLE_MCOVERLAYFS=$enableval],
[ENABLE_MCOVERLAYFS=yes])
[ENABLE_MCOVERLAYFS=no])
AC_ARG_ENABLE([rusage],
AC_HELP_STRING([--enable-rusage],

View File

@ -10,15 +10,12 @@ LIBS=@LIBS@
all: $(TARGET)
../../libmcexec.a: archdep.o arch_syscall.o
$(AR) cr ../../libmcexec.a archdep.o arch_syscall.o
../../libmcexec.a: archdep.o
$(AR) cr ../../libmcexec.a archdep.o
archdep.o: archdep.c archdep.S
$(CC) -c -I${KDIR} $(CFLAGS) $(EXTRA_CFLAGS) -fPIE -pie -pthread $^
arch_syscall.o: arch_syscall.c
$(CC) -c -I${KDIR} $(CFLAGS) $(EXTRA_CFLAGS) -fPIE -pie -pthread $<
clean:
$(RM) $(TARGET) *.o

View File

@ -1,7 +0,0 @@
struct syscall_wait_desc;
int
archdep_syscall(struct syscall_wait_desc *w, long *ret)
{
return -1;
}

View File

@ -10,15 +10,12 @@ LIBS=@LIBS@
all: $(TARGET)
../../libmcexec.a: archdep.o arch_syscall.o
$(AR) cr ../../libmcexec.a archdep.o arch_syscall.o
../../libmcexec.a: archdep.o
$(AR) cr ../../libmcexec.a archdep.o
archdep.o: archdep.S
$(CC) -c -I${KDIR} $(CFLAGS) $(EXTRA_CFLAGS) -fPIE -pie -pthread $<
arch_syscall.o: arch_syscall.c
$(CC) -c -I${KDIR} $(CFLAGS) $(EXTRA_CFLAGS) -fPIE -pie -pthread $<
../../libsyscall_intercept_arch.a: archdep_c.o
$(AR) cr ../../libsyscall_intercept_arch.a archdep_c.o

View File

@ -1,63 +0,0 @@
#define _GNU_SOURCE
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <unistd.h>
#include <fcntl.h>
#include <string.h>
#include <sys/resource.h>
#include <sys/syscall.h>
#include <elf.h>
#include <dirent.h>
#include "../../../include/uprotocol.h"
#include "../../archdep.h"
//#define DEBUG
#ifndef DEBUG
#define __dprint(msg, ...)
#define __dprintf(arg, ...)
#define __eprint(msg, ...)
#define __eprintf(format, ...)
#else
#define __dprint(msg, ...) {printf("%s: " msg, __FUNCTION__);fflush(stdout);}
#define __dprintf(format, ...) {printf("%s: " format, __FUNCTION__, \
__VA_ARGS__);fflush(stdout);}
#define __eprint(msg, ...) {fprintf(stderr, "%s: " msg, __FUNCTION__);\
fflush(stderr);}
#define __eprintf(format, ...) {fprintf(stderr, "%s: " format, __FUNCTION__, \
__VA_ARGS__);fflush(stderr);}
#endif
extern char *chgpath(char *, char *);
extern long do_strncpy_from_user(int, void *, void *, unsigned long);
extern int fd;
#define SET_ERR(ret) if (ret == -1) ret = -errno
int
archdep_syscall(struct syscall_wait_desc *w, long *ret)
{
char *fn;
char pathbuf[PATH_MAX];
char tmpbuf[PATH_MAX];
switch (w->sr.number) {
case __NR_open:
*ret = do_strncpy_from_user(fd, pathbuf,
(void *)w->sr.args[0], PATH_MAX);
if (*ret >= PATH_MAX) {
*ret = -ENAMETOOLONG;
}
if (*ret < 0) {
return 0;
}
__dprintf("open: %s\n", pathbuf);
fn = chgpath(pathbuf, tmpbuf);
*ret = open(fn, w->sr.args[1], w->sr.args[2]);
SET_ERR(*ret);
return 0;
}
return -1;
}

File diff suppressed because it is too large Load Diff

View File

@ -1,7 +1,9 @@
#ifndef _LINUX_LIST_H
#define _LINUX_LIST_H
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
#endif
/**
* container_of - cast a member of a structure out to the containing structure
* @ptr: the pointer to the member.