From: Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
To: David Windsor <dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org,
Bruce Fields <bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
"Reshetova,
Elena" <elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: Re: [RFC][PATCH] nfsd: add +1 to reference counting scheme for struct nfsd4_session
Date: Sat, 11 Feb 2017 07:31:42 -0500 [thread overview]
Message-ID: <1486816302.4233.29.camel@poochiereds.net> (raw)
In-Reply-To: <CAEXv5_jUa8Av4JABoKSAueiLHSLzibMvaE-8DrVcxZHFceckMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Sat, 2017-02-11 at 01:42 -0500, David Windsor wrote:
> <snip>
>
> > Signed-off-by: David Windsor <dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> > ---
> > fs/nfsd/nfs4state.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index a0dee8a..b0f3010 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -196,7 +196,7 @@ static void nfsd4_put_session_locked(struct nfsd4_session *ses)
> >
> > lockdep_assert_held(&nn->client_lock);
> >
> > - if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses))
> > + if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_des(ses))
>
> This should read:
> if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_dead(ses))
>
> > free_session(ses);
> > put_client_renew_locked(clp);
> > }
> > @@ -1645,7 +1645,7 @@ static void init_session(struct svc_rqst *rqstp, struct nfsd4_session *new, stru
> > new->se_flags = cses->flags;
> > new->se_cb_prog = cses->callback_prog;
> > new->se_cb_sec = cses->cb_sec;
> > - atomic_set(&new->se_ref, 0);
> > + atomic_set(&new->se_ref, 1);
> > idx = hash_sessionid(&new->se_sessionid);
> > list_add(&new->se_hash, &nn->sessionid_hashtbl[idx]);
> > spin_lock(&clp->cl_lock);
> > @@ -1792,7 +1792,7 @@ free_client(struct nfs4_client *clp)
> > ses = list_entry(clp->cl_sessions.next, struct nfsd4_session,
> > se_perclnt);
> > list_del(&ses->se_perclnt);
> > - WARN_ON_ONCE(atomic_read(&ses->se_ref));
> > + WARN_ON_ONCE((atomic_read(&ses->se_ref) > 1));
> > free_session(ses);
> > }
> > rpc_destroy_wait_queue(&clp->cl_cb_waitq);
> > --
> > 2.7.4
> >
The basic idea here is that nfsv4 sessions have a "resting state" of 0.
We want to keep them around, but if they go "dead" then we we'll tear
them down if they aren't actively in use at the time. So, we still free
the thing when the refcount goes to zero, but we have an extra condition
before we free it on the put -- that the session is also "dead" (meaning
that the client asked us to destroy it).
Your patch doesn't look like it'll break anything, but I personally find
it harder to follow that way. The freeable reference state will be 1
instead of the normal 0.
--
Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@poochiereds.net>
To: David Windsor <dwindsor@gmail.com>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Cc: kernel-hardening@lists.openwall.com,
Bruce Fields <bfields@fieldses.org>,
Kees Cook <keescook@chromium.org>,
"Reshetova, Elena" <elena.reshetova@intel.com>
Subject: Re: [RFC][PATCH] nfsd: add +1 to reference counting scheme for struct nfsd4_session
Date: Sat, 11 Feb 2017 07:31:42 -0500 [thread overview]
Message-ID: <1486816302.4233.29.camel@poochiereds.net> (raw)
In-Reply-To: <CAEXv5_jUa8Av4JABoKSAueiLHSLzibMvaE-8DrVcxZHFceckMg@mail.gmail.com>
On Sat, 2017-02-11 at 01:42 -0500, David Windsor wrote:
> <snip>
>
> > Signed-off-by: David Windsor <dwindsor@gmail.com>
> > ---
> > fs/nfsd/nfs4state.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index a0dee8a..b0f3010 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -196,7 +196,7 @@ static void nfsd4_put_session_locked(struct nfsd4_session *ses)
> >
> > lockdep_assert_held(&nn->client_lock);
> >
> > - if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses))
> > + if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_des(ses))
>
> This should read:
> if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_dead(ses))
>
> > free_session(ses);
> > put_client_renew_locked(clp);
> > }
> > @@ -1645,7 +1645,7 @@ static void init_session(struct svc_rqst *rqstp, struct nfsd4_session *new, stru
> > new->se_flags = cses->flags;
> > new->se_cb_prog = cses->callback_prog;
> > new->se_cb_sec = cses->cb_sec;
> > - atomic_set(&new->se_ref, 0);
> > + atomic_set(&new->se_ref, 1);
> > idx = hash_sessionid(&new->se_sessionid);
> > list_add(&new->se_hash, &nn->sessionid_hashtbl[idx]);
> > spin_lock(&clp->cl_lock);
> > @@ -1792,7 +1792,7 @@ free_client(struct nfs4_client *clp)
> > ses = list_entry(clp->cl_sessions.next, struct nfsd4_session,
> > se_perclnt);
> > list_del(&ses->se_perclnt);
> > - WARN_ON_ONCE(atomic_read(&ses->se_ref));
> > + WARN_ON_ONCE((atomic_read(&ses->se_ref) > 1));
> > free_session(ses);
> > }
> > rpc_destroy_wait_queue(&clp->cl_cb_waitq);
> > --
> > 2.7.4
> >
The basic idea here is that nfsv4 sessions have a "resting state" of 0.
We want to keep them around, but if they go "dead" then we we'll tear
them down if they aren't actively in use at the time. So, we still free
the thing when the refcount goes to zero, but we have an extra condition
before we free it on the put -- that the session is also "dead" (meaning
that the client asked us to destroy it).
Your patch doesn't look like it'll break anything, but I personally find
it harder to follow that way. The freeable reference state will be 1
instead of the normal 0.
--
Jeff Layton <jlayton@poochiereds.net>
WARNING: multiple messages have this Message-ID (diff)
From: Jeff Layton <jlayton@poochiereds.net>
To: David Windsor <dwindsor@gmail.com>,
linux-nfs@vger.kernel.org, netdev@vger.kernel.org
Cc: kernel-hardening@lists.openwall.com,
Bruce Fields <bfields@fieldses.org>,
Kees Cook <keescook@chromium.org>,
"Reshetova, Elena" <elena.reshetova@intel.com>
Subject: [kernel-hardening] Re: [RFC][PATCH] nfsd: add +1 to reference counting scheme for struct nfsd4_session
Date: Sat, 11 Feb 2017 07:31:42 -0500 [thread overview]
Message-ID: <1486816302.4233.29.camel@poochiereds.net> (raw)
In-Reply-To: <CAEXv5_jUa8Av4JABoKSAueiLHSLzibMvaE-8DrVcxZHFceckMg@mail.gmail.com>
On Sat, 2017-02-11 at 01:42 -0500, David Windsor wrote:
> <snip>
>
> > Signed-off-by: David Windsor <dwindsor@gmail.com>
> > ---
> > fs/nfsd/nfs4state.c | 6 +++---
> > 1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c
> > index a0dee8a..b0f3010 100644
> > --- a/fs/nfsd/nfs4state.c
> > +++ b/fs/nfsd/nfs4state.c
> > @@ -196,7 +196,7 @@ static void nfsd4_put_session_locked(struct nfsd4_session *ses)
> >
> > lockdep_assert_held(&nn->client_lock);
> >
> > - if (atomic_dec_and_test(&ses->se_ref) && is_session_dead(ses))
> > + if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_des(ses))
>
> This should read:
> if (!atomic_add_unless(&ses->se_ref, -1, 1) && is_session_dead(ses))
>
> > free_session(ses);
> > put_client_renew_locked(clp);
> > }
> > @@ -1645,7 +1645,7 @@ static void init_session(struct svc_rqst *rqstp, struct nfsd4_session *new, stru
> > new->se_flags = cses->flags;
> > new->se_cb_prog = cses->callback_prog;
> > new->se_cb_sec = cses->cb_sec;
> > - atomic_set(&new->se_ref, 0);
> > + atomic_set(&new->se_ref, 1);
> > idx = hash_sessionid(&new->se_sessionid);
> > list_add(&new->se_hash, &nn->sessionid_hashtbl[idx]);
> > spin_lock(&clp->cl_lock);
> > @@ -1792,7 +1792,7 @@ free_client(struct nfs4_client *clp)
> > ses = list_entry(clp->cl_sessions.next, struct nfsd4_session,
> > se_perclnt);
> > list_del(&ses->se_perclnt);
> > - WARN_ON_ONCE(atomic_read(&ses->se_ref));
> > + WARN_ON_ONCE((atomic_read(&ses->se_ref) > 1));
> > free_session(ses);
> > }
> > rpc_destroy_wait_queue(&clp->cl_cb_waitq);
> > --
> > 2.7.4
> >
The basic idea here is that nfsv4 sessions have a "resting state" of 0.
We want to keep them around, but if they go "dead" then we we'll tear
them down if they aren't actively in use at the time. So, we still free
the thing when the refcount goes to zero, but we have an extra condition
before we free it on the put -- that the session is also "dead" (meaning
that the client asked us to destroy it).
Your patch doesn't look like it'll break anything, but I personally find
it harder to follow that way. The freeable reference state will be 1
instead of the normal 0.
--
Jeff Layton <jlayton@poochiereds.net>
next prev parent reply other threads:[~2017-02-11 12:31 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-09 7:38 [RFC][PATCH] nfsd: add +1 to reference counting scheme for struct nfsd4_session David Windsor
2017-02-09 7:38 ` [kernel-hardening] " David Windsor
2017-02-09 7:38 ` David Windsor
2017-02-11 6:42 ` David Windsor
2017-02-11 6:42 ` [kernel-hardening] " David Windsor
[not found] ` <CAEXv5_jUa8Av4JABoKSAueiLHSLzibMvaE-8DrVcxZHFceckMg-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-11 12:31 ` Jeff Layton [this message]
2017-02-11 12:31 ` Jeff Layton
2017-02-11 12:31 ` Jeff Layton
[not found] ` <1486816302.4233.29.camel-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
2017-02-11 14:01 ` David Windsor
2017-02-11 14:01 ` [kernel-hardening] " David Windsor
2017-02-11 14:01 ` David Windsor
2017-02-11 14:09 ` Jeff Layton
2017-02-11 14:09 ` [kernel-hardening] " Jeff Layton
[not found] ` <CAEXv5_gd7F-eaazzU1BWPzH4huhEcO1Y-FWov5UP9T+6R+fv-A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-13 10:38 ` Christoph Hellwig
2017-02-13 10:38 ` [kernel-hardening] " Christoph Hellwig
2017-02-13 10:38 ` Christoph Hellwig
[not found] ` <20170213103815.GA5131-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>
2017-02-13 11:42 ` David Windsor
2017-02-13 11:42 ` [kernel-hardening] " David Windsor
2017-02-13 11:42 ` David Windsor
[not found] ` <CAEXv5_g=DS4wk0mgZuw-doVCqountb-CxZki1LOoQH-P7W1U4A-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-13 12:12 ` Christoph Hellwig
2017-02-13 12:12 ` [kernel-hardening] " Christoph Hellwig
2017-02-13 12:12 ` Christoph Hellwig
2017-02-14 13:48 ` David Windsor
2017-02-14 13:48 ` [kernel-hardening] " David Windsor
2017-02-12 1:15 ` Bruce Fields
2017-02-12 1:15 ` [kernel-hardening] " Bruce Fields
2017-02-12 1:15 ` Bruce Fields
2017-02-12 1:42 ` David Windsor
2017-02-12 1:42 ` [kernel-hardening] " David Windsor
2017-02-13 10:54 ` Hans Liljestrand
2017-02-13 10:54 ` Hans Liljestrand
2017-02-13 11:46 ` David Windsor
[not found] ` <CAEXv5_hP39k7HSLP-G_khx7MMQHnk=8Z5caa+U5n3bYvUTE1gQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2017-02-15 16:45 ` Bruce Fields
2017-02-15 16:45 ` Bruce Fields
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=1486816302.4233.29.camel@poochiereds.net \
--to=jlayton-vpemndpepfumzcb2o+c8xq@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=kernel-hardening-ZwoEplunGu1jrUoiu81ncdBPR1lH4CV8@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.