[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YgUSxzp/qDwLkiKb@casper.infradead.org>
Date: Thu, 10 Feb 2022 13:27:35 +0000
From: Matthew Wilcox <willy@...radead.org>
To: Suren Baghdasaryan <surenb@...gle.com>
Cc: akpm@...ux-foundation.org, ccross@...gle.com,
sumit.semwal@...aro.org, mhocko@...e.com, dave.hansen@...el.com,
keescook@...omium.org, kirill.shutemov@...ux.intel.com,
vbabka@...e.cz, hannes@...xchg.org, ebiederm@...ssion.com,
brauner@...nel.org, legion@...nel.org, ran.xiaokai@....com.cn,
sashal@...nel.org, chris.hyser@...cle.com, dave@...olabs.net,
pcc@...gle.com, caoxiaofeng@...ong.com, david@...hat.com,
gorcunov@...il.com, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, kernel-team@...roid.com,
syzbot+aa7b3d4b35f9dc46a366@...kaller.appspotmail.com
Subject: Re: [PATCH v2 1/1] mm: fix use-after-free when anon vma name is used
after vma is freed
On Wed, Feb 09, 2022 at 08:32:15PM -0800, Suren Baghdasaryan wrote:
> +void vma_anon_name_put(struct anon_vma_name *anon_name)
> +{
> + kref_put(&anon_name->kref, vma_anon_name_free);
> +}
To agree with Michal, make this:
if (anon_name)
kref_put(&anon_name->kref, vma_anon_name_free);
>
> - error = madvise_update_vma(vma, prev, start, end, new_flags,
> - vma_anon_name(vma));
> + anon_name = vma_anon_name_get(vma);
> + if (anon_name) {
> + error = madvise_update_vma(vma, prev, start, end, new_flags,
> + anon_name->name);
> + vma_anon_name_put(anon_name);
> + } else {
> + error = madvise_update_vma(vma, prev, start, end, new_flags,
> + NULL);
> + }
And then this becomes:
anon_name = vma_anon_name_get(vma);
error = madvise_update_vma(vma, prev, start, end, new_flags, anon_name);
vma_anon_name_put(anon_name);
Powered by blists - more mailing lists