Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp78448pxa; Wed, 26 Aug 2020 05:22:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyjlwxqZUbDma4kbopEsNgHqEDSEPEQ7qlbng4t2ybHVZTt3/dOHz2gHsHQlTRwnS9UIP9s X-Received: by 2002:a17:906:a8d:: with SMTP id y13mr12739989ejf.400.1598444547848; Wed, 26 Aug 2020 05:22:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598444547; cv=none; d=google.com; s=arc-20160816; b=gs2KEWlrHHaNWEsoNsGnPSSZUX2JYC/3wGsADHLastzh+Istmad0qAFIHIeee1bwsg xdeojFHrim1n0XBHANKmX/cSswLZ8ZJDEsIeLURhXvvPx5jXf4PHBDi/MCo2/2gOUng+ qP1Yj4EY9YdTSBzo9sa/XxmTFakQh9v6RU5E60vhstwY8WqIt8p9piIqfKDU822kdX67 L2aYSHVtST+OOmIla/RUi1q6RIXF1Ci51UBE081qtiyLtTqsmrg8j07wBSI0q9/C/V+x lz6Om4jDYa7g9zRw37loHaTkFe6uvYMc0vngCMzlDD5hA4lS82hJg59tKzSadqYNrYHy U7lA== 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=7/q8ddA2FVVePJulVHbf1w2DVxs+k2gCtz8r5i1ccF8=; b=FW8B/mG09Y2EOezXb3WIeuRrNpVjyr+AKEqiaohClbISRcDGsFcUPuFA9CoYy+jwNf q4SbFxjr/Ln+st92UoSeaH9NpRYS92LiLIqGIEAROiC73HCOv+t+SWLQAmlnyNWylrqX osq5gOlzt7rCMmBCUXBkMn4saQno+7O10Gvud7j+REMnCWRbFT4BO8LcCrDvpvyePB0q 8Q0ZvTfoOqsGROUIB1RANyOUR4ilZzADJ5qjEJ4LuqxHGRZrLLlyXR54tnx0DIUEfjtA Ma0bJi0j2T1erTnty8W0uiQD6+g5WQYMwDVnslDw+m9sKfbjVp6Sm6Y35PyatgJmbDWT qVYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=cUFP7Oiw; 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 ce15si1384584edb.201.2020.08.26.05.22.04; Wed, 26 Aug 2020 05:22:27 -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=cUFP7Oiw; 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 S1729530AbgHZMST (ORCPT + 99 others); Wed, 26 Aug 2020 08:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38074 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729204AbgHZMSJ (ORCPT ); Wed, 26 Aug 2020 08:18:09 -0400 Received: from mail-ot1-x342.google.com (mail-ot1-x342.google.com [IPv6:2607:f8b0:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8144C061574 for ; Wed, 26 Aug 2020 05:18:09 -0700 (PDT) Received: by mail-ot1-x342.google.com with SMTP id n23so1272184otq.11 for ; Wed, 26 Aug 2020 05:18:09 -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=7/q8ddA2FVVePJulVHbf1w2DVxs+k2gCtz8r5i1ccF8=; b=cUFP7Oiw1nGQBRVAjjWi4uM5zQAqXphiVe5sfmdel3PFSgL2f5Hc7lgzgDy9fc0qhb lJ9N8s3+lCqQAUn1b11KbLv8tr52O0JlPgWbKJUYy+kD4jIS2eOPAIg7iv70NvPAKyg0 mcI8hVIPBXs9+1hQduhVWVBpH/OK85kGGuxqTzhalXNZOh0za+2xYHOugfpQ99+eoejT 1NIidxHyeH3222oxS7vlk09XfFxD2yzTzij8oaq7TcAhFB9DpoA7VrvK000co/yi5brk yYMF+R5iVgZaFQAp0n52szNbvg1PVtA3osFR/eQCRnRzLywuSVdy+tiTe0lXQ4H89aJd O79g== 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=7/q8ddA2FVVePJulVHbf1w2DVxs+k2gCtz8r5i1ccF8=; b=fxcajWjC7VaLw7lBZNPxBS3i4Z+bY6r0D+sy55DwjtvHCD8slCmZjkoikotONVFAj6 wU5LoDGxa/JVPfdoP/VV/w08IiQsgvrUR8MK05f7YbHjxShrHasltBwM2lvilaJrmTLf 2ZtRKAwnwccQA7PGL2ZMphbO3rBzegZpX3RaWRqEegf+fchN3J36fHJzVBc/s84U9lAo D2hzenMANkWFubDLmc152QtBHhJOjwQgT8ASqqiry7Uu680OVsf1t/0GcQdjqsFlfly6 t4JSQc9Tz+24j1LyatGjMt7c9HMupnG7Gc8qSab49bEUBuc7aGwJSd0gkl++QbK+Tsiu bmRQ== X-Gm-Message-State: AOAM530EoGvbyx5ZgNyN2oC7WA+GXJRidHZl1806dbLSiGWk5f4B6uy6 DFo0Fzmbx6m5UopibgUFY3rQTg/z5iBUcmx5IayKoQ== X-Received: by 2002:a9d:739a:: with SMTP id j26mr10379141otk.17.1598444288848; Wed, 26 Aug 2020 05:18:08 -0700 (PDT) MIME-Version: 1.0 References: <20200821123126.3121494-1-elver@google.com> In-Reply-To: <20200821123126.3121494-1-elver@google.com> From: Marco Elver Date: Wed, 26 Aug 2020 14:17:57 +0200 Message-ID: Subject: Re: [PATCH] kcsan: Use tracing-safe version of prandom To: "Paul E. McKenney" Cc: Peter Zijlstra , Marco Elver , Mark Rutland , Dmitry Vyukov , kasan-dev , LKML 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 Fri, 21 Aug 2020 at 14:31, Marco Elver wrote: > In the core runtime, we must minimize any calls to external library > functions to avoid any kind of recursion. This can happen even though > instrumentation is disabled for called functions, but tracing is > enabled. > > Most recently, prandom_u32() added a tracepoint, which can cause > problems for KCSAN even if the rcuidle variant is used. For example: > kcsan -> prandom_u32() -> trace_prandom_u32_rcuidle -> > srcu_read_lock_notrace -> __srcu_read_lock -> kcsan ... > > While we could disable KCSAN in kcsan_setup_watchpoint(), this does not > solve other unexpected behaviour we may get due recursing into functions > that may not be tolerant to such recursion: > __srcu_read_lock -> kcsan -> ... -> __srcu_read_lock > > Therefore, switch to using prandom_u32_state(), which is uninstrumented, > and does not have a tracepoint. > > Link: https://lkml.kernel.org/r/20200821063043.1949509-1-elver@google.com > Link: https://lkml.kernel.org/r/20200820172046.GA177701@elver.google.com > Signed-off-by: Marco Elver > --- > Applies to latest -rcu/dev only. > > Let's wait a bit to see what happens with > https://lkml.kernel.org/r/20200821063043.1949509-1-elver@google.com, > just in case there's a better solution that might make this patch redundant. Paul, feel free to pick this up. I wanted to wait until after plumbers to see what happens, but maybe it's better to give the heads-up now, so this is in time for the next pull-request. It seems that prandom_u32() will keep its tracepoint, which means we definitely need this to make KCSAN compatible with tracing again. Thanks, -- Marco