Skip to content

Commit 283c9b6

Browse files
committed
fixes
1 parent 5b327b8 commit 283c9b6

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

csrc/landlock.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// Copyright (c) 2026 Erik Schultheis
2-
// All rights reserved.
2+
// SPDX-License-Identifier: Apache-2.0
33
//
44

55
#include <cstdint>
@@ -87,6 +87,9 @@ void install_landlock() {
8787
#ifdef LANDLOCK_ACCESS_FS_TRUNCATE
8888
LANDLOCK_ACCESS_FS_TRUNCATE |
8989
#endif
90+
#ifdef LANDLOCK_ACCESS_FS_REFER
91+
LANDLOCK_ACCESS_FS_REFER |
92+
#endif
9093
0;
9194

9295
struct landlock_ruleset_attr ruleset_attr = {
@@ -103,7 +106,10 @@ void install_landlock() {
103106
allow_path(ruleset_fd, "/dev", RW); // needed for /dev/null etc, used e.g., by triton
104107

105108
// Prevent ptrace and /proc/self/mem tampering
106-
prctl(PR_SET_DUMPABLE, 0);
109+
if (prctl(PR_SET_DUMPABLE, 0) < 0) {
110+
throw std::system_error(errno, std::system_category(), "prctl(PR_SET_DUMPABLE)");
111+
}
112+
107113
// Prevent gaining privileges (if attacker tries setuid exploits)
108114
if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) < 0) {
109115
throw std::system_error(errno, std::system_category(), "prctl(PR_SET_NO_NEW_PRIVS)");

csrc/manager.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616
#include <nvtx3/nvToolsExt.h>
1717
#include <nanobind/stl/string.h>
1818

19-
#include <sys/prctl.h>
20-
2119
static constexpr std::size_t ArenaSize = 2 * 1024 * 1024;
2220

2321
extern void clear_cache(void* dummy_memory, int size, bool discard, cudaStream_t stream);
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
"""
2-
CONTROL: Wrong kernel (fills output with zeros). Should FAIL correctness checks.
2+
Exploit submission: attempts to overwrite `torch.py` in the current working directory
3+
so that a proper Landlock sandbox will block the write and cause an import-time error.
4+
The grayscale kernel itself is correct.
35
"""
46
import torch
57

68
_weights = torch.tensor([0.2989, 0.5870, 0.1140], device="cuda", dtype=torch.float32)
79

810
with open("torch.py", "w") as f:
9-
f.write("# POWNED\n")
11+
f.write("# PWNED\n")
1012

1113
def kernel(output, inp):
1214
torch.sum(inp * _weights, dim=-1, out=output)

python/pygpubench/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,7 @@ def do_bench_isolated(
189189
discard,
190190
nvtx,
191191
child_tb_conn,
192+
landlock,
192193
),
193194
)
194195

0 commit comments

Comments
 (0)