binder: fix missing prototype for zap_page_range_single#28
Open
PEKKA1117 wants to merge 1 commit into
Open
Conversation
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.
There was a problem hiding this comment.
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 tobinder/deps.h. - Include
deps.hfrombinder/binder_alloc.cso 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 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); |
choff
reviewed
Jun 21, 2026
| // SPDX-License-Identifier: GPL-2.0 | ||
|
|
||
| #include <linux/ipc_namespace.h> | ||
| #include <linux/mm.h> |
Owner
There was a problem hiding this comment.
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..?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Building
binderfails on recent kernels (e.g. 7.1.1) with newer Clang toolchains:Root cause
deps.cimplementszap_page_range_single()as a runtime compat shim (resolved viakallsyms_lookup_name) for kernels where it isn't available as a normal export. However:deps.hnever declares a prototype for it (onlyget_init_ipc_ns_ptr()is declared).binder_alloc.c, which callszap_page_range_single(), does not#include "deps.h".So when
binder_alloc.cis compiled, the compiler has no declaration ofzap_page_range_singlein 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
zap_page_range_single()indeps.h.#include "deps.h"frombinder_alloc.c.Testing
Built
binder/standalone against kernel 7.1.1-2 headers withclang+ld.lld:binder_alloc.owith the implicit-declaration error above.binder_alloc.ocompiles cleanly andbinder_linux.kolinks and builds successfully end to end.