From: Alexander Gordeev <agordeev@linux.ibm.com>
To: Andrey Ryabinin <ryabinin.a.a@gmail.com>
Cc: Harry Yoo <harry.yoo@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>,
Daniel Axtens <dja@axtens.net>,
linux-kernel@vger.kernel.org, linux-mm@kvack.org,
kasan-dev@googlegroups.com, linux-s390@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH v3 1/1] kasan: Avoid sleepable page allocation from atomic context
Date: Tue, 6 May 2025 17:11:28 +0200 [thread overview]
Message-ID: <aBomoDkNgiEAJjgX@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com> (raw)
In-Reply-To: <d77f4afd-5d4e-4bd0-9c83-126e8ef5c4ed@gmail.com>
On Tue, May 06, 2025 at 04:55:20PM +0200, Andrey Ryabinin wrote:
> >>> - if (likely(pte_none(ptep_get(ptep)))) {
> >>> + if (likely(pte_none(ptep_get(ptep))))
> >>> set_pte_at(&init_mm, addr, ptep, pte);
> >>> - page = 0;
> >>
> >> With this patch, now if the pte is already set, the page is leaked?
> >
> > Yes. But currently it is leaked for previously allocated pages anyway,
> > so no change in behaviour (unless I misread the code).
>
> Current code doesn't even allocate page if pte set, and if set pte discovered only after
> taking spinlock, the page will be freed, not leaked.
Oh, right. I rather meant pages that are leaked in case of a failure. My bad.
> Whereas, this patch leaks page for every single !pte_none case. This will build up over time
> as long as vmalloc called.
>
> >
> >> Should we set data->pages[PFN_DOWN(addr - data->start)] = NULL
> >> and free non-null elements later in __kasan_populate_vmalloc()?
> >
> > Should the allocation fail on boot, the kernel would not fly anyway.
>
> This is not boot code, it's called from vmalloc() code path.
FWIW, it is called from rest_init() too.
> > If for whatever reason we want to free, that should be a follow-up
> > change, as far as I am concerned.
> >
> We want to free it, because we don't want unbound memory leak.
Will send v5.
Thanks!
next prev parent reply other threads:[~2025-05-06 15:12 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-29 16:08 [PATCH v3 0/1] " Alexander Gordeev
2025-04-29 16:08 ` [PATCH v3 1/1] " Alexander Gordeev
2025-04-29 23:04 ` Harry Yoo
2025-05-06 12:52 ` Alexander Gordeev
2025-05-06 14:55 ` Andrey Ryabinin
2025-05-06 15:11 ` Alexander Gordeev [this message]
2025-04-30 0:08 ` Andrew Morton
2025-05-01 0:51 ` kernel test robot
2025-05-01 3:22 ` kernel test robot
2025-05-01 9:04 ` kernel test robot
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=aBomoDkNgiEAJjgX@li-008a6a4c-3549-11b2-a85c-c5cc2836eea2.ibm.com \
--to=agordeev@linux.ibm.com \
--cc=akpm@linux-foundation.org \
--cc=dja@axtens.net \
--cc=harry.yoo@oracle.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=linux-s390@vger.kernel.org \
--cc=ryabinin.a.a@gmail.com \
--cc=stable@vger.kernel.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