netfilter-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Stringer <joestringer@nicira.com>
To: Florian Westphal <fw@strlen.de>
Cc: Pablo Neira Ayuso <pablo@netfilter.org>, netfilter-devel@vger.kernel.org
Subject: Re: [PATCH nf-next] netfilter: connlabels: Export setting connlabel length
Date: Mon, 3 Aug 2015 10:58:40 -0700	[thread overview]
Message-ID: <CANr6G5wDbCU94YVOz7hCbjSvz9v1cFHtLqrc7g4qyEC2tu3rKw@mail.gmail.com> (raw)
In-Reply-To: <20150801004034.GC20471@breakpoint.cc>

On 31 July 2015 at 17:40, Florian Westphal <fw@strlen.de> wrote:
> Joe Stringer <joestringer@nicira.com> wrote:
>> diff --git a/net/netfilter/nf_conntrack_labels.c b/net/netfilter/nf_conntrack_labels.c
>> index bb53f12..00df4e71 100644
>> --- a/net/netfilter/nf_conntrack_labels.c
>> +++ b/net/netfilter/nf_conntrack_labels.c
>> @@ -91,6 +91,30 @@ int nf_connlabels_replace(struct nf_conn *ct,
>>  EXPORT_SYMBOL_GPL(nf_connlabels_replace);
>>  #endif
>>
>> +int nf_connlabels_get(struct net *net, unsigned int n_bits)
>> +{
>> +     size_t words;
>> +
>> +     if (n_bits > XT_CONNLABEL_MAXBIT + 1)
>
> Perhaps use
>
>   if (n_bits >= (NF_CT_LABELS_MAX_SIZE * BITS_PER_BYTE)))
>
> To avoid the XT_CONNLABEL_MAXBIT in the nf_* part.
>
>> +             return -ERANGE;
>> +
>> +     net->ct.labels_used++;
>> +     words = BITS_TO_LONGS(n_bits);
>> +     if (words > net->ct.label_words)
>> +             net->ct.label_words = words;
>> +
>> +     return 0;
>> +}
>
> I think we should add a lock here, currently this is protected by the
> xtables mutex -- I'd suggest to just add a spinlock for this.
>
>>               return ret;
>>       }
>>
>> -     par->net->ct.labels_used++;
>> -     words = BITS_TO_LONGS(info->bit+1);
>> -     if (words > par->net->ct.label_words)
>> -             par->net->ct.label_words = words;
>> -
>> -     return ret;
>> +     return nf_connlabels_get(par->net, info->bit + 1);
>
> This can leak the refcnt on l3_proto_module we obtained earlier.
>
> Other than that, this looks good.
>
> Thanks,
> Florian

Thanks for the review, I'll fix these up and send a v2 soon.

      reply	other threads:[~2015-08-03 17:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-31 23:50 [PATCH nf-next] netfilter: connlabels: Export setting connlabel length Joe Stringer
2015-08-01  0:40 ` Florian Westphal
2015-08-03 17:58   ` Joe Stringer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CANr6G5wDbCU94YVOz7hCbjSvz9v1cFHtLqrc7g4qyEC2tu3rKw@mail.gmail.com \
    --to=joestringer@nicira.com \
    --cc=fw@strlen.de \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pablo@netfilter.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).