From: Trond Myklebust <trondmy-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
To: "elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
<peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org"
<ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org"
<steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>,
"nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org"
<nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jreuter-K7Hl1MveuGQ@public.gmane.org"
<jreuter-K7Hl1MveuGQ@public.gmane.org>,
"santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org"
<santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
"linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org"
<jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>,
"dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org"
<keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Subject: Re: [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t
Date: Fri, 17 Mar 2017 12:50:12 +0000 [thread overview]
Message-ID: <1489755011.6453.1.camel@primarydata.com> (raw)
In-Reply-To: <1489752646-8749-2-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Fri, 2017-03-17 at 14:10 +0200, Elena Reshetova wrote:
> refcount_t type and corresponding API should be
> used instead of atomic_t when the variable is used as
> a reference counter. This allows to avoid accidental
> refcounter overflows that might lead to use-after-free
> situations.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: David Windsor <dwindsor@gmail.com>
> ---
> include/linux/sunrpc/auth.h | 8 ++++----
> net/sunrpc/auth.c | 12 ++++++------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/sunrpc/auth.h
> b/include/linux/sunrpc/auth.h
> index b1bc62b..bd36e0b 100644
> --- a/include/linux/sunrpc/auth.h
> +++ b/include/linux/sunrpc/auth.h
> @@ -15,7 +15,7 @@
> #include <linux/sunrpc/msg_prot.h>
> #include <linux/sunrpc/xdr.h>
>
> -#include <linux/atomic.h>
> +#include <linux/refcount.h>
> #include <linux/rcupdate.h>
> #include <linux/uidgid.h>
> #include <linux/utsname.h>
> @@ -68,7 +68,7 @@ struct rpc_cred {
> #endif
> unsigned long cr_expire; /* when to gc
> */
> unsigned long cr_flags; /* various
> flags */
> - atomic_t cr_count; /* ref count */
> + refcount_t cr_count; /* ref count */
>
NACK. That's going to be hitting WARN_ONCE(!refcount_inc_not_zero(r),
"refcount_t: increment on 0; use-after-free.\n") like there's no
tomorrow...
Please stop with these automated conversions. They are going to cause a
lot more bugs than they fix.
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com
WARNING: multiple messages have this Message-ID (diff)
From: Trond Myklebust <trondmy@primarydata.com>
To: "elena.reshetova@intel.com" <elena.reshetova@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"ralf@linux-mips.org" <ralf@linux-mips.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"ishkamiel@gmail.com" <ishkamiel@gmail.com>,
"bfields@fieldses.org" <bfields@fieldses.org>,
"steffen.klassert@secunet.com" <steffen.klassert@secunet.com>,
"nhorman@tuxdriver.com" <nhorman@tuxdriver.com>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"jreuter@yaina.de" <jreuter@yaina.de>,
"santosh.shilimkar@oracle.com" <santosh.shilimkar@oracle.com>,
"linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>,
"jlayton@poochiereds.net" <jlayton@poochiereds.net>,
"dwindsor@gmail.com" <dwindsor@gmail.com>,
"keescook@chromium.org" <keescook@chromium.org>,
"zyan@redhat.com" <zyan@redhat.com>,
"sage@redhat.com" <sage@redhat.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
"vyasevich@gmail.com" <vyasevich@gmail.com>,
"linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>,
"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t
Date: Fri, 17 Mar 2017 12:50:12 +0000 [thread overview]
Message-ID: <1489755011.6453.1.camel@primarydata.com> (raw)
In-Reply-To: <1489752646-8749-2-git-send-email-elena.reshetova@intel.com>
T24gRnJpLCAyMDE3LTAzLTE3IGF0IDE0OjEwICswMjAwLCBFbGVuYSBSZXNoZXRvdmEgd3JvdGU6
DQo+IHJlZmNvdW50X3QgdHlwZSBhbmQgY29ycmVzcG9uZGluZyBBUEkgc2hvdWxkIGJlDQo+IHVz
ZWQgaW5zdGVhZCBvZiBhdG9taWNfdCB3aGVuIHRoZSB2YXJpYWJsZSBpcyB1c2VkIGFzDQo+IGEg
cmVmZXJlbmNlIGNvdW50ZXIuIFRoaXMgYWxsb3dzIHRvIGF2b2lkIGFjY2lkZW50YWwNCj4gcmVm
Y291bnRlciBvdmVyZmxvd3MgdGhhdCBtaWdodCBsZWFkIHRvIHVzZS1hZnRlci1mcmVlDQo+IHNp
dHVhdGlvbnMuDQo+IA0KPiBTaWduZWQtb2ZmLWJ5OiBFbGVuYSBSZXNoZXRvdmEgPGVsZW5hLnJl
c2hldG92YUBpbnRlbC5jb20+DQo+IFNpZ25lZC1vZmYtYnk6IEhhbnMgTGlsamVzdHJhbmQgPGlz
aGthbWllbEBnbWFpbC5jb20+DQo+IFNpZ25lZC1vZmYtYnk6IEtlZXMgQ29vayA8a2Vlc2Nvb2tA
Y2hyb21pdW0ub3JnPg0KPiBTaWduZWQtb2ZmLWJ5OiBEYXZpZCBXaW5kc29yIDxkd2luZHNvckBn
bWFpbC5jb20+DQo+IC0tLQ0KPiDCoGluY2x1ZGUvbGludXgvc3VucnBjL2F1dGguaCB8wqDCoDgg
KysrKy0tLS0NCj4gwqBuZXQvc3VucnBjL2F1dGguY8Kg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gKi8NCj4gDQoNCk5BQ0suIFRoYXQncyBnb2luZyB0byBiZSBoaXR0aW5n
IFdBUk5fT05DRSghcmVmY291bnRfaW5jX25vdF96ZXJvKHIpLA0KInJlZmNvdW50X3Q6IGluY3Jl
bWVudCBvbiAwOyB1c2UtYWZ0ZXItZnJlZS5cbiIpIGxpa2UgdGhlcmUncyBubw0KdG9tb3Jyb3cu
Li4NCg0KUGxlYXNlIHN0b3Agd2l0aCB0aGVzZSBhdXRvbWF0ZWQgY29udmVyc2lvbnMuIFRoZXkg
YXJlIGdvaW5nIHRvIGNhdXNlIGENCmxvdCBtb3JlIGJ1Z3MgdGhhbiB0aGV5IGZpeC4NCg0KLS0g
DQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURh
dGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg==
WARNING: multiple messages have this Message-ID (diff)
From: Trond Myklebust <trondmy@primarydata.com>
To: "elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
<peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org"
<ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org"
<steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>,
"nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org"
<nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jreuter-K7Hl1MveuGQ@public.gmane.org"
<jreuter-K7Hl1MveuGQ@public.gmane.org>,
"santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org"
<santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
"linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org"
<jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>,
"dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org"
<keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
Subject: Re: [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t
Date: Fri, 17 Mar 2017 12:50:12 +0000 [thread overview]
Message-ID: <1489755011.6453.1.camel@primarydata.com> (raw)
In-Reply-To: <1489752646-8749-2-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
T24gRnJpLCAyMDE3LTAzLTE3IGF0IDE0OjEwICswMjAwL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
YXJlIGdvaW5nIHRvIGNhdXNlIGENCmxvdCBtb3JlIGJ1Z3MgdGhhbiB0aGV5IGZpeC4NCg0KLS0g
DQpUcm9uZCBNeWtsZWJ1c3QNCkxpbnV4IE5GUyBjbGllbnQgbWFpbnRhaW5lciwgUHJpbWFyeURh
dGENCnRyb25kLm15a2xlYnVzdEBwcmltYXJ5ZGF0YS5jb20NCg=
WARNING: multiple messages have this Message-ID (diff)
From: Trond Myklebust <trondmy@primarydata.com>
To: "elena.reshetova@intel.com" <elena.reshetova@intel.com>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"peterz@infradead.org" <peterz@infradead.org>,
"ralf@linux-mips.org" <ralf@linux-mips.org>,
"linux-rdma@vger.kernel.org" <linux-rdma@vger.kernel.org>,
"ishkamiel@gmail.com" <ishkamiel@gmail.com>,
"bfields@fieldses.org" <bfields@fieldses.org>,
"steffen.klassert@secunet.com" <steffen.klassert@secunet.com>,
"nhorman@tuxdriver.com" <nhorman@tuxdriver.com>,
"linux-nfs@vger.kernel.org" <linux-nfs@vger.kernel.org>,
"jreuter@yaina.de" <jreuter@yaina.de>,
"santosh.shilimkar@oracle.com" <santosh.shilimkar@oracle.com>,
"linux-hams@vger.kernel.org" <linux-hams@vger.kernel.org>,
"jlayton@poochiereds.net" <jlayton@poochiereds.net>,
"dwindsor@gmail.com" <dwindsor@gmail.com>,
"keescook@chromium.org" <keescook@chromium.org>,
"zyan@redhat.com" <zyan@redhat.com>,
"sage@redhat.com" <sage@redhat.com>,
"davem@davemloft.net" <davem@davemloft.net>,
"linux-sctp@vger.kernel.org" <linux-sctp@vger.kernel.org>,
"vyasevich@gmail.com" <vyasevich@gmail.com>,
"linux-x25@vger.kernel.org" <linux-x25@vger.kernel.org>,
"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
"ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: Re: [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t
Date: Fri, 17 Mar 2017 12:50:12 +0000 [thread overview]
Message-ID: <1489755011.6453.1.camel@primarydata.com> (raw)
In-Reply-To: <1489752646-8749-2-git-send-email-elena.reshetova@intel.com>
On Fri, 2017-03-17 at 14:10 +0200, Elena Reshetova wrote:
> refcount_t type and corresponding API should be
> used instead of atomic_t when the variable is used as
> a reference counter. This allows to avoid accidental
> refcounter overflows that might lead to use-after-free
> situations.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: David Windsor <dwindsor@gmail.com>
> ---
> include/linux/sunrpc/auth.h | 8 ++++----
> net/sunrpc/auth.c | 12 ++++++------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/sunrpc/auth.h
> b/include/linux/sunrpc/auth.h
> index b1bc62b..bd36e0b 100644
> --- a/include/linux/sunrpc/auth.h
> +++ b/include/linux/sunrpc/auth.h
> @@ -15,7 +15,7 @@
> #include <linux/sunrpc/msg_prot.h>
> #include <linux/sunrpc/xdr.h>
>
> -#include <linux/atomic.h>
> +#include <linux/refcount.h>
> #include <linux/rcupdate.h>
> #include <linux/uidgid.h>
> #include <linux/utsname.h>
> @@ -68,7 +68,7 @@ struct rpc_cred {
> #endif
> unsigned long cr_expire; /* when to gc
> */
> unsigned long cr_flags; /* various
> flags */
> - atomic_t cr_count; /* ref count */
> + refcount_t cr_count; /* ref count */
>
NACK. That's going to be hitting WARN_ONCE(!refcount_inc_not_zero(r),
"refcount_t: increment on 0; use-after-free.\n") like there's no
tomorrow...
Please stop with these automated conversions. They are going to cause a
lot more bugs than they fix.
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com
WARNING: multiple messages have this Message-ID (diff)
From: Trond Myklebust <trondmy-7I+n7zu2hftEKMMhf/gKZA@public.gmane.org>
To: "elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org"
<elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>,
"netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org"
<peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org>,
"ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org"
<ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org>,
"linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org"
<bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org>,
"steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org"
<steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org>,
"nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org"
<nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org>,
"linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jreuter-K7Hl1MveuGQ@public.gmane.org"
<jreuter-K7Hl1MveuGQ@public.gmane.org>,
"santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org"
<santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org>,
"linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
<linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
"jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org"
<jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>,
"dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org"
<dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
"keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org"
<keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
Subject: Re: [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t
Date: Fri, 17 Mar 2017 12:50:12 +0000 [thread overview]
Message-ID: <1489755011.6453.1.camel@primarydata.com> (raw)
In-Reply-To: <1489752646-8749-2-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
On Fri, 2017-03-17 at 14:10 +0200, Elena Reshetova wrote:
> refcount_t type and corresponding API should be
> used instead of atomic_t when the variable is used as
> a reference counter. This allows to avoid accidental
> refcounter overflows that might lead to use-after-free
> situations.
>
> Signed-off-by: Elena Reshetova <elena.reshetova@intel.com>
> Signed-off-by: Hans Liljestrand <ishkamiel@gmail.com>
> Signed-off-by: Kees Cook <keescook@chromium.org>
> Signed-off-by: David Windsor <dwindsor@gmail.com>
> ---
> include/linux/sunrpc/auth.h | 8 ++++----
> net/sunrpc/auth.c | 12 ++++++------
> 2 files changed, 10 insertions(+), 10 deletions(-)
>
> diff --git a/include/linux/sunrpc/auth.h
> b/include/linux/sunrpc/auth.h
> index b1bc62b..bd36e0b 100644
> --- a/include/linux/sunrpc/auth.h
> +++ b/include/linux/sunrpc/auth.h
> @@ -15,7 +15,7 @@
> #include <linux/sunrpc/msg_prot.h>
> #include <linux/sunrpc/xdr.h>
>
> -#include <linux/atomic.h>
> +#include <linux/refcount.h>
> #include <linux/rcupdate.h>
> #include <linux/uidgid.h>
> #include <linux/utsname.h>
> @@ -68,7 +68,7 @@ struct rpc_cred {
> #endif
> unsigned long cr_expire; /* when to gc
> */
> unsigned long cr_flags; /* various
> flags */
> - atomic_t cr_count; /* ref count */
> + refcount_t cr_count; /* ref count */
>
NACK. That's going to be hitting WARN_ONCE(!refcount_inc_not_zero(r),
"refcount_t: increment on 0; use-after-free.\n") like there's no
tomorrow...
Please stop with these automated conversions. They are going to cause a
lot more bugs than they fix.
--
Trond Myklebust
Linux NFS client maintainer, PrimaryData
trond.myklebust@primarydata.com
next prev parent reply other threads:[~2017-03-17 12:50 UTC|newest]
Thread overview: 80+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-03-17 12:10 [PATCH 00/23] various networking refcount conversions, part 2 Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
[not found] ` <1489752646-8749-2-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-17 12:50 ` Trond Myklebust [this message]
2017-03-17 12:50 ` Trond Myklebust
2017-03-17 12:50 ` Trond Myklebust
2017-03-17 12:50 ` Trond Myklebust
2017-03-17 12:50 ` Trond Myklebust
2017-03-17 13:02 ` Jeff Layton
2017-03-17 13:02 ` Jeff Layton
2017-03-17 13:02 ` Jeff Layton
[not found] ` <1489755736.2810.10.camel-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>
2017-03-17 14:28 ` Trond Myklebust
2017-03-17 14:28 ` Trond Myklebust
2017-03-17 14:28 ` Trond Myklebust
2017-03-17 14:28 ` Trond Myklebust
2017-03-20 16:15 ` Reshetova, Elena
2017-03-20 16:15 ` Reshetova, Elena
2017-03-20 16:15 ` Reshetova, Elena
2017-03-20 16:15 ` Reshetova, Elena
2017-03-17 12:10 ` [PATCH 02/23] net, sunrpc: convert gss_cl_ctx.count " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 03/23] net, sunrpc: convert gss_upcall_msg.count " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 04/23] net, ceph: convert ceph_snap_context.nref " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-24 13:20 ` Ilya Dryomov
2017-03-24 13:20 ` Ilya Dryomov
2017-03-17 12:10 ` [PATCH 05/23] net, ceph: convert ceph_osd.o_ref " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
[not found] ` <1489752646-8749-6-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-24 13:49 ` Ilya Dryomov
2017-03-24 13:49 ` Ilya Dryomov
2017-03-24 13:49 ` Ilya Dryomov
2017-03-17 12:10 ` [PATCH 06/23] net, ceph: convert ceph_pagelist.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
[not found] ` <1489752646-8749-7-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-24 13:49 ` Ilya Dryomov
2017-03-24 13:49 ` Ilya Dryomov
2017-03-24 13:49 ` Ilya Dryomov
2017-03-17 12:10 ` [PATCH 07/23] net, rds: convert rds_ib_device.refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 08/23] net, rds: convert rds_incoming.i_refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 09/23] net, rds: convert rds_mr.r_refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 11/23] net, x25: convert x25_route.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 12/23] net, x25: convert x25_neigh.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
[not found] ` <1489752646-8749-1-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-17 12:10 ` [PATCH 10/23] net, rds: convert rds_message.m_refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 13/23] net, xfrm: convert xfrm_state.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 14/23] net, xfrm: convert xfrm_policy.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 18/23] net, sctp: convert sctp_chunk.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 19/23] net, sctp: convert sctp_transport.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 21/23] net, ax25: convert ax25_uid_assoc.refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 22/23] net, ax25: convert ax25_route.refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 15/23] net, xfrm: convert sec_path.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 16/23] net, sctp: convert sctp_auth_bytes.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 17/23] net, sctp: convert sctp_datamsg.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 20/23] net, sctp: convert sctp_ep_common.refcnt " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
2017-03-17 12:10 ` [PATCH 23/23] net, ax25: convert ax25_cb.refcount " Elena Reshetova
2017-03-17 12:10 ` Elena Reshetova
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=1489755011.6453.1.camel@primarydata.com \
--to=trondmy-7i+n7zu2hftekmmhf/gkza@public.gmane.org \
--cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
--cc=dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
--cc=ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
--cc=jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org \
--cc=jreuter-K7Hl1MveuGQ@public.gmane.org \
--cc=keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org \
--cc=linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org \
--cc=peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org \
--cc=ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org \
--cc=santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
--cc=steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@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.