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 B1E5FC43334 for ; Thu, 9 Jun 2022 12:31:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 29A1B8D000E; Thu, 9 Jun 2022 08:31:33 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 249348D0006; Thu, 9 Jun 2022 08:31:33 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 111698D000E; Thu, 9 Jun 2022 08:31:33 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 020ED8D0006 for ; Thu, 9 Jun 2022 08:31:33 -0400 (EDT) Received: from smtpin25.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id B7F2A3500D for ; Thu, 9 Jun 2022 12:31:32 +0000 (UTC) X-FDA: 79558633224.25.E2B2192 Received: from mail-qk1-f170.google.com (mail-qk1-f170.google.com [209.85.222.170]) by imf06.hostedemail.com (Postfix) with ESMTP id 318B8180077 for ; Thu, 9 Jun 2022 12:31:32 +0000 (UTC) Received: by mail-qk1-f170.google.com with SMTP id n197so10510856qke.1 for ; Thu, 09 Jun 2022 05:31:31 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6WNNhQK6JE2Cn/3pAieE4V2HComQZrsks/B6n612PiU=; b=48sUv55vZyNnUbWdk1Kwph/TXgN/kmH2QWhhsV0FrMaTZcYDXud3AQeQURJH5A/aif k/ZBOiSXGK17+pg5y+ELdFSYBotig0pXP4nSM7j+6M9B7mybpaCj40effra+P6Hbyv/P sAWEvR/P3Y1UpZK4xZmSI2Symva8x+IxV5+boSyB/njYZDvg+Pcfm/7opSQ4Au9+SDkQ RDlGxOICLYL8MX7Mi0XKbq48CxulE9fGRolapLSuR1DDRCSGCJhTu/vWtZqWICKSLk5L EGYg2X3CSNQZdBZ9DhcUgMYaHHKlgf0W9xdjCGoI/i6ov7p/T/WGvSn6MWf0OKbWKBpw GWTg== X-Gm-Message-State: AOAM531vs/OYbNSi4Zq3XPxqXJJACJ4iTsfjtrfirYtfvv2Pj1mrxm49 w+9mw+O/9oYqB7ZaQOEvssO/8FmA5WmAow== X-Google-Smtp-Source: ABdhPJyssfJOnsDYt2ueBd0YFwxabiKhxJXjWPR9qDvce9mG20wDX/sH0j9vByzaKm1bloRQJ+zQyQ== X-Received: by 2002:a05:620a:16d9:b0:6a6:a7e0:17ff with SMTP id a25-20020a05620a16d900b006a6a7e017ffmr19815415qkn.565.1654777890929; Thu, 09 Jun 2022 05:31:30 -0700 (PDT) Received: from mail-yw1-f173.google.com (mail-yw1-f173.google.com. [209.85.128.173]) by smtp.gmail.com with ESMTPSA id w15-20020a05620a424f00b006a69d7f390csm15611353qko.103.2022.06.09.05.31.30 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 09 Jun 2022 05:31:30 -0700 (PDT) Received: by mail-yw1-f173.google.com with SMTP id 00721157ae682-313a8a8b95aso5419667b3.5 for ; Thu, 09 Jun 2022 05:31:30 -0700 (PDT) X-Received: by 2002:a81:6157:0:b0:30c:7e4d:b28e with SMTP id v84-20020a816157000000b0030c7e4db28emr42497205ywb.502.1654777889942; Thu, 09 Jun 2022 05:31:29 -0700 (PDT) MIME-Version: 1.0 References: <20220609121709.12939-1-Jason@zx2c4.com> In-Reply-To: <20220609121709.12939-1-Jason@zx2c4.com> From: Geert Uytterhoeven Date: Thu, 9 Jun 2022 14:31:18 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mm/kfence: select random number before taking raw lock To: "Jason A. Donenfeld" Cc: Linux MM , Linux Kernel Mailing List , John Ogness , Alexander Potapenko , Marco Elver , Dmitry Vyukov Content-Type: text/plain; charset="UTF-8" ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1654777892; a=rsa-sha256; cv=none; b=gyq6awufg7TT0/NPwE0IFFrSWtRcilSdiv5v4NbOA7dLTwbVSa6B1V0RHUQ7/EqnxHfMGf VeSo0NIL64nPA7nv/br0bmg/dxlE2KX+aJypniYY7IhD1gmO/5Irpt2ER3AvzSjwVMbb2w X5Sm6YpunpZlCb42VhzrV5t+2Hf70Ec= ARC-Authentication-Results: i=1; imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1654777892; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=6WNNhQK6JE2Cn/3pAieE4V2HComQZrsks/B6n612PiU=; b=zNJf+bF31k7nIU1eAkgEkg/NXsanG9KpsXFUI89SjbWjfgWlLFK81yBp1CQcJiR+CXloi/ bBh9GUr/YWztRYI31EmQDM2KfhvEJxw0BYaA/4dBlzYxLPl2TAk7qNALwHIsVEREuAFw15 jp41E8DMYjrw0ZJdYpyW+U9Kpvi4GKU= X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 318B8180077 X-Rspam-User: Authentication-Results: imf06.hostedemail.com; dkim=none; spf=pass (imf06.hostedemail.com: domain of geert.uytterhoeven@gmail.com designates 209.85.222.170 as permitted sender) smtp.mailfrom=geert.uytterhoeven@gmail.com; dmarc=none X-Stat-Signature: fag1bkpkaihjp1xyfw1yz6dz7h78gpam X-HE-Tag: 1654777892-724305 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: Hi Jason, On Thu, Jun 9, 2022 at 2:17 PM Jason A. Donenfeld wrote: > The RNG uses vanilla spinlocks, not raw spinlocks, so kfence should pick > its random numbers before taking its raw spinlocks. This also has the > nice effect of doing less work inside the lock. It should fix a splat > that Geert saw with CONFIG_PROVE_RAW_LOCK_NESTING: > > dump_backtrace.part.0+0x98/0xc0 > show_stack+0x14/0x28 > dump_stack_lvl+0xac/0xec > dump_stack+0x14/0x2c > __lock_acquire+0x388/0x10a0 > lock_acquire+0x190/0x2c0 > _raw_spin_lock_irqsave+0x6c/0x94 > crng_make_state+0x148/0x1e4 > _get_random_bytes.part.0+0x4c/0xe8 > get_random_u32+0x4c/0x140 > __kfence_alloc+0x460/0x5c4 > kmem_cache_alloc_trace+0x194/0x1dc > __kthread_create_on_node+0x5c/0x1a8 > kthread_create_on_node+0x58/0x7c > printk_start_kthread.part.0+0x34/0xa8 > printk_activate_kthreads+0x4c/0x54 > do_one_initcall+0xec/0x278 > kernel_init_freeable+0x11c/0x214 > kernel_init+0x24/0x124 > ret_from_fork+0x10/0x20 > > Cc: John Ogness > Cc: Alexander Potapenko > Cc: Marco Elver > Cc: Dmitry Vyukov > Reported-by: Geert Uytterhoeven > Signed-off-by: Jason A. Donenfeld Thank you, the splat is gone. Tested-by: Geert Uytterhoeven Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds