linux-x25.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: Elena Reshetova
	<elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: netdev <netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org"
	<linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	"David S. Miller" <davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org>,
	linux-x25-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-sctp-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	vyasevich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	nhorman-2XuSBdqkA4R54TAoqtyWWQ@public.gmane.org,
	linux-hams-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Ceph Development
	<ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
	"Yan, Zheng" <zyan-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	Sage Weil <sage-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org>,
	bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org,
	Jeff Layton <jlayton-vpEMnDpepFuMZCB2o+C8xQ@public.gmane.org>,
	steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org,
	Herbert Xu
	<herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@public.gmane.org>,
	santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org,
	jreuter-K7Hl1MveuGQ@public.gmane.org,
	ralf-6z/3iImG2C8G8FEW9MqTrA@public.gmane.org,
	peterz-wEGCiKHe2LqWVfeAwA7xHQ@public.gmane.org,
	Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>,
	Hans Liljestrand
	<ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>,
	David Windsor <dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Subject: Re: [PATCH 06/23] net, ceph: convert ceph_pagelist.refcnt from atomic_t to refcount_t
Date: Fri, 24 Mar 2017 14:49:48 +0100	[thread overview]
Message-ID: <CAOi1vP8BeC5R8CU0_NpbFBXA_JpVfbBzxyVsAne+9JGkOgPbKA@mail.gmail.com> (raw)
In-Reply-To: <1489752646-8749-7-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>

