From: Maurizio Lombardi <mlombard@redhat.com>
To: 愚树 <chen45464546@163.com>
Cc: Alexander Duyck <alexander.duyck@gmail.com>,
Jakub Kicinski <kuba@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
linux-mm <linux-mm@kvack.org>,
LKML <linux-kernel@vger.kernel.org>,
Netdev <netdev@vger.kernel.org>
Subject: Re: Re: [PATCH v2] mm: page_frag: Warn_on when frag_alloc size is bigger than PAGE_SIZE
Date: Fri, 8 Jul 2022 10:06:53 +0200 [thread overview]
Message-ID: <CAFL455=ZcU_fyM9kiuZUJeVmRv9Jx_FmURcweCrTXheRoKkSqg@mail.gmail.com> (raw)
In-Reply-To: <3498989.c69f.1811f41186e.Coremail.chen45464546@163.com>
st 1. 6. 2022 v 14:49 odesílatel 愚树 <chen45464546@163.com> napsal:
> Can we just add code to the relatively slow path to capture the mistake
> before it lead to memory corruption?
> Like:
> diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> index e6f211d..ac60a97 100644
> --- a/mm/page_alloc.c
> +++ b/mm/page_alloc.c
> @@ -5580,6 +5580,7 @@ void *page_frag_alloc_align(struct page_frag_cache *nc,
> /* reset page count bias and offset to start of new frag */
> nc->pagecnt_bias = PAGE_FRAG_CACHE_MAX_SIZE + 1;
> offset = size - fragsz;
> + BUG_ON(offset < 0);
> }
>
Personally, I'm not really convinced this is the best solution.
The next time a driver abuses the page_frag_alloc() interface, the
bug may go unnoticed for a long time...
until a server in production runs into OOM and crashes because it hits
the BUG_ON().
And why should the kernel panic? It's perfectly able to handle this
condition by failing
the allocation and returning NULL, and printing a warning maybe.
Maurizio
next prev parent reply other threads:[~2022-07-08 8:07 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-05-28 15:39 [PATCH] mm: page_frag: Warn_on when frag_alloc size is bigger than PAGE_SIZE Chen Lin
2022-05-29 23:30 ` Andrew Morton
2022-05-30 13:39 ` [PATCH v2] " Chen Lin
2022-05-30 19:27 ` Jakub Kicinski
2022-05-30 19:29 ` Jakub Kicinski
2022-05-31 14:41 ` Chen Lin
2022-05-31 15:14 ` Jakub Kicinski
2022-05-31 15:36 ` Chen Lin
2022-05-31 15:47 ` Jakub Kicinski
2022-05-31 18:28 ` Alexander Duyck
2022-06-01 12:32 ` 愚树
2022-06-01 15:04 ` Alexander Duyck
2022-07-06 15:21 ` Maurizio Lombardi
2022-07-08 8:06 ` Maurizio Lombardi [this message]
2022-05-30 20:07 ` Andrew Morton
2022-05-31 14:43 ` [PATCH v3] " Chen Lin
2022-05-31 23:45 ` Eric Dumazet
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='CAFL455=ZcU_fyM9kiuZUJeVmRv9Jx_FmURcweCrTXheRoKkSqg@mail.gmail.com' \
--to=mlombard@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=alexander.duyck@gmail.com \
--cc=chen45464546@163.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=netdev@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;
as well as URLs for NNTP newsgroup(s).