From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA021C2BA4C for ; Wed, 26 Jan 2022 12:10:05 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 399FD6B0074; Wed, 26 Jan 2022 07:10:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 349316B0075; Wed, 26 Jan 2022 07:10:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 211566B0078; Wed, 26 Jan 2022 07:10:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0084.hostedemail.com [216.40.44.84]) by kanga.kvack.org (Postfix) with ESMTP id 122966B0074 for ; Wed, 26 Jan 2022 07:10:05 -0500 (EST) Received: from smtpin06.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id CAB3D827CB7A for ; Wed, 26 Jan 2022 12:10:04 +0000 (UTC) X-FDA: 79072319928.06.6573BB0 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf26.hostedemail.com (Postfix) with ESMTP id 9BDAC14000C for ; Wed, 26 Jan 2022 12:10:03 +0000 (UTC) Received: from kwepemi100010.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4JkMrF2qH4zZfM0; Wed, 26 Jan 2022 20:06:05 +0800 (CST) Received: from kwepemm600017.china.huawei.com (7.193.23.234) by kwepemi100010.china.huawei.com (7.221.188.54) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan 2022 20:09:59 +0800 Received: from [10.174.179.19] (10.174.179.19) by kwepemm600017.china.huawei.com (7.193.23.234) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2308.21; Wed, 26 Jan 2022 20:09:59 +0800 Content-Type: multipart/alternative; boundary="------------0r5L9YsFuj0bn5CuUOBFgq1q" Message-ID: <1e219dd7-c2d0-1d1f-f662-2002311adef6@huawei.com> Date: Wed, 26 Jan 2022 20:09:58 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.3.2 Subject: Re: [PATCH RFC 1/3] kfence: Add a module parameter to adjust kfence objects Content-Language: en-US To: Marco Elver CC: , , , , , , , , , , References: <20220124025205.329752-1-liupeng256@huawei.com> <20220124025205.329752-2-liupeng256@huawei.com> <6eb16a68-9a56-7aea-3dd6-bd719a9ce700@huawei.com> From: "liupeng (DM)" In-Reply-To: X-Originating-IP: [10.174.179.19] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To kwepemm600017.china.huawei.com (7.193.23.234) X-CFilter-Loop: Reflected X-Rspamd-Server: rspam03 X-Rspamd-Queue-Id: 9BDAC14000C X-Stat-Signature: zo19771mnugbcstomff46acfu9gx384o Authentication-Results: imf26.hostedemail.com; dkim=none; spf=pass (imf26.hostedemail.com: domain of liupeng256@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=liupeng256@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-Rspam-User: nil X-HE-Tag: 1643199003-174333 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --------------0r5L9YsFuj0bn5CuUOBFgq1q Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit On 2022/1/24 19:55, Marco Elver wrote: > On Mon, 24 Jan 2022 at 12:45, Marco Elver wrote: >> [ FYI, your reply was not plain text, so LKML may have rejected it. I >> advise that you switch your email client for LKML emails to plain >> text. ] >> >> On Mon, 24 Jan 2022 at 12:24, liupeng (DM) wrote: >> [...] >>>> I think the only reasonable way forward is if you add immediate patching >>>> support to the kernel as the "Note" suggests. >>> May you give us more details about "immediate patching"? >> [...] >>> Thank you for your patient suggestions, it's actually helpful and inspired. >>> We have integrated your latest work "skipping already covered allocations", >>> and will do more experiments about KFENCE. Finally, we really hope you can >>> give us more introductions about "immediate patching". >> "Immediate patching" would, similar to "static branches" or >> "alternatives" be based on code hot patching. >> >> https://www.kernel.org/doc/html/latest/staging/static-keys.html >> >> "Patching immediates" would essentially patch the immediate operands >> of certain (limited) instructions. I think designing this properly to >> work across various architectures (like static_keys/jump_label) is >> very complex. So it may not be a viable near-term option. >> >> What Dmitry suggests using a constant virtual address carveout is more >> realistic. But this means having to discuss with arch maintainers >> which virtual address ranges can be reserved. The nice thing about >> just relying on memblock and nothing else is that it is very portable >> and simple. You can have a look at how KASAN deals with organizing its >> shadow memory if you are interested. > Hmm, there may be more issues lurking here: > > https://lore.kernel.org/all/20200929140226.GB53442@C02TD0UTHF1T.local/ > https://lore.kernel.org/all/20200929142411.GC53442@C02TD0UTHF1T.local/ > > ... and I'm guessing if we assign a fixed virtual address range it'll > live outside the linear mapping, which is likely to break certain > requirements of kmalloc()'d allocations in certain situations (a > problem we had with v1 of KFENCE on arm64). > > So I don't even know if that's feasible. :-/ > > Thanks, > -- Marco > . Thank you very much, we will try the suggestions you give. Thanks, -- Peng Liu . --------------0r5L9YsFuj0bn5CuUOBFgq1q Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 7bit
On 2022/1/24 19:55, Marco Elver wrote:
On Mon, 24 Jan 2022 at 12:45, Marco Elver <elver@google.com> wrote:
[ FYI, your reply was not plain text, so LKML may have rejected it. I
advise that you switch your email client for LKML emails to plain
text. ]

On Mon, 24 Jan 2022 at 12:24, liupeng (DM) <liupeng256@huawei.com> wrote:
[...]
I think the only reasonable way forward is if you add immediate patching
support to the kernel as the "Note" suggests.
May you give us more details about "immediate patching"?
[...]
Thank you for your patient suggestions, it's actually helpful and inspired.
We have integrated your latest work "skipping already covered allocations",
and will do more experiments about KFENCE. Finally, we really hope you can
give us more introductions about "immediate patching".
"Immediate patching" would, similar to "static branches" or
"alternatives" be based on code hot patching.

https://www.kernel.org/doc/html/latest/staging/static-keys.html

"Patching immediates" would essentially patch the immediate operands
of certain (limited) instructions. I think designing this properly to
work across various architectures (like static_keys/jump_label) is
very complex. So it may not be a viable near-term option.

What Dmitry suggests using a constant virtual address carveout is more
realistic. But this means having to discuss with arch maintainers
which virtual address ranges can be reserved. The nice thing about
just relying on memblock and nothing else is that it is very portable
and simple. You can have a look at how KASAN deals with organizing its
shadow memory if you are interested.
Hmm, there may be more issues lurking here:

https://lore.kernel.org/all/20200929140226.GB53442@C02TD0UTHF1T.local/
https://lore.kernel.org/all/20200929142411.GC53442@C02TD0UTHF1T.local/

... and I'm guessing if we assign a fixed virtual address range it'll
live outside the linear mapping, which is likely to break certain
requirements of kmalloc()'d allocations in certain situations (a
problem we had with v1 of KFENCE on arm64).

So I don't even know if that's feasible. :-/

Thanks,
-- Marco
.
Thank you very much, we will try the suggestions you give.

Thanks,
-- Peng Liu
.
--------------0r5L9YsFuj0bn5CuUOBFgq1q--