Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp2810274pxb; Mon, 25 Apr 2022 03:03:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxAEm5KwU5SYAXf2A2xP9XJ/1n2EhEY1qlB08WqMyp/z+1X07Hwu+vqFevngzgRxA5tnexw X-Received: by 2002:a05:6402:1583:b0:425:de1e:d0ed with SMTP id c3-20020a056402158300b00425de1ed0edmr6979758edv.385.1650881007983; Mon, 25 Apr 2022 03:03:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650881007; cv=none; d=google.com; s=arc-20160816; b=iAoVZ42XG2+lGVayJymsFcIg64jK+7j0+tl0G5k7PB92kqdufWW0LMFUy+8bpwE0wg 2EaLWuXRpJ21Dj7sY0KucchQJdOcB0xStXYlf9U5xeRCe/v76dU/QYOacFJIAm7WWoUm 5yFUr8W6lzEphO3Dji8GgwNxXr3aTGqbUg4jTEFt/3PVkdMjmah6DcKqXAZoUtI8loPK Z81JlQ02IgsQnW+qZGzuW0qY94h5EN/oyYoE5GbrFJR9QG3ty9y0KRoar5D5IJX5CIFC YRz8pq7ZVwHwpitBMr0111FJBW0P1B9o9DVf7nqKaHliTuBgMLiaEj4lGeHWjHzSvgqy OcYQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=gnNnns2O0civrmjFz4szfFflY9glkzlEAvPz+SeLb6Y=; b=aYfbKf+POeaLXDywXFphMYpxUY4dPX0kmMOhQiCIWRtpO7IKiG+kB2Y9VmiT/dXnUz jGxB1v8KkIjdeQLqkzKrEzwSjvfoAY5H5Ta+wYtVvxfuvpqEPN7EK1O5xG62Y42i+75B uKqKFay6X7/5DKso7QLB6yzKAtcAQSCYHXzcB3KspWGqoVtKW8K1n4lXmjVcOjRk9GT1 +b0uPK4GjxAFqIN2rhkrheuE05Q30hoa9RHRd1OxFgIbC6q5l5XUKORJe2rcd7qkpTwa EElzMSIzadx3KumTRaUJcOl61sHBEYDDFe7LKCmwf9A61Ftqnpwp1/r0BqNoPvkj6Rn9 6BVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ss4-20020a170907038400b006f3786d89f6si4212147ejb.53.2022.04.25.03.02.38; Mon, 25 Apr 2022 03:03:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240117AbiDYB0o (ORCPT + 99 others); Sun, 24 Apr 2022 21:26:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34964 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233946AbiDYB0l (ORCPT ); Sun, 24 Apr 2022 21:26:41 -0400 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75B8EC0E52 for ; Sun, 24 Apr 2022 18:23:38 -0700 (PDT) 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: 7BIT Content-Type: text/plain; charset=US-ASCII 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-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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