Skip to content

Commit 1694ea5

Browse files
committed
syz-cluster: simplify shared git repo mounting code
Instead of a complicated overlayfs setup, do a lightweight git clone in a way that the cloned local copy keeps on referencing the git object storage on the NFS. It's simpler code-wise and hopefully will be less susceptible to failures when local git operations coincide with a git fetch on the shared repository.
1 parent 4e1406b commit 1694ea5

File tree

4 files changed

+29
-58
lines changed

4 files changed

+29
-58
lines changed

syz-cluster/workflow/build-step/Dockerfile

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ RUN gzip -d /disk-images/buildroot_amd64_2024.09.gz
2424
RUN mkdir -p /kernel-configs
2525
ADD https://raw.githubusercontent.com/google/syzkaller/refs/heads/master/dashboard/config/linux/upstream-apparmor-kasan.config /kernel-configs/upstream-apparmor-kasan.config
2626
ADD https://raw.githubusercontent.com/google/syzkaller/refs/heads/master/dashboard/config/linux/upstream-kmsan.config /kernel-configs/upstream-kmsan.config
27+
RUN chmod 644 /kernel-configs/*
28+
29+
# Prevent "fatal: detected dubious ownership in repository" errors.
30+
RUN git config --system --add safe.directory /workdir
31+
RUN git config --system --add safe.directory /kernel-repo
2732

2833
COPY --from=build-step-builder /build/build-step-bin /bin/build-step
2934

syz-cluster/workflow/build-step/workflow-template.yaml

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ spec:
1212
limit: "3"
1313
backoff:
1414
duration: "5m"
15+
securityContext:
16+
runAsUser: 10000
17+
fsGroup: 10000
1518
inputs:
1619
parameters:
1720
- name: findings
@@ -27,34 +30,25 @@ spec:
2730
- name: request
2831
path: /tmp/request.json
2932
initContainers:
30-
- name: setup-overlays
31-
image: alpine/git:latest
33+
- name: setup-repo
34+
image: ${IMAGE_PREFIX}build-step:${IMAGE_TAG}
3235
imagePullPolicy: IfNotPresent
3336
command:
3437
- sh
3538
- -c
3639
- |
37-
mkdir /data/overlayfs /data/.git
38-
mount -t tmpfs -o size=128M tmpfs /data/overlayfs
39-
mkdir /data/overlayfs/upper /data/overlayfs/work
40-
mount -t overlay overlay -o lowerdir=/kernel-repo,upperdir=/data/overlayfs/upper,workdir=/data/overlayfs/work /data/.git
41-
chmod 0777 /data/.git
42-
git --git-dir=/data/.git --work-tree=/workdir checkout v3.0
43-
chmod -R 0777 /data/.git/logs
44-
chmod -R 0777 /workdir
40+
git clone --reference /kernel-repo /kernel-repo ./workdir
41+
env:
42+
- name: GIT_DISCOVERY_ACROSS_FILESYSTEM
43+
value: "1"
44+
- name: HOME # Otherwise it's failing with "warning: unable to access '/root/.config/git/attributes': Permission denied.".
45+
value: "/home/syzkaller"
4546
volumeMounts:
46-
- name: shared-git-repo
47-
mountPath: /data
48-
mountPropagation: Bidirectional
4947
- name: base-kernel-repo
5048
mountPath: /kernel-repo
5149
readOnly: true
5250
- name: workdir
5351
mountPath: /workdir
54-
securityContext:
55-
privileged: true
56-
capabilities:
57-
add: ["SYS_ADMIN"]
5852
container:
5953
image: ${IMAGE_PREFIX}build-step:${IMAGE_TAG}
6054
imagePullPolicy: IfNotPresent
@@ -75,18 +69,7 @@ spec:
7569
limits:
7670
cpu: 32
7771
memory: 96G
78-
env:
79-
- name: GIT_DIR
80-
value: "/data/.git"
81-
- name: GIT_DISCOVERY_ACROSS_FILESYSTEM
82-
value: "1"
83-
- name: GIT_WORK_TREE
84-
value: "/workdir"
85-
- name: HOME # Otherwise it's failing with "warning: unable to access '/root/.config/git/attributes': Permission denied.".
86-
value: "/home/syzkaller"
8772
volumeMounts:
88-
- name: shared-git-repo
89-
mountPath: /data
9073
- name: base-kernel-repo
9174
mountPath: /kernel-repo
9275
readOnly: true
@@ -102,9 +85,6 @@ spec:
10285
- name: base-kernel-repo
10386
persistentVolumeClaim:
10487
claimName: base-kernel-repo-pv-claim
105-
- name: shared-git-repo
106-
emptyDir:
107-
medium: Memory
10888
- name: workdir
10989
emptyDir: {}
11090
- name: output

syz-cluster/workflow/triage-step/Dockerfile

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ RUN apt-get update && \
2626
apt-get install -y git
2727

2828
# pkg/osutil uses syzkaller user for sandboxing.
29-
RUN useradd --create-home syzkaller
29+
RUN useradd -u 10000 --create-home syzkaller
30+
# Prevent "fatal: detected dubious ownership in repository" errors.
31+
RUN git config --system --add safe.directory /workdir
32+
RUN git config --system --add safe.directory /kernel-repo
3033

3134
COPY --from=triage-step-builder /build/triage-step-bin /bin/triage-step
3235

syz-cluster/workflow/triage-step/workflow-template.yaml

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,35 +12,27 @@ spec:
1212
limit: "3"
1313
backoff:
1414
duration: "5m"
15+
securityContext:
16+
runAsUser: 10000
17+
fsGroup: 10000
1518
initContainers:
16-
- name: setup-overlays
17-
image: alpine/git:latest
19+
- name: setup-repo
20+
image: ${IMAGE_PREFIX}triage-step:${IMAGE_TAG}
1821
imagePullPolicy: IfNotPresent
1922
command:
2023
- sh
2124
- -c
2225
- |
23-
mkdir /data/overlayfs /data/.git
24-
mount -t tmpfs -o size=128M tmpfs /data/overlayfs
25-
mkdir /data/overlayfs/upper /data/overlayfs/work
26-
mount -t overlay overlay -o lowerdir=/kernel-repo,upperdir=/data/overlayfs/upper,workdir=/data/overlayfs/work /data/.git
27-
chmod 0777 /data/.git
28-
git --git-dir=/data/.git --work-tree=/workdir checkout v3.0
29-
chmod -R 0777 /data/.git/logs
30-
chmod -R 0777 /workdir
26+
git clone --reference /kernel-repo /kernel-repo /workdir
27+
env:
28+
- name: GIT_DISCOVERY_ACROSS_FILESYSTEM
29+
value: "1"
3130
volumeMounts:
32-
- name: shared-git-repo
33-
mountPath: /data
34-
mountPropagation: Bidirectional
3531
- name: base-kernel-repo
3632
mountPath: /kernel-repo
3733
readOnly: true
3834
- name: workdir
3935
mountPath: /workdir
40-
securityContext:
41-
privileged: true
42-
capabilities:
43-
add: ["SYS_ADMIN"]
4436
container:
4537
image: ${IMAGE_PREFIX}triage-step:${IMAGE_TAG}
4638
imagePullPolicy: IfNotPresent
@@ -58,17 +50,11 @@ spec:
5850
cpu: 4
5951
memory: 16G
6052
env:
61-
- name: GIT_DIR
62-
value: "/data/.git"
6353
- name: GIT_DISCOVERY_ACROSS_FILESYSTEM
6454
value: "1"
65-
- name: GIT_WORK_TREE
66-
value: "/workdir"
6755
- name: HOME # Otherwise it's failing with "warning: unable to access '/root/.config/git/attributes': Permission denied.".
6856
value: "/home/syzkaller"
6957
volumeMounts:
70-
- name: shared-git-repo
71-
mountPath: /data
7258
- name: base-kernel-repo
7359
mountPath: /kernel-repo
7460
readOnly: true
@@ -80,9 +66,6 @@ spec:
8066
- name: base-kernel-repo
8167
persistentVolumeClaim:
8268
claimName: base-kernel-repo-pv-claim
83-
- name: shared-git-repo
84-
emptyDir:
85-
medium: Memory
8669
- name: workdir
8770
emptyDir: {}
8871
- name: output

0 commit comments

Comments
 (0)