* [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes
@ 2016-08-09 18:46 Laura Garcia Liebana
2016-08-10 10:57 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Laura Garcia Liebana @ 2016-08-09 18:46 UTC (permalink / raw)
To: netfilter-devel
Fix the direct assignment of offset and length attributes included in
nft_exthdr structure from u32 data to u8.
Signed-off-by: Laura Garcia Liebana <nevola@gmail.com>
---
net/netfilter/nft_exthdr.c | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/net/netfilter/nft_exthdr.c b/net/netfilter/nft_exthdr.c
index ba7aed1..dec3c36 100644
--- a/net/netfilter/nft_exthdr.c
+++ b/net/netfilter/nft_exthdr.c
@@ -59,6 +59,7 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
const struct nlattr * const tb[])
{
struct nft_exthdr *priv = nft_expr_priv(expr);
+ u32 offset, len;
if (tb[NFTA_EXTHDR_DREG] == NULL ||
tb[NFTA_EXTHDR_TYPE] == NULL ||
@@ -67,8 +68,16 @@ static int nft_exthdr_init(const struct nft_ctx *ctx,
return -EINVAL;
priv->type = nla_get_u8(tb[NFTA_EXTHDR_TYPE]);
- priv->offset = ntohl(nla_get_be32(tb[NFTA_EXTHDR_OFFSET]));
- priv->len = ntohl(nla_get_be32(tb[NFTA_EXTHDR_LEN]));
+
+ offset = ntohl(nla_get_be32(tb[NFTA_EXTHDR_OFFSET]));
+ len = ntohl(nla_get_be32(tb[NFTA_EXTHDR_LEN]));
+
+ if (offset > U8_MAX || len > U8_MAX)
+ return -EINVAL;
+
+ priv->offset = offset;
+ priv->len = len;
+
priv->dreg = nft_parse_register(tb[NFTA_EXTHDR_DREG]);
return nft_validate_register_store(ctx, priv->dreg, NULL,
--
2.8.1
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes
2016-08-09 18:46 [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes Laura Garcia Liebana
@ 2016-08-10 10:57 ` Pablo Neira Ayuso
2016-08-10 10:58 ` Pablo Neira Ayuso
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-10 10:57 UTC (permalink / raw)
To: Laura Garcia Liebana; +Cc: netfilter-devel
On Tue, Aug 09, 2016 at 08:46:16PM +0200, Laura Garcia Liebana wrote:
> Fix the direct assignment of offset and length attributes included in
> nft_exthdr structure from u32 data to u8.
Applied to my nf tree, I just made a minor edition on this patch.
Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes
2016-08-10 10:57 ` Pablo Neira Ayuso
@ 2016-08-10 10:58 ` Pablo Neira Ayuso
2016-08-10 11:00 ` Laura Garcia
0 siblings, 1 reply; 4+ messages in thread
From: Pablo Neira Ayuso @ 2016-08-10 10:58 UTC (permalink / raw)
To: Laura Garcia Liebana; +Cc: netfilter-devel
On Wed, Aug 10, 2016 at 12:57:45PM +0200, Pablo Neira Ayuso wrote:
> On Tue, Aug 09, 2016 at 08:46:16PM +0200, Laura Garcia Liebana wrote:
> > Fix the direct assignment of offset and length attributes included in
> > nft_exthdr structure from u32 data to u8.
>
> Applied to my nf tree, I just made a minor edition on this patch.
It would be good to search for similar issues in other existing
expressions, BTW. Let me know if you can take care of it. Thanks.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes
2016-08-10 10:58 ` Pablo Neira Ayuso
@ 2016-08-10 11:00 ` Laura Garcia
0 siblings, 0 replies; 4+ messages in thread
From: Laura Garcia @ 2016-08-10 11:00 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: netfilter-devel
On Wed, Aug 10, 2016 at 12:58:38PM +0200, Pablo Neira Ayuso wrote:
> On Wed, Aug 10, 2016 at 12:57:45PM +0200, Pablo Neira Ayuso wrote:
> > On Tue, Aug 09, 2016 at 08:46:16PM +0200, Laura Garcia Liebana wrote:
> > > Fix the direct assignment of offset and length attributes included in
> > > nft_exthdr structure from u32 data to u8.
> >
> > Applied to my nf tree, I just made a minor edition on this patch.
>
> It would be good to search for similar issues in other existing
> expressions, BTW. Let me know if you can take care of it. Thanks.
Sure, count on it.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-08-10 19:58 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-09 18:46 [PATCH] netfilter: nf_tables: Add size check on u8 nft_exthdr attributes Laura Garcia Liebana
2016-08-10 10:57 ` Pablo Neira Ayuso
2016-08-10 10:58 ` Pablo Neira Ayuso
2016-08-10 11:00 ` Laura Garcia
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).