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 C4B3CC433EF for ; Mon, 25 Apr 2022 01:23:42 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 163646B0088; Sun, 24 Apr 2022 21:23:42 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 113066B0089; Sun, 24 Apr 2022 21:23:42 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id F1CA36B008A; Sun, 24 Apr 2022 21:23:41 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.hostedemail.com [64.99.140.25]) by kanga.kvack.org (Postfix) with ESMTP id DF15E6B0088 for ; Sun, 24 Apr 2022 21:23:41 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id B008D620CF for ; Mon, 25 Apr 2022 01:23:41 +0000 (UTC) X-FDA: 79393654242.03.AC2234F Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by imf11.hostedemail.com (Postfix) with ESMTP id E9C374003C for ; Mon, 25 Apr 2022 01:23:37 +0000 (UTC) Received: from kwepemi500013.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4KmnMd32KSzhYf0; Mon, 25 Apr 2022 09:23:25 +0800 (CST) Received: from kwepemm600020.china.huawei.com (7.193.23.147) by kwepemi500013.china.huawei.com (7.221.188.120) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Apr 2022 09:23:36 +0800 Received: from DESKTOP-E0KHRBE.china.huawei.com (10.67.111.5) by kwepemm600020.china.huawei.com (7.193.23.147) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Mon, 25 Apr 2022 09:23:35 +0800 From: Shaobo Huang To: CC: , , , , , , , , , , , , , Subject: Re: [PATCH v2] kfence: enable check kfence canary in panic via boot param Date: Mon, 25 Apr 2022 09:23:34 +0800 Message-ID: <20220425012334.46364-1-huangshaobo6@huawei.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.67.111.5] X-ClientProxiedBy: dggems705-chm.china.huawei.com (10.3.19.182) To kwepemm600020.china.huawei.com (7.193.23.147) X-CFilter-Loop: Reflected X-Stat-Signature: zbq76gm8nazq7i4eq7955kweky8qoamz X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: E9C374003C X-Rspam-User: Authentication-Results: imf11.hostedemail.com; dkim=none; spf=pass (imf11.hostedemail.com: domain of huangshaobo6@huawei.com designates 45.249.212.187 as permitted sender) smtp.mailfrom=huangshaobo6@huawei.com; dmarc=pass (policy=quarantine) header.from=huawei.com X-HE-Tag: 1650849817-303336 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000118, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Sun, 24 Apr 2022 15:31:42 +0200, Marco Elver wrote: > On Sun, 24 Apr 2022 at 13:00, Shaobo Huang wrote: > > > > From: huangshaobo > > > > when writing out of bounds to the red zone, it can only be > > detected at kfree. However, the system may have been reset > > before freeing the memory, which would result in undetected > > oob. Therefore, it is necessary to detect oob behavior in > > panic. Since only the allocated mem call stack is available, > > it may be difficult to find the oob maker. Therefore, this > > feature is disabled by default and can only be enabled via > > boot parameter. > > This description is still not telling the full story or usecase. The > story goes something like: > """ > Out-of-bounds accesses that aren't caught by a guard page will result > in corruption of canary memory. In pathological cases, where an object > has certain alignment requirements, an out-of-bounds access might > never be caught by the guard page. Such corruptions, however, are only > detected on kfree() normally. If the bug causes the kernel to panic > before kfree(), KFENCE has no opportunity to report the issue. Such > corruptions may also indicate failing memory or other faults. > > To provide some more information in such cases, add the option to > check canary bytes on panic. This might help narrow the search for the > panic cause; but, due to only having the allocation stack trace, such > reports are difficult to use to diagnose an issue alone. In most > cases, such reports are inactionable, and is therefore an opt-in > feature (disabled by default). > """ > > Please feel free to copy or take pieces above to complete the commit message. > > [...] > > #include > > #include > > #include > > +#include > > +#include > > Please keep these includes sorted alphabetically. > > [...] > > +/* If true, check kfence canary in panic. */ > > It should be "on panic". E.g. "If true, check all canary bytes on panic." > > [...] > > +/* === Panic Notifier ====================================================== */ > > Blank line between /* === ... */ and function. thank you so much for your suggestion! thanks, ShaoBo Huang