Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incompatible pointer type when building 2.1.2 on Hardkernel 4.9.295, 2.0.7 builds fine. #12952

Open
akschu opened this issue Jan 10, 2022 · 12 comments
Labels
Type: Building Indicates an issue related to building binaries Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@akschu
Copy link

akschu commented Jan 10, 2022

System information

slackware64-current on odroid arm (Amlogic S905X3) based board (slarm64) with this kernel:
https://github.com/hardkernel/linux (branch odroidg12-4.9.y)
with this config:
https://gitlab.com/sndwvs/images_build_kit/-/blob/arm/config/kernel/linux-meson-sm1-legacy.config

openzfs-2.1.2 release
aarch64
kernel 4.9.295
gcc 11.2
glibc 2.33

While compiling the kernel modules I get:

CC [M] /tmp/zfs-2.1.2/module/zfs/../os/linux/zfs/zpl_super.o
/tmp/zfs-2.1.2/module/zfs/../os/linux/zfs/zpl_file.c: In function ‘zpl_readpages’:
/tmp/zfs-2.1.2/module/zfs/../os/linux/zfs/zpl_file.c:654:50: error: passing argument 3 of ‘read_cache_pages’ from incompatible pointer type [-Werror=incompatible-pointer-types]
654 | return (read_cache_pages(mapping, pages, zpl_readpage_filler, NULL));
| ^~~~~~~~~~~~~~~~~~~
| |
| int (*)(void *, struct page )
In file included from ./include/linux/blkdev.h:14,
from /tmp/zfs-2.1.2/include/os/linux/spl/sys/uio.h:30,
from /tmp/zfs-2.1.2/include/os/linux/spl/sys/sunddi.h:28,
from /tmp/zfs-2.1.2/include/sys/zfs_context.h:69,
from /tmp/zfs-2.1.2/include/sys/spa.h:39,
from /tmp/zfs-2.1.2/include/sys/dmu_objset.h:33,
from /tmp/zfs-2.1.2/module/zfs/../os/linux/zfs/zpl_file.c:31:
./include/linux/pagemap.h:367:52: note: expected ‘int (
)(struct file *, struct page )’ but argument is of type ‘int ()(void *, struct page *)’
367 | struct list_head *pages, filler_t *filler, void *data);
| ~~~~~~~~~~^~~~~~
cc1: some warnings being treated as errors

Looks like one var is of type "int (*)(struct file *, struct page )" and the other "int ()(void *, struct page *)"

I tried compiling with CXXFLAGS="-Wno-incompatible-pointer-types" but that doesn't make it compile, if it's even safe to do so.

2.0.7 Builds totally fine.

@akschu akschu added the Type: Defect Incorrect behavior (e.g. crash, hang) label Jan 10, 2022
@akschu akschu changed the title Incompatible pointer type when building 2.1.2 on 4.9.295, 2.0.7 builds fine. Incompatible pointer type when building 2.1.2 on 4.9.295 Jan 10, 2022
@akschu akschu changed the title Incompatible pointer type when building 2.1.2 on 4.9.295 Incompatible pointer type when building 2.1.2 on 4.9.295, 2.0.7 builds fine. Jan 10, 2022
@akschu
Copy link
Author

akschu commented Jan 10, 2022

I changed the title because I wanted to double check that 2.0.7 builds fine, and it does.

@rincebrain
Copy link
Contributor

It seems like 4affa09 sunk your battleship, and since 2.0.x didn't have that commit, it didn't have the issue.

@solbjorn

@akschu
Copy link
Author

akschu commented Jan 10, 2022

It seems like 4affa09 sunk your battleship, and since 2.0.x didn't have that commit, it didn't have the issue.

@solbjorn

Confirmed, patch -R on 4affa09 causes it to build. Any issues with running it like that?

@rincebrain
Copy link
Contributor

AFAIK that patch solely cleaned up some casting that offended ClangCFI, so unless you're planning on building with that, I wouldn't think so.

@solbjorn
Copy link
Contributor

solbjorn commented Jan 11, 2022

@akschu, this is caused by the commit hardkernel/linux@4fd840d of the kernel you use.

Upstream kernel 4.9 has filler_t of the same type as ZFS callback does ([0]), but the "hardkernel" does not: [1].
Since it's effectively impossible to try to support all the kernels from around the world, this ZFS repo aims only upstream version. From this point of view, it's the users of custom kernels who should fix such by themselves.
OTOH, this issue can relatively easily be fixed by adding a configure-time check for filler_t type. Since Sami changed its type in the "hardkernel" exactly for the purpose of ClangCFI, and the ZFS part would look even simpler on it (no need for splitting zpl_readpage() into two callbacks), I could do this.

@rincebrain, @behlendorf, what do you guys think? Is it fine to add a bit of code to ZFS to support third-party kernels?

If so, I need a couple days to dissect some free time slice for this.
And I think it's better to change the title to mention the "hardkernel".

[0] https://elixir.bootlin.com/linux/v4.9.296/source/include/linux/pagemap.h#L228
[1] https://github.com/hardkernel/linux/blob/odroidg12-4.9.y/include/linux/pagemap.h#L228

@rincebrain
Copy link
Contributor

Doesn't seem any stranger than grsec compat fixes or distro-specific fixes, to me, but I'm not the one anyone needs to convince. :)

(Also, the commit message on hardkernel/linux@4fd840d seems to be originally from a very different patch, to the AES code, so...that seems wrong.)

@akschu akschu changed the title Incompatible pointer type when building 2.1.2 on 4.9.295, 2.0.7 builds fine. Incompatible pointer type when building 2.1.2 on Hardkernel 4.9.295, 2.0.7 builds fine. Jan 11, 2022
@Tony763
Copy link

Tony763 commented May 7, 2022

error: passing argument 3 of ‘read_cache_pages’ from incompatible pointer type [-Werror=incompatible-pointer-types]
  return (read_cache_pages(mapping, pages, zpl_readpage_filler, NULL));

For me, happen on Jetson Nano 4.4 with 2.1.4

@rincebrain
Copy link
Contributor

rincebrain commented May 7, 2022

Mayhap 23c13c7 could make your life nicer?

e: hm, no, that's in 2.1.4.

Curious. Do you have a pointer to the kernel tree the Jetson Nano is running on?

e2: oh lovely, they changed the function signature. (Assuming NVIDIA did the same thing, at least - the L4T sources I found for 5.10 don't have such a change.)

One could imagine a configure-time check that swaps zpl_readpage_filler with zpl_readpage if it detects this case.

@Tony763
Copy link

Tony763 commented May 7, 2022

Jetpack 4.4 run 4.9.140-tegra.

@rincebrain
Copy link
Contributor

@Tony763
Copy link

Tony763 commented May 7, 2022

l4t-r32.6 is jetpack 4.6 which is sadly not available for my carrier board. I will stick with version 2.0.7

@stale
Copy link

stale bot commented May 8, 2023

This issue has been automatically marked as "stale" because it has not had any activity for a while. It will be closed in 90 days if no further activity occurs. Thank you for your contributions.

@stale stale bot added the Status: Stale No recent activity for issue label May 8, 2023
@behlendorf behlendorf added Type: Building Indicates an issue related to building binaries and removed Status: Stale No recent activity for issue labels May 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Building Indicates an issue related to building binaries Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

No branches or pull requests

5 participants