Skip to content

lkl: clean up discard rules for fuzzing builds - #653

Open
clingfei wants to merge 1 commit into
lkl:masterfrom
clingfei:cleanup-fuzzing-discards
Open

clingfei wants to merge 1 commit into
lkl:masterfrom
clingfei:cleanup-fuzzing-discards

Conversation

@clingfei

Copy link
Copy Markdown

Move the explicit /DISCARD/ block into the CONFIG_LKL_FUZZING branch to avoid duplicating the .export_symbol discard rule in non-fuzzing builds.

Also discard .discard, .discard., .modinfo and .gnu.version in fuzzing builds while preserving sanitizer sections such as .init_array and .eh_frame.

Following #648.

@github-actions

github-actions Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Test Results

106 files  ±0  106 suites  ±0   7m 37s ⏱️ +15s
206 tests ±0  195 ✅ ±0  11 💤 ±0  0 ❌ ±0 
790 runs  ±0  734 ✅ ±0  56 💤 ±0  0 ❌ ±0 

Results for commit 6b5c644. ± Comparison against base commit 2ab931f.

♻️ This comment has been updated with latest results.

@tavip

tavip commented Nov 30, 2026

Copy link
Copy Markdown
Member

Thanks for the cleanup! Could you rebase this on top of master now that the 6.18 merge (#632) is in?

Two things changed in 6.18 that affect this patch:

  1. Upstream removed *(.modinfo) from COMMON_DISCARDS (commit 3e86e4d74c04), so *(.modinfo) now needs to stay discarded in non-fuzzing builds as well (see d66417bf9cfc).
  2. Upstream added *(.no_trim_symbol) to COMMON_DISCARDS. To avoid duplicating COMMON_DISCARDS and drifting on future kernel updates, what do you think about reusing COMMON_DISCARDS directly with SANITIZER_DISCARDS undefined for fuzzing? (Note: the snippet below is untested.)
	/DISCARD/ : {
		*(.modinfo)
#if !defined(CONFIG_LKL_FUZZING)
		EXIT_DISCARDS
		EXIT_CALL
#else
		/* Preserve sanitizer sections needed for fuzzing. */
#undef SANITIZER_DISCARDS
#define SANITIZER_DISCARDS
#endif
		COMMON_DISCARDS
	}

Reuse COMMON_DISCARDS in both build modes, with SANITIZER_DISCARDS
redefined to empty for fuzzing to preserve sanitizer sections. This
also picks up .no_trim_symbol and future updates to the common rules.

Keep .modinfo explicitly discarded in both modes now that it is no
longer part of COMMON_DISCARDS.

Signed-off-by: Cheng Lingfei <chenglingfei@foxmail.com>
@clingfei
clingfei force-pushed the cleanup-fuzzing-discards branch from 7c23547 to 6b5c644 Compare December 1, 2026 02:17
@clingfei

clingfei commented Dec 1, 2026

Copy link
Copy Markdown
Author

Thanks for the cleanup! Could you rebase this on top of master now that the 6.18 merge (#632) is in?

Two things changed in 6.18 that affect this patch:

  1. Upstream removed *(.modinfo) from COMMON_DISCARDS (commit 3e86e4d74c04), so *(.modinfo) now needs to stay discarded in non-fuzzing builds as well (see d66417bf9cfc).
  2. Upstream added *(.no_trim_symbol) to COMMON_DISCARDS. To avoid duplicating COMMON_DISCARDS and drifting on future kernel updates, what do you think about reusing COMMON_DISCARDS directly with SANITIZER_DISCARDS undefined for fuzzing? (Note: the snippet below is untested.)
	/DISCARD/ : {
		*(.modinfo)
#if !defined(CONFIG_LKL_FUZZING)
		EXIT_DISCARDS
		EXIT_CALL
#else
		/* Preserve sanitizer sections needed for fuzzing. */
#undef SANITIZER_DISCARDS
#define SANITIZER_DISCARDS
#endif
		COMMON_DISCARDS
	}

Done. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants