From: Marco Elver <elver@google.com>
To: Andrey Konovalov <andreyknvl@gmail.com>
Cc: Sabyrzhan Tasbolatov <snovitoll@gmail.com>,
akpm@linux-foundation.org, bpf@vger.kernel.org,
dvyukov@google.com, glider@google.com,
kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org,
linux-mm@kvack.org, ryabinin.a.a@gmail.com,
syzbot+61123a5daeb9f7454599@syzkaller.appspotmail.com,
vincenzo.frascino@arm.com
Subject: Re: [PATCH v4] mm, kasan, kmsan: copy_from/to_kernel_nofault
Date: Wed, 9 Oct 2024 22:34:43 +0200 [thread overview]
Message-ID: <CANpmjNNPnEMBxF1-Lr_BACmPYxOTRa=k6Vwi=EFR=BED=G8akg@mail.gmail.com> (raw)
In-Reply-To: <CA+fCnZeMRZZe4A0QW4SSnEgXFEnb287PgHd5hVq8AA4itBFxEQ@mail.gmail.com>
On Wed, 9 Oct 2024 at 22:19, Andrey Konovalov <andreyknvl@gmail.com> wrote:
[...]
> Please add a comment here explaining why we only check
> copy_to_kernel_nofault and not copy_from_kernel_nofault (is this
> because we cannot add KASAN instrumentation to
> copy_from_kernel_nofault?).
Just to clarify: Unless we can prove that there won't be any false
positives, I proposed to err on the side of being conservative here.
The new way of doing it after we already checked that the accessed
location is on a faulted-in page may be amenable to also KASAN
instrumentation, but you can also come up with cases that would be a
false positive: e.g. some copy_from_kernel_nofault() for a large
range, knowing that if it accesses bad memory at least one page is not
faulted in, but some initial pages may be faulted in; in that case
there'd be some error handling that then deals with the failure.
Again, this might be something that an eBPF program could legally do.
On the other hand, we may want to know if we are leaking random
uninitialized kernel memory with KMSAN to avoid infoleaks.
Only copy_to_kernel_nofault should really have valid memory, otherwise
we risk corrupting the kernel. But these checks should only happen
after we know we're accessing faulted-in memory, again to avoid false
positives.
next prev parent reply other threads:[~2024-10-09 20:35 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-05 9:23 [PATCH] mm, kmsan: instrument copy_from_kernel_nofault Sabyrzhan Tasbolatov
2024-10-05 10:36 ` Marco Elver
2024-10-05 16:48 ` [PATCH v2 0/1] mm, kasan, kmsan: copy_from/to_kernel_nofault Sabyrzhan Tasbolatov
2024-10-05 16:48 ` [PATCH v2 1/1] " Sabyrzhan Tasbolatov
2024-10-08 8:31 ` Marco Elver
2024-10-08 8:46 ` Sabyrzhan Tasbolatov
2024-10-08 9:27 ` Marco Elver
2024-10-08 10:15 ` [PATCH v3] " Sabyrzhan Tasbolatov
2024-10-08 11:35 ` Marco Elver
2024-10-08 19:29 ` [PATCH v4] " Sabyrzhan Tasbolatov
2024-10-08 19:34 ` Marco Elver
2024-10-08 19:42 ` Sabyrzhan Tasbolatov
2024-10-09 21:39 ` Andrew Morton
2024-10-09 20:18 ` Andrey Konovalov
2024-10-09 20:34 ` Marco Elver [this message]
2024-10-10 13:11 ` [PATCH v5] " Sabyrzhan Tasbolatov
2024-10-10 21:39 ` Andrey Konovalov
2024-10-11 3:53 ` [PATCH v6] " Sabyrzhan Tasbolatov
2024-10-12 22:45 ` Andrey Konovalov
2024-10-15 11:05 ` Sabyrzhan Tasbolatov
2024-10-08 19:39 ` [PATCH v3] " Sabyrzhan Tasbolatov
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='CANpmjNNPnEMBxF1-Lr_BACmPYxOTRa=k6Vwi=EFR=BED=G8akg@mail.gmail.com' \
--to=elver@google.com \
--cc=akpm@linux-foundation.org \
--cc=andreyknvl@gmail.com \
--cc=bpf@vger.kernel.org \
--cc=dvyukov@google.com \
--cc=glider@google.com \
--cc=kasan-dev@googlegroups.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=ryabinin.a.a@gmail.com \
--cc=snovitoll@gmail.com \
--cc=syzbot+61123a5daeb9f7454599@syzkaller.appspotmail.com \
--cc=vincenzo.frascino@arm.com \
/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