From: Alexander Potapenko <glider@google.com>
To: Matthew Wilcox <willy@infradead.org>
Cc: Michal Hocko <mhocko@suse.com>, Arnd Bergmann <arnd@kernel.org>,
Andrew Morton <akpm@linux-foundation.org>,
Alexander Duyck <alexander.h.duyck@linux.intel.com>,
Arnd Bergmann <arnd@arndb.de>,
David Hildenbrand <david@redhat.com>,
"Liam R. Howlett" <Liam.Howlett@oracle.com>,
John Hubbard <jhubbard@nvidia.com>,
Naoya Horiguchi <naoya.horiguchi@nec.com>,
Hugh Dickins <hughd@google.com>,
Suren Baghdasaryan <surenb@google.com>,
Alex Sierra <alex.sierra@amd.com>,
linux-mm@kvack.org, linux-kernel@vger.kernel.org,
pasha.tatashin@soleen.com
Subject: Re: [PATCH] mm: extend max struct page size for kmsan
Date: Mon, 30 Jan 2023 19:20:40 +0100 [thread overview]
Message-ID: <CAG_fn=XaOnr5n2UoT5xzYXYPvgGXwJD_1+u-BFDo=Mv17V=-NA@mail.gmail.com> (raw)
In-Reply-To: <Y9f0tkiXUoQexGsS@casper.infradead.org>
> > I haven't really followed KMSAN development but I would have expected
> > that it would, like other debugging tools, add its metadata to page_ext
> > rather than page directly.
>
> Yes, that would have been preferable. Also, I don't understand why we
> need an entire page to store whether each "bit" of a page is initialised.
> There are no CPUs which have bit-granularity stores; either you initialise
> an entire byte or not. So that metadata can shrink from 4096 bytes
> to 512.
It's not about bit-granularity stores, it's about bits being
uninitialized or not.
Consider the following struct:
struct foo {
char a:4;
char b:4;
} f;
- if the user initializes f.a and then tries to use f.b, this is still
undefined behavior that KMSAN is able to catch thanks to bit-to-bit
shadow, but would not have been able to detect if we only stored one
bit per byte.
Another example is bit flags or bit masks, where you can set a single
bit in an int32, but that wouldn't necessarily mean the rest of that
variable is initialized.
It's worth mentioning that even if we choose to shrink the shadows
from 4096 to 512 bytes, there'd still be four-byte origin IDs, which
are allocated for every four bytes of program memory.
So a whole page of origins will still be required in addition to those
512 bytes of shadow.
(Origins are handy when debugging KMSAN reports, because a single
uninit value can be copied or modified multiple times before it is
used in a branch or passed to the userspace.
Shrinking origins further would render them useless for e.g. 32-bit
local variables, which is a quite common use case).
next prev parent reply other threads:[~2023-01-30 18:21 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-30 13:07 Arnd Bergmann
2023-01-30 13:38 ` Michal Hocko
2023-01-30 16:47 ` Matthew Wilcox
2023-01-30 18:20 ` Alexander Potapenko [this message]
2023-01-30 17:59 ` Alexander Potapenko
2023-01-31 15:14 ` Michal Hocko
2023-01-31 15:17 ` Alexander Potapenko
2023-01-31 16:03 ` Alexander Potapenko
2023-01-30 16:29 ` Alexander Duyck
2023-01-30 17:19 ` Pasha Tatashin
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='CAG_fn=XaOnr5n2UoT5xzYXYPvgGXwJD_1+u-BFDo=Mv17V=-NA@mail.gmail.com' \
--to=glider@google.com \
--cc=Liam.Howlett@oracle.com \
--cc=akpm@linux-foundation.org \
--cc=alex.sierra@amd.com \
--cc=alexander.h.duyck@linux.intel.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=david@redhat.com \
--cc=hughd@google.com \
--cc=jhubbard@nvidia.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=mhocko@suse.com \
--cc=naoya.horiguchi@nec.com \
--cc=pasha.tatashin@soleen.com \
--cc=surenb@google.com \
--cc=willy@infradead.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