Syzkaller PPDEV Syzlang Support
When to Use
- Write syzlang device descriptions for ppdev
- Create syzkaller system call descriptions
- Define ioctl interfaces for /dev/parport*
Required Files
/opt/syzkaller/sys/linux/dev_ppdev.txt- syzlang descriptions/opt/syzkaller/sys/linux/dev_ppdev.txt.const- constant values
Workflow
- Read the full authoritative headers before writing anything: inspect
linux/ppdev.hand any needed related definitions fromlinux/parport.h. - Make a checklist of every ppdev ioctl, its ioctl number macro, argument type, and direction (
_IO,_IOR,_IOW,_IOWR).
2a. Read enough of linux/ppdev.h and linux/parport.h to cover the complete relevant definitions before encoding anything; if a tool output is truncated, paged, or clipped, continue reading the remainder instead of extrapolating from the opening lines.
2b. Mark which ioctls use size-sensitive argument types (especially any timeval-based commands), because their encoded constants may differ across amd64 and 386.
- Treat kernel headers as the source of truth for ioctl names, numbers, flags, and structs; do not guess, hand-invent, or add interfaces not verified in headers.
- Before creating either file, inspect a nearby syzkaller device description and its
.constcompanion in/opt/syzkaller/sys/linux/to copy repository-local formatting exactly.
4a. Reuse nearby sys/linux/dev_*.txt and matching .const files as syntax/schema references for resource names, syz_open_dev specialization style, ioctl declaration shape, pointer payload modeling, .const layout, and supported per-arch override syntax; keep ppdev-specific names, numbers, and argument meanings derived from the headers.
4b. While inspecting nearby files, also check whether common structs or helper types are already defined globally (for example in sys.txt) before declaring them locally; reuse shared definitions instead of duplicating standard types such as timeval.
4c. When a header-referenced value domain is not exposed as named userspace/UAPI constants, model it with the simplest validated numeric type or range instead of inventing unavailable symbolic flags or enums.
- Only then write
dev_ppdev.txtanddev_ppdev.txt.const. - Before writing, confirm the minimal modeled surface matches the headers: required includes,
fd_ppdev,syz_open_dev$ppdev("/dev/parport#", 0, 0), each ioctl name/number family, and each argument direction. - Prefer writing each target file in one shot (for example with a single-quoted heredoc or another atomic write method) instead of long chains of incremental appends.
- Prefer compiling a tiny C helper against the local headers to print ppdev/parport ioctl and flag values for
.const; use that output to populate or cross-check constants instead of deriving encodings by hand. - As soon as both files are written, run
make descriptionsfirst to catch syntax/schema issues before the slower full build. - Immediately reopen both final files from
/opt/syzkaller/sys/linux/and inspect the saved contents before any full build step; treat the on-disk files as authoritative over the intended payload. - If writing directly into
/opt/syzkaller/sys/linux/is awkward, stage the files in a writable location, verify them there, then copy them into the final paths and reread the final saved copies. - If readback shows truncation, malformed syntax, shell-quoting damage, wrong formatting, or a partial rewrite, fix that first and reread the saved files before continuing.
- Keep a one-to-one mapping between the header-derived ppdev ioctl checklist and the syzlang ioctl declarations unless the task explicitly asks for extra variants; do not add alias/duplicate ioctl entries just to satisfy parser or unused-type complaints.
- Do not claim coverage counts such as "all 23 ioctls" until you have extracted the complete ioctl list from the full untruncated headers and checked each entry off explicitly.
dev_ppdev.txt Content
include <linux/ppdev.h>
include <linux/parport.h>
resource fd_ppdev[fd]
syz_open_dev/dev/parport# -> fd_ppdev
ioctl ppdev_ioc... (23 total)
ppdev_frob_struct { mask, val }
IEEE1284 mode flags + ppdev flags
- Use a normal syzlang specialization name for the opener, e.g.
syz_open_dev$ppdev("/dev/parport#", 0, 0) fd_ppdev. - Prefer a single-quoted heredoc (
cat <<'EOF') or another write method that preserves$literally; do not introduce shell-quoting artifacts into the file content. - After writing
dev_ppdev.txt, immediately read back the exactsyz_open_dev$ppdev(...)line and several ioctl declarations from disk before any build step. If the opener name,$, quotes, or parentheses differ from what you intended, rewrite the file first and only then continue. - First derive the full ioctl list from
linux/ppdev.h, then match the task scope exactly: include all 23 ioctls when full header coverage is requested, and exclude entries only when the task explicitly asks for a narrower set. - Verify ioctl names, structs, and argument directions from the full untruncated contents of
linux/ppdev.handlinux/parport.hbefore finalizing. - Assign ioctl argument types only from the exact header definitions/macros. Do not upgrade an argument to flags, mode, phase, status, or another semantic domain based only on the ioctl name or nearby comments.
- Map syzlang argument handling directly from the ioctl macro kind in
linux/ppdev.h:_IOmeans no argument,_IORuses output-oriented pointer modeling,_IOWuses input-oriented pointer modeling, and_IOWRrequires validated mixed-direction handling consistent with nearby syzkaller examples. - For each ioctl, keep read-style commands, write-style commands, and no-arg commands distinct based on the exact header macro usage and argument type rather than the ioctl name alone.
- Reuse existing syzkaller common type definitions when available; do not redeclare shared structs already provided elsewhere in
sys/linux/unless the ppdev headers require a distinct layout. - If
make descriptionsreports a syntax/schema issue, fix that exact declaration first and rerunmake descriptionsbefore attemptingmake all.
dev_ppdev.txt.const
arches = amd64, 386
ioctl numbers and flag values
- Write the first line exactly as
arches = amd64, 386. - Before creating this file, inspect an existing
sys/linux/*.txt.constexample and copy its header/comment style exactly; do not rely on memory for.constfile syntax.
- Do not prefix that line with
#or any other comment marker. - Populate constants from kernel headers or the syzkaller extraction/generation flow.
- Do not hand-compute ioctl numbers or flag values unless you verify them against a trustworthy extracted or build-produced result.
- Generate or validate constants in an architecture-aware way; do not copy amd64 values to 386 (or vice versa) by assumption.
- When one
.constfile covers multiple architectures, verify and use syzkaller's supported per-arch entry syntax from nearby.constfiles instead of forcing one shared value across both arches. - Pay special attention to ioctls whose encoded size depends on argument layout; for ppdev,
PPGETTIMEandPPSETTIMErequire explicit per-arch validation becausestruct timevalsize can differ betweenamd64and386. - When a constant differs by architecture, encode explicit per-arch values in
.constinstead of copying one arch's number to the other.
- If any ioctl value depends on structure layout or encoded size bits, treat manual arithmetic as unsafe.
- For a multi-arch
.constfile, obtain or validate values for each listed arch from extraction, generated output, build products, or another direct evidence source; do not reuse values derived from one ABI for another by assumption. - Prefer a small compiled helper/extractor that includes
linux/ppdev.handlinux/parport.hand prints the needed ioctl and flag macros for each listed architecture. - If a first extraction attempt fails because ppdev ioctls are function-like macros, change the extraction method so the compiler/preprocessor evaluates the real header definitions; prefer a tiny C helper or another direct header-driven extraction path over hand-written
_IO*reconstruction. - If extraction/build-backed validation fails, debug that specific failure first and preserve the diagnostic; do not fall back to handwritten ioctl-encoding scripts, guessed completions, or visibly truncated numeric output.
- If extraction, helper scripts, or ad hoc computations produce truncated, inconsistent, incomplete, or suspicious results, do not populate
.constfrom them yet; rerun or use another trustworthy extraction path until every referenced constant is fully validated for each listed arch. - Do not fill
.constby hand from_IOCmath, guessed struct sizes, or one-arch assumptions when386andamd64are both required.
- After writing the file, read back the first few lines and confirm the
arches = ...header is present verbatim. - Then inspect the full saved
.constfile, not just the header, to confirm no write truncation, cut-off numeric values, or partial constant list made it to disk.
- Include only constants actually referenced by
dev_ppdev.txtplus any explicitly requested ppdev/IEEE1284 flag set; do not pad the file with guessed extras. - Keep the
.constfile limited to values you can validate from headers, helper output, or trusted extraction/build-produced results; compare naming, ordering, and metadata conventions against nearby.constfiles, including whether__NR_ioctlis present. - Include syscall-number constants only for real syscalls referenced by the description; do not add a
__NR_*entry for the pseudo-callsyz_open_dev. - After
make descriptions, reopen the saved.constfile from disk and inspect enough of it to confirm the regenerated final file still contains the expected arch header and full ppdev constant set.
Verification Commands
cd /opt/syzkaller
make descriptions
make all TARGETOS=linux TARGETARCH=amd64
Run these only after reading back the generated files and confirming they are complete.
Do not stop at build success: semantic verification against the full headers is still required.
- Run
make descriptionsfirst and use its parser/type errors to drive the smallest syntax fix before attempting the full build. - Execute the required verification commands exactly as written; do not substitute
grep,syz-sysgen,make extract, ad hoc scripts, or other partial proxies unless the task explicitly asks for them. - Do not background
make all, stop it early, or infer success from partial/truncated output. Wait for completion and confirm a clear success signal such as exit status 0. - If the environment or tooling blocks the required commands, treat the task as unresolved until you either fix that issue or clearly report the exact blocking error.
- Run both commands to completion and do not claim success unless you directly observe clear completion for both commands, preferably explicit exit status
0plus output consistent with completion. - Do not infer success from partial output, dependency-download noise, silence, unrelated shell messages, piped/wrapper-truncated logs, or still-running output; if the result is ambiguous, rerun the exact command or a narrower targeted check with explicit status reporting until completion is observable.
- Before and after running builds, reopen
/opt/syzkaller/sys/linux/dev_ppdev.txtand/opt/syzkaller/sys/linux/dev_ppdev.txt.constfrom their final paths and inspect the exact saved contents, including enough of each file to catch truncation rather than only spot-checking the top. - Treat
make descriptionsandmake allas necessary but not sufficient: after they pass, reconcile the final ioctl list againstlinux/ppdev.h, confirm argument directions match the header definitions, and ensure every constant referenced indev_ppdev.txtis defined in.constfor each listed arch. - If either command fails, treat the task as unverified: quote the relevant diagnostic, make the smallest targeted fix, and rerun verification instead of guessing.
- Treat direct file inspection as higher-priority evidence than a passing build. If readback, counts, or grep output suggests truncation, missing ioctls, malformed lines, or contradictory signals, stop and resolve that from the saved files before any success claim.
- On the first failure, stop and inspect the exact parser/compiler/build diagnostic before editing any file. Base each fix on an observed error, make the smallest targeted change, and rerun the relevant verification step instead of speculative trial-and-error rewrites.
- Do not treat build success, partial logs, or exit status alone as proof that the ppdev description is correct. After the commands pass, perform a semantic audit from the final on-disk files back to
linux/ppdev.h. - Treat final verification as a three-part check: (1) headers-to-syzlang audit, (2) saved-file readback from disk at the final paths, and (3) successful execution of the required repository build commands.
- Before declaring success, explicitly verify from the final saved files that every claimed ppdev ioctl came from
linux/ppdev.h, that no extra unchecked interface was added, that the final ioctl count matches the header-derived checklist for the task scope, and that every constant referenced indev_ppdev.txtis defined in.constfor each listed arch. - In the final audit, explicitly confirm the opener/resource pair is present, ioctl directions still match the
_IO*forms fromlinux/ppdev.h, and every constant referenced indev_ppdev.txtis defined in.constfor each listed arch. - During final constant audit, pay extra attention to ioctl constants whose encoded size depends on struct layout; confirm any such entries, especially
PPGETTIMEandPPSETTIME, have the correct per-arch values rather than assumed identical ones. - During final audit, keep
.constminimal and relevant: syscall constants should cover only actual syscalls used by the description. - If
make descriptionsrewrites generated files, treat the post-generation on-disk contents as authoritative for final inspection; reread the full relevant ppdev sections rather than assuming the pre-build version survived unchanged.
Tips
- Check the complete
linux/ppdev.hand relevantlinux/parport.hdefinitions, not just the opening portion. - Correct in/out arg directions.
- Match ioctl numbers from validated header-derived or build-produced constants, not manual reconstruction.
- Use kernel headers for the interface surface and nearby
sys/linux/*.txtfiles for syzlang idioms; rely on both rather than either one alone. - For
.constgeneration, prefer a tiny compiled helper/extractor over manual_IO,_IOR,_IOW, or_IOWRmacro expansion, especially for ABI- or struct-size-sensitive values. - If symbolic names are unavailable in exported UAPI headers, encode the validated numeric type or range directly instead of inventing unsupported symbols.
- When a requested flag set or constant group is initially hard to find, keep tracing authoritative headers or generated constants until you either model it correctly or can state precisely what remains unresolved; do not silently widen the argument to a generic integer just to finish.
- Prefer an explicit unresolved note over a guessed or weakened ABI description when the header-backed representation is still unverified.
- If direct edits in
/opt/syzkaller/sys/linux/are inconvenient, write under a writable directory, then copy into place and reread the final files from/opt/syzkaller/sys/linux/before building.
- Include all ppdev ioctls from
linux/ppdev.h(23 total) when full coverage is requested, even commonly missed obsolete entries such asPPWSTATUS,PPRFIFO,PPWFIFO,PPRECONTROL, andPPWECONTROL. - Derive ioctl argument types and directions from the exact header macros; do not infer semantics from ioctl names, comments, or memory.
- Keep related concepts distinct exactly as defined by headers (for example, phase vs mode vs flags vs status); do not substitute one domain for another without explicit header evidence.
- Do not hand-reconstruct ioctl encodings, flag values, widths, enums, or struct-sensitive ABI values if authoritative extraction or direct header validation is possible.
- If extraction or build tooling fails, investigate the specific error or missing macro handling rather than approximating values manually.
- Debug from observed diagnostics only: inspect the actual
make descriptionsormake allerror output, then apply the minimal targeted change tied to that error. - Cross-check representation choices against nearby syzkaller
sys/linux/*.txtfiles when the headers define the interface but not the syzlang idiom. - Before finishing, do a header-to-syzlang audit: verify
syz_open_devtargets/dev/parport#,fd_ppdevis defined,ppdev_frob_structis present, ioctl coverage matches the header-derived checklist, and constants match validated header values.
Final Audit Before Responding
- Re-open the saved
dev_ppdev.txtanddev_ppdev.txt.constfrom disk. - Reconcile the ioctl checklist against
linux/ppdev.h: names, count, argument type, and direction for every requested ioctl. - Confirm every constant referenced in
dev_ppdev.txtis defined in.constfor each listed arch, and that.constdoes not rely on unchecked arch assumptions. - Confirm any claimed verification step has explicit observed success evidence; if not, rerun before answering.