[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXu5jK3x+cPe4pccv0Q5W+9eDxu7n3Enih-TVRkysmwDwzGCA@mail.gmail.com>
Date: Wed, 8 Mar 2017 12:06:49 -0800
From: Kees Cook <keescook@...omium.org>
To: Christoph Hellwig <hch@...radead.org>
Cc: Elena Reshetova <elena.reshetova@...el.com>,
darrick.wong@...cle.com, LKML <linux-kernel@...r.kernel.org>,
linux-xfs@...r.kernel.org, Hans Liljestrand <ishkamiel@...il.com>,
David Windsor <dwindsor@...il.com>
Subject: Re: [PATCH 3/5] fs, xfs: convert xlog_ticket.t_ref from atomic_t to refcount_t
On Wed, Mar 8, 2017 at 7:50 AM, Christoph Hellwig <hch@...radead.org> wrote:
>> - ASSERT(atomic_read(&ticket->t_ref) > 0);
>> - atomic_inc(&ticket->t_ref);
>> + ASSERT(refcount_read(&ticket->t_ref) > 0);
>> + refcount_inc(&ticket->t_ref);
>
> With strict refcount semantics refcount_inc should check that
> the count is larger than 0, otherwise we'd need to use
> recount_inc_not_zero or whatever you're going to call it.
>
> Is that something the recount code does / could do?
Yes, refcount_inc() will not increment from 0 and WARNs. It looks like
xfs's ASSERT is also a warn (though with XFS-specific formatting), so
perhaps the ASSERT could be dropped? IIUC, Elena's approach to these
changes was to be conservative about removing the existing checks.
-Kees
--
Kees Cook
Pixel Security
Powered by blists - more mailing lists