Skip to content

binder: fix missing prototype for zap_page_range_single#28

Open
PEKKA1117 wants to merge 1 commit into
choff:masterfrom
PEKKA1117:fix/zap_page_range_single-implicit-decl
Open

binder: fix missing prototype for zap_page_range_single#28
PEKKA1117 wants to merge 1 commit into
choff:masterfrom
PEKKA1117:fix/zap_page_range_single-implicit-decl

Conversation

@PEKKA1117

Copy link
Copy Markdown

Problem

Building binder fails on recent kernels (e.g. 7.1.1) with newer Clang toolchains:

binder_alloc.c:1029:3: error: call to undeclared function 'zap_page_range_single';
ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]

Root cause

deps.c implements zap_page_range_single() as a runtime compat shim (resolved via kallsyms_lookup_name) for kernels where it isn't available as a normal export. However:

  • deps.h never declares a prototype for it (only get_init_ipc_ns_ptr() is declared).
  • binder_alloc.c, which calls zap_page_range_single(), does not #include "deps.h".

So when binder_alloc.c is compiled, the compiler has no declaration of zap_page_range_single in scope. Older compilers treated this as a warning; newer Clang (and GCC in C99+ mode) treats implicit function declarations as a hard error, breaking the build.

Fix

  • Declare the prototype for zap_page_range_single() in deps.h.
  • #include "deps.h" from binder_alloc.c.

Testing

Built binder/ standalone against kernel 7.1.1-2 headers with clang + ld.lld:

  • Before the fix: fails at binder_alloc.o with the implicit-declaration error above.
  • After the fix: binder_alloc.o compiles cleanly and binder_linux.ko links and builds successfully end to end.

deps.c implements zap_page_range_single() as a runtime compat shim
(resolved via kallsyms_lookup_name), but deps.h never declared its
prototype, and binder_alloc.c did not include deps.h. Newer compilers
(Clang, building with -std=gnu11 and later defaults) treat an
implicit function declaration as a hard error rather than a warning,
so the module fails to build:

  binder_alloc.c:1029:3: error: call to undeclared function
  'zap_page_range_single'; ISO C99 and later do not support implicit
  function declarations [-Wimplicit-function-declaration]

Declare the prototype in deps.h and include it from binder_alloc.c.

Verified the module builds and links cleanly (binder_linux.ko) against
kernel 7.1.1 with the fix applied; previously failed with the error
above.
Copilot AI review requested due to automatic review settings June 21, 2026 07:21

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes a build failure in the out-of-tree binder module on newer kernels/toolchains by ensuring zap_page_range_single() is properly declared and visible to the compilation unit that calls it.

Changes:

  • Add a zap_page_range_single() prototype to binder/deps.h.
  • Include deps.h from binder/binder_alloc.c so the caller has the declaration in scope.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
binder/deps.h Adds the missing declaration for the compat shim used to unmap user pages on newer kernels.
binder/binder_alloc.c Includes deps.h so zap_page_range_single() is declared when compiling binder_alloc.c.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread binder/deps.h
Comment on lines 1 to +8
// SPDX-License-Identifier: GPL-2.0

#include <linux/ipc_namespace.h>
#include <linux/mm.h>

struct ipc_namespace* get_init_ipc_ns_ptr(void);
void zap_page_range_single(struct vm_area_struct *vma, unsigned long address,
unsigned long size, struct zap_details *details);
Comment thread binder/deps.h
// SPDX-License-Identifier: GPL-2.0

#include <linux/ipc_namespace.h>
#include <linux/mm.h>

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Thanks for your fix :-)

Is there a reason why you need to include linux/mm.h..? Wouldn't it be sufficient to only add the function prototype below..?

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