From: Daniel Borkmann <daniel@iogearbox.net>
To: Elena Reshetova <elena.reshetova@intel.com>
Cc: ast@fb.com, linux-kernel@vger.kernel.org, peterz@infradead.org,
netdev@vger.kernel.org, Hans Liljestrand <ishkamiel@gmail.com>,
Kees Cook <keescook@chromium.org>,
David Windsor <dwindsor@gmail.com>
Subject: Re: [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t
Date: Mon, 20 Mar 2017 18:13:33 +0100 [thread overview]
Message-ID: <58D00DBD.5080702@iogearbox.net> (raw)
In-Reply-To: <1490002641-10498-1-git-send-email-elena.reshetova@intel.com>
On 03/20/2017 10:37 AM, Elena Reshetova wrote:
[...]
> diff --git a/net/core/filter.c b/net/core/filter.c
> index ebaeaf2..389cb8d 100644
> --- a/net/core/filter.c
> +++ b/net/core/filter.c
> @@ -928,7 +928,7 @@ static void sk_filter_release_rcu(struct rcu_head *rcu)
> */
> static void sk_filter_release(struct sk_filter *fp)
> {
> - if (atomic_dec_and_test(&fp->refcnt))
> + if (refcount_dec_and_test(&fp->refcnt))
> call_rcu(&fp->rcu, sk_filter_release_rcu);
> }
>
> @@ -943,20 +943,27 @@ void sk_filter_uncharge(struct sock *sk, struct sk_filter *fp)
> /* try to charge the socket memory if there is space available
> * return true on success
> */
> -bool sk_filter_charge(struct sock *sk, struct sk_filter *fp)
> +bool __sk_filter_charge(struct sock *sk, struct sk_filter *fp)
And this then becomes: static bool __sk_filter_charge(...)
> {
> u32 filter_size = bpf_prog_size(fp->prog->len);
>
> /* same check as in sock_kmalloc() */
> if (filter_size <= sysctl_optmem_max &&
> atomic_read(&sk->sk_omem_alloc) + filter_size < sysctl_optmem_max) {
> - atomic_inc(&fp->refcnt);
> atomic_add(filter_size, &sk->sk_omem_alloc);
> return true;
> }
> return false;
> }
Since here is just all in slow-path, looks fine to me if the above
is addressed as well in v3:
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Please make sure you add [PATCH net-next] in your subject in future
so that it's clear which tree this goes to.
Thanks,
Daniel
next prev parent reply other threads:[~2017-03-20 17:13 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-20 9:37 [PATCH] net: convert sk_filter.refcnt from atomic_t to refcount_t Elena Reshetova
2017-03-20 17:13 ` Daniel Borkmann [this message]
2017-03-21 10:43 ` Reshetova, Elena
-- strict thread matches above, loose matches on Subject: below --
2017-03-18 12:58 Elena Reshetova
2017-03-18 14:33 ` Sergei Shtylyov
2017-03-20 9:31 ` Reshetova, Elena
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=58D00DBD.5080702@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=ast@fb.com \
--cc=dwindsor@gmail.com \
--cc=elena.reshetova@intel.com \
--cc=ishkamiel@gmail.com \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=peterz@infradead.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).