summaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorSaeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com>2020-10-20 13:41:36 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2020-11-01 12:47:00 +0100
commit10cf2d801e22c531efb085d89e773a5922882f9b (patch)
tree42d3671299230512421e6fe341d50359f925ad8c /include
parent0e26e64bb38aec25efe7917e1f18ed9775d0020c (diff)
downloadlinux-stable-10cf2d801e22c531efb085d89e773a5922882f9b.tar.gz
linux-stable-10cf2d801e22c531efb085d89e773a5922882f9b.tar.bz2
linux-stable-10cf2d801e22c531efb085d89e773a5922882f9b.zip
netfilter: nftables_offload: KASAN slab-out-of-bounds Read in nft_flow_rule_create
commit 31cc578ae2de19c748af06d859019dced68e325d upstream. This patch fixes the issue due to: BUG: KASAN: slab-out-of-bounds in nft_flow_rule_create+0x622/0x6a2 net/netfilter/nf_tables_offload.c:40 Read of size 8 at addr ffff888103910b58 by task syz-executor227/16244 The error happens when expr->ops is accessed early on before performing the boundary check and after nft_expr_next() moves the expr to go out-of-bounds. This patch checks the boundary condition before expr->ops that fixes the slab-out-of-bounds Read issue. Add nft_expr_more() and use it to fix this problem. Signed-off-by: Saeed Mirzamohammadi <saeed.mirzamohammadi@oracle.com> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'include')
-rw-r--r--include/net/netfilter/nf_tables.h6
1 files changed, 6 insertions, 0 deletions
diff --git a/include/net/netfilter/nf_tables.h b/include/net/netfilter/nf_tables.h
index 224d194ad29d..e5b7fbabedfb 100644
--- a/include/net/netfilter/nf_tables.h
+++ b/include/net/netfilter/nf_tables.h
@@ -896,6 +896,12 @@ static inline struct nft_expr *nft_expr_last(const struct nft_rule *rule)
return (struct nft_expr *)&rule->data[rule->dlen];
}
+static inline bool nft_expr_more(const struct nft_rule *rule,
+ const struct nft_expr *expr)
+{
+ return expr != nft_expr_last(rule) && expr->ops;
+}
+
static inline struct nft_userdata *nft_userdata(const struct nft_rule *rule)
{
return (void *)&rule->data[rule->dlen];