On Fri, Mar 17, 2017 at 1:10 PM, Elena Reshetova
<elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org> 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-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Hans Liljestrand <ishkamiel-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> Signed-off-by: Kees Cook <keescook-F7+t8E8rja9g9hUCZPvPmw@public.gmane.org>
> Signed-off-by: David Windsor <dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  fs/ceph/mds_client.c          | 2 +-
>  include/linux/ceph/pagelist.h | 6 +++---
>  net/ceph/pagelist.c           | 2 +-
>  3 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
> index c681762..7b38e6c 100644
> --- a/fs/ceph/mds_client.c
> +++ b/fs/ceph/mds_client.c
> @@ -1991,7 +1991,7 @@ static struct ceph_msg *create_request_message(struct ceph_mds_client *mdsc,
>
>         if (req->r_pagelist) {
>                 struct ceph_pagelist *pagelist = req->r_pagelist;
> -               atomic_inc(&pagelist->refcnt);
> +               refcount_inc(&pagelist->refcnt);
>                 ceph_msg_data_add_pagelist(msg, pagelist);
>                 msg->hdr.data_len = cpu_to_le32(pagelist->length);
>         } else {
> diff --git a/include/linux/ceph/pagelist.h b/include/linux/ceph/pagelist.h
> index 13d71fe..75a7db2 100644
> --- a/include/linux/ceph/pagelist.h
> +++ b/include/linux/ceph/pagelist.h
> @@ -2,7 +2,7 @@
>  #define __FS_CEPH_PAGELIST_H
>
>  #include <asm/byteorder.h>
> -#include <linux/atomic.h>
> +#include <linux/refcount.h>
>  #include <linux/list.h>
>  #include <linux/types.h>
>
> @@ -13,7 +13,7 @@ struct ceph_pagelist {
>         size_t room;
>         struct list_head free_list;
>         size_t num_pages_free;
> -       atomic_t refcnt;
> +       refcount_t refcnt;
>  };
>
>  struct ceph_pagelist_cursor {
> @@ -30,7 +30,7 @@ static inline void ceph_pagelist_init(struct ceph_pagelist *pl)
>         pl->room = 0;
>         INIT_LIST_HEAD(&pl->free_list);
>         pl->num_pages_free = 0;
> -       atomic_set(&pl->refcnt, 1);
> +       refcount_set(&pl->refcnt, 1);
>  }
>
>  extern void ceph_pagelist_release(struct ceph_pagelist *pl);
> diff --git a/net/ceph/pagelist.c b/net/ceph/pagelist.c
> index 6864007..ce09f73 100644
> --- a/net/ceph/pagelist.c
> +++ b/net/ceph/pagelist.c
> @@ -16,7 +16,7 @@ static void ceph_pagelist_unmap_tail(struct ceph_pagelist *pl)
>
>  void ceph_pagelist_release(struct ceph_pagelist *pl)
>  {
> -       if (!atomic_dec_and_test(&pl->refcnt))
> +       if (!refcount_dec_and_test(&pl->refcnt))
>                 return;
>         ceph_pagelist_unmap_tail(pl);
>         while (!list_empty(&pl->head)) {

Applied.

Thanks,

                Ilya
--
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

  parent reply	other threads:[~2017-03-24 13:49 UTC|newest]

Thread overview: 31+ 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 ` [PATCH 01/23] net, sunrpc: convert rpc_cred.cr_count from atomic_t to refcount_t Elena Reshetova
     [not found]   ` <1489752646-8749-2-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-17 12:50     ` Trond Myklebust
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-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 ` [PATCH 03/23] net, sunrpc: convert gss_upcall_msg.count " Elena Reshetova
2017-03-17 12:10 ` [PATCH 04/23] net, ceph: convert ceph_snap_context.nref " Elena Reshetova
2017-03-24 13:20   ` Ilya Dryomov
2017-03-17 12:10 ` [PATCH 05/23] net, ceph: convert ceph_osd.o_ref " 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-17 12:10 ` [PATCH 06/23] net, ceph: convert ceph_pagelist.refcnt " Elena Reshetova
     [not found]   ` <1489752646-8749-7-git-send-email-elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2017-03-24 13:49     ` Ilya Dryomov [this message]
2017-03-17 12:10 ` [PATCH 07/23] net, rds: convert rds_ib_device.refcount " Elena Reshetova
2017-03-17 12:10 ` [PATCH 08/23] net, rds: convert rds_incoming.i_refcount " Elena Reshetova
2017-03-17 12:10 ` [PATCH 09/23] net, rds: convert rds_mr.r_refcount " 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   ` [PATCH 13/23] net, xfrm: convert xfrm_state.refcnt " Elena Reshetova
2017-03-17 12:10   ` [PATCH 14/23] net, xfrm: convert xfrm_policy.refcnt " Elena Reshetova
2017-03-17 12:10   ` [PATCH 18/23] net, sctp: convert sctp_chunk.refcnt " Elena Reshetova
2017-03-17 12:10   ` [PATCH 19/23] net, sctp: convert sctp_transport.refcnt " Elena Reshetova
2017-03-17 12:10   ` [PATCH 21/23] net, ax25: convert ax25_uid_assoc.refcount " Elena Reshetova
2017-03-17 12:10   ` [PATCH 22/23] net, ax25: convert ax25_route.refcount " Elena Reshetova
2017-03-17 12:10 ` [PATCH 11/23] net, x25: convert x25_route.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 12/23] net, x25: convert x25_neigh.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 15/23] net, xfrm: convert sec_path.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 16/23] net, sctp: convert sctp_auth_bytes.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 17/23] net, sctp: convert sctp_datamsg.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 20/23] net, sctp: convert sctp_ep_common.refcnt " Elena Reshetova
2017-03-17 12:10 ` [PATCH 23/23] net, ax25: convert ax25_cb.refcount " 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=CAOi1vP8BeC5R8CU0_NpbFBXA_JpVfbBzxyVsAne+9JGkOgPbKA@mail.gmail.com \
    --to=idryomov-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org \
    --cc=ceph-devel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org \
    --cc=dwindsor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=elena.reshetova-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=herbert-lOAM2aK0SrRLBo1qDEOMRrpzq4S04n8Q@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=linux-sctp-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=linux-x25-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=sage-H+wXaHxf7aLQT0dZR+AlfA@public.gmane.org \
    --cc=santosh.shilimkar-QHcLZuEGTsvQT0dZR+AlfA@public.gmane.org \
    --cc=steffen.klassert-opNxpl+3fjRBDgjK7y7TUQ@public.gmane.org \
    --cc=vyasevich-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=zyan-H+wXaHxf7aLQT0dZR+AlfA@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 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 read-only IMAP folder(s) and NNTP newsgroup(s).