Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

livepatch/klp-build: report patch validation fuzz

Capture the output of the patch command to detect when a patch applies
with fuzz or line offsets.

If such "fuzz" is detected during the validation phase, warn the user
and display the details. This helps identify input patches that may
need refreshing against the target source tree.

Ensure that internal patch operations (such as those in refresh_patch or
during the final build phase) can still run quietly.

Signed-off-by: Joe Lawrence <joe.lawrence@redhat.com>
Acked-by: Song Liu <song@kernel.org>
Link: https://patch.msgid.link/20260310203751.1479229-13-joe.lawrence@redhat.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by

Joe Lawrence and committed by
Josh Poimboeuf
51a0b7c4 1fbc9b85

+19 -5
+19 -5
scripts/livepatch/klp-build
··· 360 360 361 361 apply_patch() { 362 362 local patch="$1" 363 + shift 364 + local extra_args=("$@") 365 + local drift_regex="with fuzz|offset [0-9]+ line" 366 + local output 367 + local status 363 368 364 369 [[ ! -f "$patch" ]] && die "$patch doesn't exist" 365 - patch -d "$SRC" -p1 --dry-run --silent --no-backup-if-mismatch -r /dev/null < "$patch" 366 - patch -d "$SRC" -p1 --silent --no-backup-if-mismatch -r /dev/null < "$patch" 370 + status=0 371 + output=$(patch -d "$SRC" -p1 --dry-run --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" < "$patch" 2>&1) || status=$? 372 + if [[ "$status" -ne 0 ]]; then 373 + echo "$output" >&2 374 + die "$patch did not apply" 375 + elif [[ "$output" =~ $drift_regex ]]; then 376 + echo "$output" >&2 377 + warn "${patch} applied with fuzz" 378 + fi 367 379 380 + patch -d "$SRC" -p1 --no-backup-if-mismatch -r /dev/null "${extra_args[@]}" --silent < "$patch" 368 381 APPLIED_PATCHES+=("$patch") 369 382 } 370 383 ··· 396 383 } 397 384 398 385 apply_patches() { 386 + local extra_args=("$@") 399 387 local patch 400 388 401 389 for patch in "${PATCHES[@]}"; do 402 - apply_patch "$patch" 390 + apply_patch "$patch" "${extra_args[@]}" 403 391 done 404 392 } 405 393 ··· 458 444 ( cd "$SRC" && echo "${input_files[@]}" | xargs cp --parents --target-directory="$tmpdir/a" ) 459 445 460 446 # Copy patched source files to 'b' 461 - apply_patch "$patch" 447 + apply_patch "$patch" "--silent" 462 448 ( cd "$SRC" && echo "${output_files[@]}" | xargs cp --parents --target-directory="$tmpdir/b" ) 463 449 revert_patch "$patch" 464 450 ··· 831 817 if (( SHORT_CIRCUIT <= 2 )); then 832 818 status "Fixing patch(es)" 833 819 fix_patches 834 - apply_patches 820 + apply_patches "--silent" 835 821 status "Building patched kernel" 836 822 build_kernel "patched" 837 823 revert_patches