* nftables batch abi broken ...
@ 2015-08-27 15:31 Florian Westphal
2015-08-27 16:46 ` Pablo Neira Ayuso
0 siblings, 1 reply; 2+ messages in thread
From: Florian Westphal @ 2015-08-27 15:31 UTC (permalink / raw)
To: netfilter-devel
Hi.
batch handling in libnftnl uses this:
libnftnl/src/common.c: nfg->res_id = NFNL_SUBSYS_NFTABLES;
It SHOULD be:
libnftnl/src/common.c: nfg->res_id = htons(NFNL_SUBSYS_NFTABLES)
since res_id is a __be16.
The kernel contains the same error when decoding batch messages
which is why this works :-/
I found this problem when looking at sparse error reports on the kernel
where sparse complains about the following line in nfnetlink_rcv():
nfnetlink_rcv_batch(skb, nlh, nfgenmsg->res_id);
and sparse complaint is correct, __be16 is treated as u16 without
conversion.
How to fix this?
If we want to maintain ABI on Little Endian only solution is to "fix"
it in kernel by annotating this with explicit cast to u16.
But it sucks since ->res_id is used via htons/ntohs in all other places
:-/
Any ideas?
Fix userspace and play 'guess todays endianess' in the kernel...?
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: nftables batch abi broken ...
2015-08-27 15:31 nftables batch abi broken Florian Westphal
@ 2015-08-27 16:46 ` Pablo Neira Ayuso
0 siblings, 0 replies; 2+ messages in thread
From: Pablo Neira Ayuso @ 2015-08-27 16:46 UTC (permalink / raw)
To: Florian Westphal; +Cc: netfilter-devel
On Thu, Aug 27, 2015 at 05:31:51PM +0200, Florian Westphal wrote:
> Hi.
>
> batch handling in libnftnl uses this:
> libnftnl/src/common.c: nfg->res_id = NFNL_SUBSYS_NFTABLES;
>
> It SHOULD be:
> libnftnl/src/common.c: nfg->res_id = htons(NFNL_SUBSYS_NFTABLES)
>
> since res_id is a __be16.
>
> The kernel contains the same error when decoding batch messages
> which is why this works :-/
>
> I found this problem when looking at sparse error reports on the kernel
> where sparse complains about the following line in nfnetlink_rcv():
>
> nfnetlink_rcv_batch(skb, nlh, nfgenmsg->res_id);
>
> and sparse complaint is correct, __be16 is treated as u16 without
> conversion.
>
> How to fix this?
> If we want to maintain ABI on Little Endian only solution is to "fix"
> it in kernel by annotating this with explicit cast to u16.
>
> But it sucks since ->res_id is used via htons/ntohs in all other places
> :-/
>
> Any ideas?
We only have one subsystem that supports batching at this moment, ie.
nft, so we can add a workaround now, fix userspace and then drop the
workaround from the kernel at some point.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-08-27 16:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-27 15:31 nftables batch abi broken Florian Westphal
2015-08-27 16:46 ` Pablo Neira Ayuso
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).