* [PATCH nft] evaluate: use existing table object from evaluation context
@ 2015-09-09 23:59 Pablo Neira Ayuso
2015-09-10 6:31 ` Arturo Borrero Gonzalez
0 siblings, 1 reply; 3+ messages in thread
From: Pablo Neira Ayuso @ 2015-09-09 23:59 UTC (permalink / raw)
To: netfilter-devel; +Cc: kaber, fw, arturo.borrero.glez
Skip table object lookup if we are in the context of table declaration already,
ctx->table already points to the right table we have to use during the
evalution. Otherwise, a list corruption occurs when using the wrong table
object when it already exists in the kernel.
http://marc.info/?l=netfilter-devel&m=144179814209295&w=2
Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
src/evaluate.c | 22 ++++++++++++++++++----
1 file changed, 18 insertions(+), 4 deletions(-)
diff --git a/src/evaluate.c b/src/evaluate.c
index 1405da8..22dd6d5 100644
--- a/src/evaluate.c
+++ b/src/evaluate.c
@@ -1711,12 +1711,26 @@ int stmt_evaluate(struct eval_ctx *ctx, struct stmt *stmt)
}
}
+static struct table *table_lookup_global(struct eval_ctx *ctx)
+{
+ struct table *table;
+
+ if (ctx->table != NULL)
+ return ctx->cmd->table;
+
+ table = table_lookup(&ctx->cmd->handle);
+ if (table == NULL)
+ return NULL;
+
+ return table;
+}
+
static int setelem_evaluate(struct eval_ctx *ctx, struct expr **expr)
{
struct table *table;
struct set *set;
- table = table_lookup(&ctx->cmd->handle);
+ table = table_lookup_global(ctx);
if (table == NULL)
return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
ctx->cmd->handle.table);
@@ -1739,7 +1753,7 @@ static int set_evaluate(struct eval_ctx *ctx, struct set *set)
struct table *table;
const char *type;
- table = table_lookup(&ctx->cmd->handle);
+ table = table_lookup_global(ctx);
if (table == NULL)
return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
ctx->cmd->handle.table);
@@ -1857,9 +1871,9 @@ static int chain_evaluate(struct eval_ctx *ctx, struct chain *chain)
struct table *table;
struct rule *rule;
- table = table_lookup(&ctx->cmd->handle);
+ table = table_lookup_global(ctx);
if (table == NULL)
- return cmd_error(ctx, "Table '%s' does not exist",
+ return cmd_error(ctx, "Could not process rule: Table '%s' does not exist",
ctx->cmd->handle.table);
if (chain == NULL) {
--
1.7.10.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH nft] evaluate: use existing table object from evaluation context
2015-09-09 23:59 [PATCH nft] evaluate: use existing table object from evaluation context Pablo Neira Ayuso
@ 2015-09-10 6:31 ` Arturo Borrero Gonzalez
2015-09-11 12:32 ` Pablo Neira Ayuso
0 siblings, 1 reply; 3+ messages in thread
From: Arturo Borrero Gonzalez @ 2015-09-10 6:31 UTC (permalink / raw)
To: Pablo Neira Ayuso; +Cc: Netfilter Development Mailing list, Patrick McHardy, fw
On 10 September 2015 at 01:59, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> Skip table object lookup if we are in the context of table declaration already,
> ctx->table already points to the right table we have to use during the
> evalution. Otherwise, a list corruption occurs when using the wrong table
> object when it already exists in the kernel.
>
> http://marc.info/?l=netfilter-devel&m=144179814209295&w=2
>
> Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> ---
> src/evaluate.c | 22 ++++++++++++++++++----
> 1 file changed, 18 insertions(+), 4 deletions(-)
>
I can't reproduce the issue with this patch, thanks.
Tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
--
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] 3+ messages in thread
* Re: [PATCH nft] evaluate: use existing table object from evaluation context
2015-09-10 6:31 ` Arturo Borrero Gonzalez
@ 2015-09-11 12:32 ` Pablo Neira Ayuso
0 siblings, 0 replies; 3+ messages in thread
From: Pablo Neira Ayuso @ 2015-09-11 12:32 UTC (permalink / raw)
To: Arturo Borrero Gonzalez
Cc: Netfilter Development Mailing list, Patrick McHardy, fw
On Thu, Sep 10, 2015 at 08:31:25AM +0200, Arturo Borrero Gonzalez wrote:
> On 10 September 2015 at 01:59, Pablo Neira Ayuso <pablo@netfilter.org> wrote:
> > Skip table object lookup if we are in the context of table declaration already,
> > ctx->table already points to the right table we have to use during the
> > evalution. Otherwise, a list corruption occurs when using the wrong table
> > object when it already exists in the kernel.
> >
> > http://marc.info/?l=netfilter-devel&m=144179814209295&w=2
> >
> > Reported-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
> > Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
> > ---
> > src/evaluate.c | 22 ++++++++++++++++++----
> > 1 file changed, 18 insertions(+), 4 deletions(-)
> >
>
> I can't reproduce the issue with this patch, thanks.
>
> Tested-by: Arturo Borrero Gonzalez <arturo.borrero.glez@gmail.com>
Thanks for testing Arturo.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-09-11 12:26 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-09 23:59 [PATCH nft] evaluate: use existing table object from evaluation context Pablo Neira Ayuso
2015-09-10 6:31 ` Arturo Borrero Gonzalez
2015-09-11 12:32 ` 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).