Skip to content

Commit 24880bb

Browse files
committed
kernelCTF: enable bpf_jit_harden in repro
1 parent 9a3033a commit 24880bb

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

kernelctf/check-submission.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@
9494
submissionIds = list(set(submissionIds).intersection(publicSheet.keys()))
9595
submissionIds.sort()
9696

97+
# Regular expression to handle kernelCTF flag without signature
98+
flagRegex = r"kernelCTF\{(?:[^:]+:)?(?:v1:([^:]+)|v2:([^:]+):([^:]*)):\d+\}"
99+
def flagTarget(flag):
100+
match = checkRegex(flag, flagRegex, f"The flag (`{flag}`) is invalid")
101+
if match.group(1):
102+
# v1 flag
103+
return match.group(1)
104+
105+
# v2 flag
106+
return match.group(2)
107+
108+
targetFlagTimes = {}
97109
flags = []
98110
for submissionId in submissionIds:
99111
publicData = publicSheet[submissionId]
@@ -116,22 +128,13 @@
116128
else:
117129
print(f"[+] The hash of the file `{archiveFn}` matches the expected `{exploitHash}` value.")
118130

119-
flags.extend(publicData["Flags"].strip().split('\n'))
131+
for flag in publicData["Flags"].strip().split('\n'):
132+
flags.append(flag)
133+
targetFlagTimes[flagTarget(flag)] = publicData["Flag submission time"]
120134

121135
if cve != publicData["CVE"]:
122136
error(f"The CVE on the public spreadsheet for submission `{submissionId}` is `{publicData['CVE']}` but the PR is for `{cve}`.")
123137

124-
# Regular expression to handle kernelCTF flag without signature
125-
flagRegex = r"kernelCTF\{(?:[^:]+:)?(?:v1:([^:]+)|v2:([^:]+):([^:]*)):\d+\}"
126-
def flagTarget(flag):
127-
match = checkRegex(flag, flagRegex, f"The flag (`{flag}`) is invalid")
128-
if match.group(1):
129-
# v1 flag
130-
return match.group(1)
131-
132-
# v2 flag
133-
return match.group(2)
134-
135138
flagTargets = set([flagTarget(flag) for flag in flags])
136139
if "mitigation-6.1-v2" in flagTargets:
137140
flagTargets = flagTargets - {"mitigation-6.1-v2"} | {"mitigation-6.1"}
@@ -160,6 +163,7 @@ def summary(success, text):
160163
exploit_info = metadata["exploits"].get(target)
161164
if not exploit_info: continue
162165
exploits_info[target] = { key: exploit_info[key] for key in ["uses", "requires_separate_kaslr_leak"] if key in exploit_info }
166+
exploits_info[target]["flag_time"] = targetFlagTimes[target]
163167
ghSet("OUTPUT", f"exploits_info={json.dumps(exploits_info)}")
164168
ghSet("OUTPUT", f"artifact_backup_dir={'_'.join(submissionIds)}")
165169

kernelctf/repro/repro.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ fi
2525

2626
if [[ "$RELEASE_ID" == "mitigation-"* ]]; then
2727
CMDLINE="$CMDLINE sysctl.kernel.dmesg_restrict=1 sysctl.kernel.kptr_restrict=2 sysctl.kernel.unprivileged_bpf_disabled=2 sysctl.net.core.bpf_jit_harden=1 sysctl.kernel.yama.ptrace_scope=1 slab_virtual=1 slab_virtual_guards=1";
28+
elif [[ "$(echo $EXPLOIT_INFO | jq -re '.flag_time')" > "2025-02-28" ]]; then
29+
CMDLINE="$CMDLINE sysctl.net.core.bpf_jit_harden=2"
2830
fi
2931

3032
# Keep this as the last check as it contains "--", everything comes after this is not passed to the kernel

0 commit comments

Comments
 (0)