[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YXhbq/6OIpIAr7Tx@casper.infradead.org>
Date: Tue, 26 Oct 2021 20:48:59 +0100
From: Matthew Wilcox <willy@...radead.org>
To: Pasha Tatashin <pasha.tatashin@...een.com>
Cc: linux-kernel@...r.kernel.org, linux-mm@...ck.org,
linux-m68k@...ts.linux-m68k.org, anshuman.khandual@....com,
akpm@...ux-foundation.org, william.kucharski@...cle.com,
mike.kravetz@...cle.com, vbabka@...e.cz, geert@...ux-m68k.org,
schmitzmic@...il.com, rostedt@...dmis.org, mingo@...hat.com,
hannes@...xchg.org, guro@...com, songmuchun@...edance.com,
weixugc@...gle.com, gthelen@...gle.com
Subject: Re: [RFC 1/8] mm: add overflow and underflow checks for
page->_refcount
On Tue, Oct 26, 2021 at 05:38:15PM +0000, Pasha Tatashin wrote:
> static inline void page_ref_add(struct page *page, int nr)
> {
> - atomic_add(nr, &page->_refcount);
> + int ret;
> +
> + VM_BUG_ON(nr <= 0);
> + ret = atomic_add_return(nr, &page->_refcount);
> + VM_BUG_ON_PAGE(ret <= 0, page);
This isn't right. _refcount is allowed to overflow into the negatives.
See page_ref_zero_or_close_to_overflow() and the conversations that led
to it being added.
Powered by blists - more mailing lists