net, rds: convert rds_mr.r_refcount from atomic_t to refcount_t

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>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Reshetova, Elena
2017-07-04 15:53:17 +03:00
committed by David S. Miller
parent b7f0292094
commit 803ea85053
2 changed files with 7 additions and 7 deletions

View File

@@ -277,7 +277,7 @@ struct rds_incoming {
struct rds_mr {
struct rb_node r_rb_node;
atomic_t r_refcount;
refcount_t r_refcount;
u32 r_key;
/* A copy of the creation flags */
@@ -857,7 +857,7 @@ int rds_cmsg_atomic(struct rds_sock *rs, struct rds_message *rm,
void __rds_put_mr_final(struct rds_mr *mr);
static inline void rds_mr_put(struct rds_mr *mr)
{
if (atomic_dec_and_test(&mr->r_refcount))
if (refcount_dec_and_test(&mr->r_refcount))
__rds_put_mr_final(mr);
}