Skip to content

Enable compiler warnings and fix format string security issues#4

Open
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/review-compile-security-dWUOg
Open

Enable compiler warnings and fix format string security issues#4
assisted-by-ai wants to merge 1 commit intoKicksecure:masterfrom
assisted-by-ai:claude/review-compile-security-dWUOg

Conversation

@assisted-by-ai
Copy link
Copy Markdown

Summary

This PR enhances code quality by enabling strict compiler warnings in the kernel module build and fixes format string security issues in the _s_out() function.

Key Changes

  • Makefile: Added comprehensive compiler warning flags:

    • -Wall -Wextra: Enable all common warnings
    • -Werror: Treat warnings as errors to enforce compliance
    • -Wformat -Wformat-security -Wformat-nonliteral: Format string security checks
    • -Wno-unused-parameter: Suppress unused parameter warnings for cleaner output
  • tirdad.c: Fixed format string security issues:

    • Added __printf(2, 3) attribute to _s_out() function declaration for compiler format checking
    • Changed fmt parameter from char * to const char * in both declaration and definition to properly indicate the format string is not modified

Implementation Details

The __printf(2, 3) attribute tells the compiler to validate the format string (2nd parameter) and variadic arguments (starting from 3rd parameter) using printf-style format checking rules. This helps catch format string vulnerabilities and mismatches at compile time. The const qualifier on the format string parameter is the correct practice for variadic functions that don't modify the format string.

https://claude.ai/code/session_01TGuvnh5mbFAcuVWNxMcuKP

Copy link
Copy Markdown

@ArrayBolt3 ArrayBolt3 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rejected. Comments below.

module/tirdad.c Outdated
Comment on lines +26 to +32
void _s_out(u8 err, char *fmt, ...);
__printf(2, 3) void _s_out(u8 err, const char *fmt, ...);

int hook_init(void);
void hook_exit(void);


void _s_out(u8 err, char *fmt, ...){
void _s_out(u8 err, const char *fmt, ...){
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

module/Makefile Outdated
Comment on lines +2 to +9

ccflags-y += -Wall
ccflags-y += -Wextra
ccflags-y += -Werror
ccflags-y += -Wformat
ccflags-y += -Wformat-security
ccflags-y += -Wformat-nonliteral
ccflags-y += -Wno-unused-parameter
Copy link
Copy Markdown

@ArrayBolt3 ArrayBolt3 Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Linux kernel already sets appropriate compiler warning flags in its build infrastructure (which AIUI applies to modules as well). We should not be setting our own flags. (Kernel module developers might use make KCFLAGS=-W to enable verbose warnings at development time, according to the kernel's Documentation/process/4.Coding.rst file.)

adrelanos pushed a commit that referenced this pull request Apr 10, 2026
Add AGENTS.md with project context and upstream PR notes
Add documentation of the rejected compiler warning flags PR (#4)
so future agents don't re-propose hardcoding ccflags-y in the
module Makefile. Kbuild already handles warning flags for modules.

https://claude.ai/code/session_01TGuvnh5mbFAcuVWNxMcuKP
@assisted-by-ai assisted-by-ai force-pushed the claude/review-compile-security-dWUOg branch from d7474fd to e1cc04e Compare April 10, 2026 10:39
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.

3 participants