Commit eb0c940
committed
api: drop KASLD_* on a privilege-gaining exec
KASLD_COMPONENT_DIR and KASLD_EXEC_WRAPPER name programs kasld executes,
and KASLD_SYSROOT names the files it reads. Nothing stripped them, so a
set-uid or set-gid install, or one carrying file capabilities, handed
whoever set them code execution at that privilege. The dynamic loader
sanitises only the variables it owns and these are ordinary ones. No
install here sets those bits — the install target uses mode 755
throughout — but nothing would notice if that changed, and setcap on a
tool that reads /proc/kallsyms and the kernel log is a plausible step for
someone to take.
A constructor in api.h, which the orchestrator and every component
include, unlinks each KASLD_ entry from environ when getauxval(AT_SECURE)
reports the exec gained privilege, falling back to a uid/gid comparison
where the auxiliary vector carries no such entry. AT_SECURE is the only
one of the two that accounts for file capabilities.
The whole prefix goes rather than a list of names, so a variable added
later needs no change here. Removing the entries rather than ignoring
them at each read also cleans what the component children inherit, which
matters because a child gains no privilege at its own exec and cannot
detect the case itself. environ is edited directly because unsetenv is
not declared under the strict -std=c99 compile that check-headers builds
api.h as.
Nothing aborts: a privileged install still runs, on its own configuration
rather than a caller's. The removal is covered over a synthetic prefix,
since dropping the real one in-process would take the staged sysroot with
it and send every later test to the live host. kasld(1) records the
behaviour beside the env_reset note it already carried.1 parent a734207 commit eb0c940
3 files changed
Lines changed: 125 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
190 | 197 | | |
191 | 198 | | |
192 | 199 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1228 | 1228 | | |
1229 | 1229 | | |
1230 | 1230 | | |
| 1231 | + | |
| 1232 | + | |
1231 | 1233 | | |
1232 | 1234 | | |
1233 | 1235 | | |
| |||
2427 | 2429 | | |
2428 | 2430 | | |
2429 | 2431 | | |
| 2432 | + | |
| 2433 | + | |
| 2434 | + | |
| 2435 | + | |
| 2436 | + | |
| 2437 | + | |
| 2438 | + | |
| 2439 | + | |
| 2440 | + | |
| 2441 | + | |
| 2442 | + | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
| 2446 | + | |
| 2447 | + | |
| 2448 | + | |
| 2449 | + | |
| 2450 | + | |
| 2451 | + | |
| 2452 | + | |
| 2453 | + | |
| 2454 | + | |
| 2455 | + | |
| 2456 | + | |
| 2457 | + | |
| 2458 | + | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
| 2462 | + | |
| 2463 | + | |
| 2464 | + | |
| 2465 | + | |
| 2466 | + | |
| 2467 | + | |
| 2468 | + | |
| 2469 | + | |
| 2470 | + | |
| 2471 | + | |
| 2472 | + | |
| 2473 | + | |
| 2474 | + | |
| 2475 | + | |
| 2476 | + | |
| 2477 | + | |
| 2478 | + | |
| 2479 | + | |
| 2480 | + | |
| 2481 | + | |
| 2482 | + | |
| 2483 | + | |
| 2484 | + | |
| 2485 | + | |
| 2486 | + | |
| 2487 | + | |
| 2488 | + | |
| 2489 | + | |
| 2490 | + | |
| 2491 | + | |
| 2492 | + | |
| 2493 | + | |
| 2494 | + | |
| 2495 | + | |
| 2496 | + | |
| 2497 | + | |
2430 | 2498 | | |
2431 | 2499 | | |
2432 | 2500 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3127 | 3127 | | |
3128 | 3128 | | |
3129 | 3129 | | |
| 3130 | + | |
| 3131 | + | |
| 3132 | + | |
| 3133 | + | |
| 3134 | + | |
| 3135 | + | |
| 3136 | + | |
| 3137 | + | |
| 3138 | + | |
| 3139 | + | |
| 3140 | + | |
| 3141 | + | |
| 3142 | + | |
| 3143 | + | |
| 3144 | + | |
| 3145 | + | |
| 3146 | + | |
| 3147 | + | |
| 3148 | + | |
| 3149 | + | |
| 3150 | + | |
| 3151 | + | |
| 3152 | + | |
| 3153 | + | |
| 3154 | + | |
| 3155 | + | |
| 3156 | + | |
| 3157 | + | |
| 3158 | + | |
| 3159 | + | |
| 3160 | + | |
| 3161 | + | |
| 3162 | + | |
| 3163 | + | |
| 3164 | + | |
| 3165 | + | |
| 3166 | + | |
| 3167 | + | |
| 3168 | + | |
| 3169 | + | |
| 3170 | + | |
| 3171 | + | |
| 3172 | + | |
| 3173 | + | |
| 3174 | + | |
| 3175 | + | |
| 3176 | + | |
| 3177 | + | |
3130 | 3178 | | |
3131 | 3179 | | |
3132 | 3180 | | |
| |||
3246 | 3294 | | |
3247 | 3295 | | |
3248 | 3296 | | |
| 3297 | + | |
| 3298 | + | |
3249 | 3299 | | |
3250 | 3300 | | |
3251 | 3301 | | |
| |||
0 commit comments