* [PATCH] netfilter: nft_compat: fix sparse warning
@ 2015-02-12 10:14 Arturo Borrero Gonzalez
2015-02-12 12:20 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Arturo Borrero Gonzalez @ 2015-02-12 10:14 UTC (permalink / raw)
To: netfilter-devel; +Cc: pablo
>> net/netfilter/nft_compat.c:140:37: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_compat.c:140:37: expected restricted __be16 [usertype] ethproto
net/netfilter/nft_compat.c:140:37: got unsigned char [unsigned] [usertype] proto
>> net/netfilter/nft_compat.c:351:37: sparse: incorrect type in assignment (different base types)
net/netfilter/nft_compat.c:351:37: expected restricted __be16 [usertype] ethproto
net/netfilter/nft_compat.c:351:37: got unsigned char [unsigned] [usertype] proto
Reported-by: kbuild test robot <fengguang.wu@intel.com>
Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
---
net/netfilter/nft_compat.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
index c598f74..b5dc651 100644
--- a/net/netfilter/nft_compat.c
+++ b/net/netfilter/nft_compat.c
@@ -137,7 +137,7 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
break;
case NFPROTO_BRIDGE:
- entry->ebt.ethproto = proto;
+ entry->ebt.ethproto = (__force __be16)proto;
entry->ebt.invflags = inv ? EBT_IPROTO : 0;
break;
}
@@ -348,7 +348,7 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
break;
case NFPROTO_BRIDGE:
- entry->ebt.ethproto = proto;
+ entry->ebt.ethproto = (__force __be16)proto;
entry->ebt.invflags = inv ? EBT_IPROTO : 0;
break;
}
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nft_compat: fix sparse warning
2015-02-12 10:14 [PATCH] netfilter: nft_compat: fix sparse warning Arturo Borrero Gonzalez
@ 2015-02-12 12:20 ` Pablo Neira Ayuso
2015-02-12 12:25 ` Arturo Borrero Gonzalez
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2015-02-12 12:20 UTC (permalink / raw)
To: Arturo Borrero Gonzalez; +Cc: netfilter-devel
On Thu, Feb 12, 2015 at 11:14:09AM +0100, Arturo Borrero Gonzalez wrote:
> >> net/netfilter/nft_compat.c:140:37: sparse: incorrect type in assignment (different base types)
> net/netfilter/nft_compat.c:140:37: expected restricted __be16 [usertype] ethproto
> net/netfilter/nft_compat.c:140:37: got unsigned char [unsigned] [usertype] proto
> >> net/netfilter/nft_compat.c:351:37: sparse: incorrect type in assignment (different base types)
> net/netfilter/nft_compat.c:351:37: expected restricted __be16 [usertype] ethproto
> net/netfilter/nft_compat.c:351:37: got unsigned char [unsigned] [usertype] proto
This is spotting a more serious problem. The existing code is trimming
the ethernet protocol field to u8. We should use u16 all around the
code and then force the casting to calm down sparse.
> Reported-by: kbuild test robot <fengguang.wu@intel.com>
> Signed-off-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> ---
> net/netfilter/nft_compat.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/net/netfilter/nft_compat.c b/net/netfilter/nft_compat.c
> index c598f74..b5dc651 100644
> --- a/net/netfilter/nft_compat.c
> +++ b/net/netfilter/nft_compat.c
> @@ -137,7 +137,7 @@ nft_target_set_tgchk_param(struct xt_tgchk_param *par,
> entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
> break;
> case NFPROTO_BRIDGE:
> - entry->ebt.ethproto = proto;
> + entry->ebt.ethproto = (__force __be16)proto;
> entry->ebt.invflags = inv ? EBT_IPROTO : 0;
> break;
> }
> @@ -348,7 +348,7 @@ nft_match_set_mtchk_param(struct xt_mtchk_param *par, const struct nft_ctx *ctx,
> entry->e6.ipv6.invflags = inv ? IP6T_INV_PROTO : 0;
> break;
> case NFPROTO_BRIDGE:
> - entry->ebt.ethproto = proto;
> + entry->ebt.ethproto = (__force __be16)proto;
> entry->ebt.invflags = inv ? EBT_IPROTO : 0;
> break;
> }
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nft_compat: fix sparse warning
2015-02-12 12:20 ` Pablo Neira Ayuso
@ 2015-02-12 12:25 ` Arturo Borrero Gonzalez
2015-02-12 13:21 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Arturo Borrero Gonzalez @ 2015-02-12 12:25 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Netfilter Development Mailing list
On 12 February 2015 at 13:20, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> On Thu, Feb 12, 2015 at 11:14:09AM +0100, Arturo Borrero Gonzalez wrote:
>> >> net/netfilter/nft_compat.c:140:37: sparse: incorrect type in assignment (different base types)
>> net/netfilter/nft_compat.c:140:37: expected restricted __be16 [usertype] ethproto
>> net/netfilter/nft_compat.c:140:37: got unsigned char [unsigned] [usertype] proto
>> >> net/netfilter/nft_compat.c:351:37: sparse: incorrect type in assignment (different base types)
>> net/netfilter/nft_compat.c:351:37: expected restricted __be16 [usertype] ethproto
>> net/netfilter/nft_compat.c:351:37: got unsigned char [unsigned] [usertype] proto
>
> This is spotting a more serious problem. The existing code is trimming
> the ethernet protocol field to u8. We should use u16 all around the
> code and then force the casting to calm down sparse.
>
I see, I can handle it if you want.
--
Arturo Borrero González
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nft_compat: fix sparse warning
2015-02-12 12:25 ` Arturo Borrero Gonzalez
@ 2015-02-12 13:21 ` Pablo Neira Ayuso
0 siblings, 0 replies; 4+ messages in thread
From: Pablo Neira Ayuso @ 2015-02-12 13:21 UTC (permalink / raw)
To: Arturo Borrero Gonzalez; +Cc: Netfilter Development Mailing list
On Thu, Feb 12, 2015 at 01:25:57PM +0100, Arturo Borrero Gonzalez wrote:
> On 12 February 2015 at 13:20, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > On Thu, Feb 12, 2015 at 11:14:09AM +0100, Arturo Borrero Gonzalez wrote:
> >> >> net/netfilter/nft_compat.c:140:37: sparse: incorrect type in assignment (different base types)
> >> net/netfilter/nft_compat.c:140:37: expected restricted __be16 [usertype] ethproto
> >> net/netfilter/nft_compat.c:140:37: got unsigned char [unsigned] [usertype] proto
> >> >> net/netfilter/nft_compat.c:351:37: sparse: incorrect type in assignment (different base types)
> >> net/netfilter/nft_compat.c:351:37: expected restricted __be16 [usertype] ethproto
> >> net/netfilter/nft_compat.c:351:37: got unsigned char [unsigned] [usertype] proto
> >
> > This is spotting a more serious problem. The existing code is trimming
> > the ethernet protocol field to u8. We should use u16 all around the
> > code and then force the casting to calm down sparse.
>
> I see, I can handle it if you want.
Please, go ahead. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-02-12 13:18 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-12 10:14 [PATCH] netfilter: nft_compat: fix sparse warning Arturo Borrero Gonzalez
2015-02-12 12:20 ` Pablo Neira Ayuso
2015-02-12 12:25 ` Arturo Borrero Gonzalez
2015-02-12 13:21 ` 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).