Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1379243pxk; Thu, 10 Sep 2020 13:55:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeuL6m7yP6IJ0sBkMOeIygyudq6sfrIixeBXVxIBnGbrIoW47uubIeO/xOZPdWcX9SVXWq X-Received: by 2002:a17:906:2c04:: with SMTP id e4mr10537129ejh.147.1599771359568; Thu, 10 Sep 2020 13:55:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599771359; cv=none; d=google.com; s=arc-20160816; b=Qu3ul2skkt7vDUrhHre7EsHrz47JQHQTWvFJX0f1LpLfTrUWVDURkX8P1m1co1ka0P 4djvPMeMjxj7upjRergGJO0e97g97lS9pKow8qBXcpRJnGi82AEuVXhu4ylARhodq83a XISrLbzy/MVLZ8Z9KgVMYvooLPs2EqaFCn6u+WmjvzIm1hUnajdnWrpxRITNTN81ev1d EOumg+DmM+tu+wDl58qYknUzrgIbq/qdyivn9KWGdJcXe9fIVZ9UhmlfOKLhglLgerCt xIe46SQ35JS3Uw7SxLceXUPUkRa9irPZY8q4y8WsSWrY5NisOahH14IMrkPNXIDwMNsV D2CA== 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=psWYZztgZCmOanZbN0KVSKVg8aC+fzD9jcmxhuC+NNI=; b=ItMFUg8lLhud6K4gQUlFJar1AQJ0/YD476x2+eHan2AmHcuQQGg86INeT+wlSqXMqE 6omsx5NSTyhP7RYpezVPd6GcG6joL5Ug5LCfz2EByWrIZITilRlpLXO6XiG3H+5vFxZp pxH2FXnrO4eaglho166HvQH2yhFDUZbtP+U/dxFu8CiJVOQ+ANWIiXoX+EianEFexrsT UdjSjbt1m5UcHnhVgMoqMcqFjtaPNQFNsWGYypplEiHpvhJ2qVNZEjTPd9i77nW4/b6D nnzxqFCavo2B2QtHy578QEtAV4tOZTnNq0sk2Mkoz8u3WMtTG2fY2zvUf1JvnkYf6YoS QOqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=uBOlTGMa; 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 c13si4437260edv.328.2020.09.10.13.55.36; Thu, 10 Sep 2020 13:55:59 -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=uBOlTGMa; 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 S1726424AbgIJUwp (ORCPT + 99 others); Thu, 10 Sep 2020 16:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730813AbgIJO6V (ORCPT ); Thu, 10 Sep 2020 10:58:21 -0400 Received: from mail-qt1-x842.google.com (mail-qt1-x842.google.com [IPv6:2607:f8b0:4864:20::842]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32A12C061573 for ; Thu, 10 Sep 2020 07:58:07 -0700 (PDT) Received: by mail-qt1-x842.google.com with SMTP id k25so5073151qtu.4 for ; Thu, 10 Sep 2020 07:58:07 -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=psWYZztgZCmOanZbN0KVSKVg8aC+fzD9jcmxhuC+NNI=; b=uBOlTGMa94CWWF6b+8C6NaJQaNcmte0pvB20fB/uVnBUUG8bvWgUMpgmpjaAvmfxr7 AOtJ+KbVmezhukeZRCHFU6HqC8v/EauaFyhX9aa15oWd0ENqKLPrc8KSgg30BLwgc/yj AapZ46xO0EI3jLRHYfn/B5QbXVDv9AKyvij0LRF3yZomuokQyFfGZCZuGmBYRJuT/lH+ cweg8VGv/ZI014+jDzWXQPJjA4oi3ZWbNm4yvus4D8czoI73PkA8zOT/lsnuJ0Or7lM6 Vv8DYVqjz6dYkI89w1eFdCBIcEOC0NR9mZBsy2hRME9X71MtGhDIwU80FS74v9831tWA E5wg== 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=psWYZztgZCmOanZbN0KVSKVg8aC+fzD9jcmxhuC+NNI=; b=YOL9Q95HdeWo+dYi7a0iLB3aaRsuNNpcBJVJfwkyRNMiRuDwnDGLqFbX7Gcy+Bjn69 w7+KHGZez5G6UgYfMPgKbAHy77k7vGZkGHcNiH0tGdQ7szSL7+6nXmufauRpHe2DuT1w cluocKo9tmtl3j+S2nqo8lMqSbvoitxbYqRKdsKY5hJSU20hFyzZBT5zpxhecNCX8vcQ iZxiGgq7A+E0kt0YNaKTYYPA0B0unedxC9HlU/ZsXhZ0JNYeRTLskkHDisaenGRfzrOY zg51GWLpz/GRb0DsYI/OaJVcDNnsEkmh5vodf4DM3BpbYXTLmIwQREkfecO/WmJipPXf j9Rw== X-Gm-Message-State: AOAM532GnD4lpu3MvLxl/PGTMG98LtYBJ91GpSjBGjPPoaufdEGlhENL CKMAAoeiwJbWn7Pz0hhFghJy2VWjKAXjdFj+kZ4BFg== X-Received: by 2002:ac8:5215:: with SMTP id r21mr8150267qtn.257.1599749886066; Thu, 10 Sep 2020 07:58:06 -0700 (PDT) MIME-Version: 1.0 References: <20200907134055.2878499-1-elver@google.com> <20200907134055.2878499-2-elver@google.com> In-Reply-To: <20200907134055.2878499-2-elver@google.com> From: Dmitry Vyukov Date: Thu, 10 Sep 2020 16:57:54 +0200 Message-ID: Subject: Re: [PATCH RFC 01/10] mm: add Kernel Electric-Fence infrastructure To: Marco Elver 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 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? > +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. Maybe it should depend on DEBUG_KERNEL as well? > +/* > + * 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 > + 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? Please post example reports somewhere. It's hard to figure out all details of the reporting/formatting.