Commit ac813744 authored by David S. Miller's avatar David S. Miller

Merge git://git.kernel.org/pub/scm/linux/kernel/git/pablo/nf

Pablo Neira Ayuso says:

====================
Netfilter fixes for net

The following patch contains Netfilter fixes for your net tree, they are:

1) nf_log_unregister() should only set to NULL the logger that is being
   unregistered, instead of everything else. Patch from Florian Westphal.

2) Fix a crash when accessing physoutdev from PREROUTING in br_netfilter.
   This is partially reverting the patch to shrink nf_bridge_info to 32 bytes.
   Also from Florian.

3) Use existing match/target extensions in the internal nft_compat extension
   lists when the extension is family unspecific (ie. NFPROTO_UNSPEC).

4) Wait for rcu grace period before leaving nf_log_unregister().
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 4e3ae001 ad5001cc
...@@ -179,6 +179,9 @@ struct nf_bridge_info { ...@@ -179,6 +179,9 @@ struct nf_bridge_info {
u8 bridged_dnat:1; u8 bridged_dnat:1;
__u16 frag_max_size; __u16 frag_max_size;
struct net_device *physindev; struct net_device *physindev;
/* always valid & non-NULL from FORWARD on, for physdev match */
struct net_device *physoutdev;
union { union {
/* prerouting: detect dnat in orig/reply direction */ /* prerouting: detect dnat in orig/reply direction */
__be32 ipv4_daddr; __be32 ipv4_daddr;
...@@ -189,9 +192,6 @@ struct nf_bridge_info { ...@@ -189,9 +192,6 @@ struct nf_bridge_info {
* skb is out in neigh layer. * skb is out in neigh layer.
*/ */
char neigh_header[8]; char neigh_header[8];
/* always valid & non-NULL from FORWARD on, for physdev match */
struct net_device *physoutdev;
}; };
}; };
#endif #endif
......
...@@ -107,12 +107,17 @@ EXPORT_SYMBOL(nf_log_register); ...@@ -107,12 +107,17 @@ EXPORT_SYMBOL(nf_log_register);
void nf_log_unregister(struct nf_logger *logger) void nf_log_unregister(struct nf_logger *logger)
{ {
const struct nf_logger *log;
int i; int i;
mutex_lock(&nf_log_mutex); mutex_lock(&nf_log_mutex);
for (i = 0; i < NFPROTO_NUMPROTO; i++) for (i = 0; i < NFPROTO_NUMPROTO; i++) {
RCU_INIT_POINTER(loggers[i][logger->type], NULL); log = nft_log_dereference(loggers[i][logger->type]);
if (log == logger)
RCU_INIT_POINTER(loggers[i][logger->type], NULL);
}
mutex_unlock(&nf_log_mutex); mutex_unlock(&nf_log_mutex);
synchronize_rcu();
} }
EXPORT_SYMBOL(nf_log_unregister); EXPORT_SYMBOL(nf_log_unregister);
......
...@@ -619,6 +619,13 @@ struct nft_xt { ...@@ -619,6 +619,13 @@ struct nft_xt {
static struct nft_expr_type nft_match_type; static struct nft_expr_type nft_match_type;
static bool nft_match_cmp(const struct xt_match *match,
const char *name, u32 rev, u32 family)
{
return strcmp(match->name, name) == 0 && match->revision == rev &&
(match->family == NFPROTO_UNSPEC || match->family == family);
}
static const struct nft_expr_ops * static const struct nft_expr_ops *
nft_match_select_ops(const struct nft_ctx *ctx, nft_match_select_ops(const struct nft_ctx *ctx,
const struct nlattr * const tb[]) const struct nlattr * const tb[])
...@@ -626,7 +633,7 @@ nft_match_select_ops(const struct nft_ctx *ctx, ...@@ -626,7 +633,7 @@ nft_match_select_ops(const struct nft_ctx *ctx,
struct nft_xt *nft_match; struct nft_xt *nft_match;
struct xt_match *match; struct xt_match *match;
char *mt_name; char *mt_name;
__u32 rev, family; u32 rev, family;
if (tb[NFTA_MATCH_NAME] == NULL || if (tb[NFTA_MATCH_NAME] == NULL ||
tb[NFTA_MATCH_REV] == NULL || tb[NFTA_MATCH_REV] == NULL ||
...@@ -641,8 +648,7 @@ nft_match_select_ops(const struct nft_ctx *ctx, ...@@ -641,8 +648,7 @@ nft_match_select_ops(const struct nft_ctx *ctx,
list_for_each_entry(nft_match, &nft_match_list, head) { list_for_each_entry(nft_match, &nft_match_list, head) {
struct xt_match *match = nft_match->ops.data; struct xt_match *match = nft_match->ops.data;
if (strcmp(match->name, mt_name) == 0 && if (nft_match_cmp(match, mt_name, rev, family)) {
match->revision == rev && match->family == family) {
if (!try_module_get(match->me)) if (!try_module_get(match->me))
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
...@@ -693,6 +699,13 @@ static LIST_HEAD(nft_target_list); ...@@ -693,6 +699,13 @@ static LIST_HEAD(nft_target_list);
static struct nft_expr_type nft_target_type; static struct nft_expr_type nft_target_type;
static bool nft_target_cmp(const struct xt_target *tg,
const char *name, u32 rev, u32 family)
{
return strcmp(tg->name, name) == 0 && tg->revision == rev &&
(tg->family == NFPROTO_UNSPEC || tg->family == family);
}
static const struct nft_expr_ops * static const struct nft_expr_ops *
nft_target_select_ops(const struct nft_ctx *ctx, nft_target_select_ops(const struct nft_ctx *ctx,
const struct nlattr * const tb[]) const struct nlattr * const tb[])
...@@ -700,7 +713,7 @@ nft_target_select_ops(const struct nft_ctx *ctx, ...@@ -700,7 +713,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
struct nft_xt *nft_target; struct nft_xt *nft_target;
struct xt_target *target; struct xt_target *target;
char *tg_name; char *tg_name;
__u32 rev, family; u32 rev, family;
if (tb[NFTA_TARGET_NAME] == NULL || if (tb[NFTA_TARGET_NAME] == NULL ||
tb[NFTA_TARGET_REV] == NULL || tb[NFTA_TARGET_REV] == NULL ||
...@@ -715,8 +728,7 @@ nft_target_select_ops(const struct nft_ctx *ctx, ...@@ -715,8 +728,7 @@ nft_target_select_ops(const struct nft_ctx *ctx,
list_for_each_entry(nft_target, &nft_target_list, head) { list_for_each_entry(nft_target, &nft_target_list, head) {
struct xt_target *target = nft_target->ops.data; struct xt_target *target = nft_target->ops.data;
if (strcmp(target->name, tg_name) == 0 && if (nft_target_cmp(target, tg_name, rev, family)) {
target->revision == rev && target->family == family) {
if (!try_module_get(target->me)) if (!try_module_get(target->me))
return ERR_PTR(-ENOENT); return ERR_PTR(-ENOENT);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment