Skip to content

Commit 0362058

Browse files
committed
netfilter: nf_tables: restrict tunnel object to NFPROTO_NETDEV
jira LE-1907 Rebuild_History Non-Buildable kernel-5.14.0-427.33.1.el9_4 commit-author Pablo Neira Ayuso <pablo@netfilter.org> commit 776d451 Bail out on using the tunnel dst template from other than netdev family. Add the infrastructure to check for the family in objects. Fixes: af308b9 ("netfilter: nf_tables: add tunnel support") Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org> (cherry picked from commit 776d451) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 137fbbc commit 0362058

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

include/net/netfilter/nf_tables.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1265,6 +1265,7 @@ void nft_obj_notify(struct net *net, const struct nft_table *table,
12651265
* @type: stateful object numeric type
12661266
* @owner: module owner
12671267
* @maxattr: maximum netlink attribute
1268+
* @family: address family for AF-specific object types
12681269
* @policy: netlink attribute policy
12691270
*/
12701271
struct nft_object_type {
@@ -1274,6 +1275,7 @@ struct nft_object_type {
12741275
struct list_head list;
12751276
u32 type;
12761277
unsigned int maxattr;
1278+
u8 family;
12771279
struct module *owner;
12781280
const struct nla_policy *policy;
12791281
};

net/netfilter/nf_tables_api.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7223,23 +7223,27 @@ static int nft_object_dump(struct sk_buff *skb, unsigned int attr,
72237223
return -1;
72247224
}
72257225

7226-
static const struct nft_object_type *__nft_obj_type_get(u32 objtype)
7226+
static const struct nft_object_type *__nft_obj_type_get(u32 objtype, u8 family)
72277227
{
72287228
const struct nft_object_type *type;
72297229

72307230
list_for_each_entry(type, &nf_tables_objects, list) {
7231+
if (type->family != NFPROTO_UNSPEC &&
7232+
type->family != family)
7233+
continue;
7234+
72317235
if (objtype == type->type)
72327236
return type;
72337237
}
72347238
return NULL;
72357239
}
72367240

72377241
static const struct nft_object_type *
7238-
nft_obj_type_get(struct net *net, u32 objtype)
7242+
nft_obj_type_get(struct net *net, u32 objtype, u8 family)
72397243
{
72407244
const struct nft_object_type *type;
72417245

7242-
type = __nft_obj_type_get(objtype);
7246+
type = __nft_obj_type_get(objtype, family);
72437247
if (type != NULL && try_module_get(type->owner))
72447248
return type;
72457249

@@ -7332,7 +7336,7 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,
73327336
if (info->nlh->nlmsg_flags & NLM_F_REPLACE)
73337337
return -EOPNOTSUPP;
73347338

7335-
type = __nft_obj_type_get(objtype);
7339+
type = __nft_obj_type_get(objtype, family);
73367340
if (WARN_ON_ONCE(!type))
73377341
return -ENOENT;
73387342

@@ -7346,7 +7350,7 @@ static int nf_tables_newobj(struct sk_buff *skb, const struct nfnl_info *info,
73467350
if (!nft_use_inc(&table->use))
73477351
return -EMFILE;
73487352

7349-
type = nft_obj_type_get(net, objtype);
7353+
type = nft_obj_type_get(net, objtype, family);
73507354
if (IS_ERR(type)) {
73517355
err = PTR_ERR(type);
73527356
goto err_type;

net/netfilter/nft_tunnel.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -684,6 +684,7 @@ static const struct nft_object_ops nft_tunnel_obj_ops = {
684684

685685
static struct nft_object_type nft_tunnel_obj_type __read_mostly = {
686686
.type = NFT_OBJECT_TUNNEL,
687+
.family = NFPROTO_NETDEV,
687688
.ops = &nft_tunnel_obj_ops,
688689
.maxattr = NFTA_TUNNEL_KEY_MAX,
689690
.policy = nft_tunnel_key_policy,

0 commit comments

Comments
 (0)