Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1207010pxk; Thu, 10 Sep 2020 09:31:43 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzEJZ0kFZkr1wNdU97EyEVWg+5dUdXqPKUvzvBsPEu1KlSX8m4yxA48178v4JJ2LKZ/7ikh X-Received: by 2002:a17:906:3755:: with SMTP id e21mr9655279ejc.39.1599755503111; Thu, 10 Sep 2020 09:31:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599755503; cv=none; d=google.com; s=arc-20160816; b=V3nRmuoMwkSV9Zci3C/R5i4rVxK9Omtb++hT1lIBpP/41il2HAshMVHp5RI/6sBarb Nnq7j5MysdX7shImhMr10eO08My97VjW0ZVOPhVZ69OvxkHzSO6nth3mecbMY7n1jJfF oSnFzLk8moXtmc/xSSo4eK1jLUkHRhiT1ZlYgtD4ssTpbyb+wcK6KagReEuDZqH9eKmm i74XPm29NwyQuq7t8yvA9V7SbIFvARtZrKl8182iBoHYHNuDwV6wR5xHFsMy1PUTU4Ri AIonR19/f8iwaQr9OpKL/7jFP129HjSKCzpCMhWpGQubjjv986EzT8GrDZw7H/J5ekxC pv5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=2DiBsMVuHaQKweeTOQHLBykKJQg8tEScxOxVWMIr6f4=; b=q601BU1lc0FbrGegkHl0mfXHrvB0x3fpbwyi/NZyINzZNdQNN5jUAZSjngAGD8zK/C 1HLpPumzyHej9oKczINM2u3xZT9FF5ftI6+GWElVnBvOHR1fiknB3hkhZxZgnqs/kPEh 2bR9X3kGxc3W2REEaR8lBvDeLpocN7Cl55Ky52myAkmTwLWKHYP6Z9xXK6QMRHawfid0 KLzy+P0g4kSaP7Zz5127HjQaFQlU4m/Eamvfbe5vE1CHtvf0qti4vJQYFjS3CSjhBcAO eKbsJwXpz5qsf914TaRgU/3MVLpYTWfobtMKEv+t6MNb5qVvigupQmjJqEEjGgtR5X5L SnoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d7rj+8Qp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q21si3846282eds.392.2020.09.10.09.31.20; Thu, 10 Sep 2020 09:31:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=d7rj+8Qp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726833AbgIJQaE (ORCPT + 99 others); Thu, 10 Sep 2020 12:30:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbgIJQ1v (ORCPT ); Thu, 10 Sep 2020 12:27:51 -0400 Received: from mail-ot1-x344.google.com (mail-ot1-x344.google.com [IPv6:2607:f8b0:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6B7CCC0617BE for ; Thu, 10 Sep 2020 08:06:38 -0700 (PDT) Received: by mail-ot1-x344.google.com with SMTP id u25so5620139otq.6 for ; Thu, 10 Sep 2020 08:06:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=2DiBsMVuHaQKweeTOQHLBykKJQg8tEScxOxVWMIr6f4=; b=d7rj+8QpSjUscxArZ7XYKcuFoi7B/GFxbmwxY/YeAJFpXkDE4GqonTwAilQRs3eHCr 9wgqUUGp2M2uZqGrS8oyOuUHtC72NS+g+HPsaSoYo3tcxRVgrIlDea7prwP0aii0bjkR WJcgjPHMGb1+5uTKdiVpFY05RsxeiG/It4ZrCaBrC3jeXnxUb3JdE5uIwvrsGaNyS4x7 Dq11bilXPZ9dpQgxS66wkRODkNr/rumXomg4AH7YlQffk8K2MBnEZSd4mbQm+F4nV39/ Hyi0MLbwb0o8rTE3Z9b1JJf241U+CBVEHuof+AYwXeSrnN4RIb7n+OlXgrSBFjT/81j6 ySxQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2DiBsMVuHaQKweeTOQHLBykKJQg8tEScxOxVWMIr6f4=; b=b+14SKsITf4Gh06DI37b9qYyuZ2aZtQpk2s8x2/KZxOEJPE+Ik0xW4Se8lI5O8bwNk e/BB5RukG5cbY0p1ow8/HUGFP8r8yBo5/knxxyt1/0fttkxwFTcVvgwpZGypn8egWiC0 P5HXOpt1qsFp6V/KMaaCwIJr+bkaAfqMazGKJLi2C7RtlLHytyZxwQ6TuIUd61dMh/Sx ZE+CQiGX7MCXdp2FhTe5C+QpnGwDdpkBcnOrfaC+i+t9t726v3J8Urwb2NCzWYTz6TUV jtLwHdVjR2+6W/Xtr9BzjZf5/7vw/m3qPzyGja/rBZOj2hkzwR9voJPgKDk4QzwQrOEQ sUJw== X-Gm-Message-State: AOAM533g+86jnMsscIc1jI1D3vDVciw0VnyFUQPJckWKvOTDq9j7pCo9 2sU6rkPJc8LqGBLezKdxM6MQquaPLrs0joJLGvuM+g== X-Received: by 2002:a9d:3da1:: with SMTP id l30mr4426034otc.233.1599750397232; Thu, 10 Sep 2020 08:06:37 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-2-elver@google.com> In-Reply-To: From: Marco Elver Date: Thu, 10 Sep 2020 17:06:25 +0200 Message-ID: Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure To: Dmitry Vyukov Cc: Alexander Potapenko , Andrew Morton , Catalin Marinas , Christoph Lameter , David Rientjes , Joonsoo Kim , Mark Rutland , Pekka Enberg , "H. Peter Anvin" , "Paul E. McKenney" , Andrey Konovalov , Andrey Ryabinin , Andy Lutomirski , Borislav Petkov , Dave Hansen , Eric Dumazet , Greg Kroah-Hartman , Ingo Molnar , Jann Horn , Jonathan Corbet , Kees Cook , Peter Zijlstra , Qian Cai , Thomas Gleixner , Will Deacon , "the arch/x86 maintainers" , "open list:DOCUMENTATION" , LKML , kasan-dev , Linux ARM , Linux-MM Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, 10 Sep 2020 at 16:58, Dmitry Vyukov wrote: > > On Mon, Sep 7, 2020 at 3:41 PM Marco Elver wrote: > > +config KFENCE_NUM_OBJECTS > > + int "Number of guarded objects available" > > + default 255 > > + range 1 65535 > > + help > > + The number of guarded objects available. For each KFENCE object, 2 > > + pages are required; with one containing the object and two adjacent > > + ones used as guard pages. > > Hi Marco, > > Wonder if you tested build/boot with KFENCE_NUM_OBJECTS=65535? Can a > compiler create such a large object? Indeed, I get a "ld: kernel image bigger than KERNEL_IMAGE_SIZE". Let's lower it to something more reasonable. The main reason to have the limit is to constrain random configs and avoid the inevitable error reports. > > +config KFENCE_FAULT_INJECTION > > + int "Fault injection for stress testing" > > + default 0 > > + depends on EXPERT > > + help > > + The inverse probability with which to randomly protect KFENCE object > > + pages, resulting in spurious use-after-frees. The main purpose of > > + this option is to stress-test KFENCE with concurrent error reports > > + and allocations/frees. A value of 0 disables fault injection. > > I would name this differently. "FAULT_INJECTION" is already taken for > a different thing, so it's a bit confusing. > KFENCE_DEBUG_SOMETHING may be a better name. > It would also be good to make it very clear in the short description > that this is for testing of KFENCE itself. When I configure syzbot I > routinely can't figure out if various DEBUG configs detect user > errors, or enable additional unit tests, or something else. Makes sense, we'll change the name. > Maybe it should depend on DEBUG_KERNEL as well? EXPERT selects DEBUG_KERNEL, so depending on DEBUG_KERNEL doesn't make sense. > > +/* > > + * Get the canary byte pattern for @addr. Use a pattern that varies based on the > > + * lower 3 bits of the address, to detect memory corruptions with higher > > + * probability, where similar constants are used. > > + */ > > +#define KFENCE_CANARY_PATTERN(addr) ((u8)0xaa ^ (u8)((unsigned long)addr & 0x7)) > > (addr) in macro body Done for v2. > > + seq_con_printf(seq, > > + "kfence-#%zd [0x" PTR_FMT "-0x" PTR_FMT > > PTR_FMT is only used in this file, should it be declared in report.c? It's also used by the test. > Please post example reports somewhere. It's hard to figure out all > details of the reporting/formatting. They can be seen in Documentation added later in the series (also viewable here: https://github.com/google/kasan/blob/kfence/Documentation/dev-tools/kfence.rst) Thank you! -- Marco