forked from gitpod-io/gitpod
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[ws-sync] Add shiftfs module loader for user-namespaced workspaces
- Loading branch information
Christian Weichel
committed
Oct 14, 2020
1 parent
75fafc7
commit 77f8c93
Showing
12 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shiftfs.c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
packages: | ||
- name: docker | ||
type: docker | ||
argdeps: | ||
- imageRepoBase | ||
srcs: | ||
- entrypoint.sh | ||
- dkms.conf | ||
- Makefile | ||
config: | ||
dockerfile: leeway.Dockerfile | ||
image: | ||
- ${imageRepoBase}/shiftfs-module-loader:${version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# source: https://github.com/toby63/shiftfs-dkms/blob/master/Makefile | ||
|
||
modname := shiftfs | ||
obj-m := $(modname).o | ||
|
||
KVERSION := $(shell uname -r) | ||
KDIR := /lib/modules/$(KVERSION)/build | ||
PWD := "$$(pwd)" | ||
|
||
ifdef DEBUG | ||
CFLAGS_$(obj-m) := -DDEBUG | ||
endif | ||
|
||
EXTRA_CFLAGS := -DSHIFTFS_MAGIC=0x6a656a62 | ||
|
||
default: | ||
$(MAKE) -C $(KDIR) M=$(PWD) EXTRA_CFLAGS="${EXTRA_CFLAGS}" modules | ||
|
||
clean: | ||
$(MAKE) O=$(PWD) -C $(KDIR) M=$(PWD) clean | ||
|
||
load: | ||
-rmmod $(modname) | ||
insmod $(modname).ko | ||
|
||
install: | ||
install -m 0755 -o root -g root $(modname).ko /lib/modules/$(KVERSION)/fs/ | ||
depmod -a | ||
|
||
uninstall: | ||
rm /lib/modules/$(KVERSION)/fs/$(modname).ko | ||
depmod -a | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This folder contains a fairly restricted, experimental shiftfs DKMS loader that can be run from within | ||
a Kubernetes cluster. | ||
|
||
It heavily draws inspiration from: | ||
https://github.com/falcosecurity/falco | ||
https://github.com/toby63/shiftfs-dkms |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
PACKAGE_NAME="shiftfs" | ||
PACKAGE_VERSION="1.2" | ||
BUILT_MODULE_NAME[0]="shiftfs" | ||
DEST_MODULE_LOCATION[0]="/kernel/fs/" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
|
||
DRIVER_NAME=shiftfs | ||
DRIVER_VERSION=1.2 | ||
ARCH=$(uname -m) | ||
KERNEL_RELEASE=$(uname -r) | ||
KERNEL_VERSION=$(uname -v | sed 's/#\([[:digit:]]\+\).*/\1/') | ||
|
||
if lsmod | grep $DRIVER_NAME; then | ||
echo "shiftfs is already loaded - nothing to do here" | ||
exit 0 | ||
fi | ||
|
||
set -ex | ||
mkdir -p /lib/modules/${KERNEL_RELEASE} | ||
ln -s /usr/src/linux-headers-${KERNEL_RELEASE} /lib/modules/${KERNEL_RELEASE}/build | ||
dkms install -m ${DRIVER_NAME} -v ${DRIVER_VERSION} -k $KERNEL_RELEASE --kernelsourcedir /usr/src/linux-headers-${KERNEL_RELEASE} | ||
insmod /var/lib/dkms/${DRIVER_NAME}/${DRIVER_VERSION}/${KERNEL_RELEASE}/${ARCH}/module/${DRIVER_NAME}.ko |
13 changes: 13 additions & 0 deletions
13
components/ws-sync/shiftfs-module-loader/leeway.Dockerfile
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
FROM ubuntu:18.04 | ||
|
||
RUN apt-get update && apt-get install -y git gcc make dkms curl | ||
|
||
# expects the host's /lib/modules to be mounted with a /lib/modules/<host-kernel-version>/build directory containing | ||
# the kernel header files. | ||
|
||
WORKDIR /build | ||
COPY entrypoint.sh ./ | ||
RUN mkdir -p /usr/src/shiftfs-1.2 && curl -o /usr/src/shiftfs-1.2/shiftfs.c -L https://git.launchpad.net/~ubuntu-kernel/ubuntu/+source/linux/+git/focal/plain/fs/shiftfs.c | ||
COPY dkms.conf Makefile /usr/src/shiftfs-1.2/ | ||
|
||
CMD [ "./entrypoint.sh" ] |