Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1062638ybt; Wed, 24 Jun 2020 19:02:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyu2gWsSISN4a1ZSqpfV6mQvM3fQLOuP/BYd+CsAdtko17T88th7yG7UJAfM+YPflNrwqe9 X-Received: by 2002:a50:e791:: with SMTP id b17mr31224353edn.366.1593050533347; Wed, 24 Jun 2020 19:02:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593050533; cv=none; d=google.com; s=arc-20160816; b=wZjHbmmvn9/HD8trUQ/zpP9jbF1iDWDOFFcHYQbXMaiqOo+OU4JRdYaHcmuM/gSnWH IMffCJ1E9aSpDAJbNqXr5W5o6Ym4XWcXIoGJ1wXYEODWP4hNX5h3HNZ81DQJyhfoS8/o G2LQpYjlqYrlz1B4tSae+wvin7KK+ZdjmfAcY2wYNOAf9XA/jh30Gz4YISD9kdZTjEbz yezQg3ZMdYdNLSwX9tSgMbXCvruDovV5Zg8d/A2ZNaDl4I5ooiu6FRrBqsWjIh/XU62n yYYJ/17yqgPhQm72Ab9Ll6cA2LrldUtMV/SzBjHX1RSn+gPRJV+EswXh0A6huFCKfNUX M3Jw== 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=haPh2Xvd7Zt46zY+ZtekFR/RX9PHzoO9GWj53NuZJAg=; b=0mCBDCnblrpCPiopUZW4PYlu7hyi1GX9qqb36eVQOu2EHFVMFo+j5mbGQU8jZqbfCd 71MixCc/17+4ILmAgGi7SECpMJYrzLHa1b80nXOS0+HQPRfP8hPtRWbpzVjVDH6shDYB O4HmJ4YONMT5+IhNduf79TlRK+jRPsWhRPu3AzI4/NKCXMxQ7QtdBuP68A63YdjK1TD8 dGs43rEdMbeQapaNg1pqxWyUl7PG/PDR39wxtAJ5CxlfIH1fxcRJWOxI6rdQP5GKIGCS Fbf2lGHhFdWF0dSxN4msb3hxKUas1JYZcD7MtIE57l5B9S2VlyVS7sK+fy2l3HrcB7A7 dPqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jZms4slB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gf16si14288821ejb.490.2020.06.24.19.01.46; Wed, 24 Jun 2020 19:02:13 -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=@chromium.org header.s=google header.b=jZms4slB; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389136AbgFYCAY (ORCPT + 99 others); Wed, 24 Jun 2020 22:00:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44628 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389070AbgFYCAX (ORCPT ); Wed, 24 Jun 2020 22:00:23 -0400 Received: from mail-vk1-xa43.google.com (mail-vk1-xa43.google.com [IPv6:2607:f8b0:4864:20::a43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68B46C061573 for ; Wed, 24 Jun 2020 19:00:22 -0700 (PDT) Received: by mail-vk1-xa43.google.com with SMTP id y3so750194vkg.11 for ; Wed, 24 Jun 2020 19:00:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=haPh2Xvd7Zt46zY+ZtekFR/RX9PHzoO9GWj53NuZJAg=; b=jZms4slBsFztIAOUylr/cALBwKqs7LOp4M06UnI3N6wUY7Wx89GY/oUw2v2mCerW3H 5VYU6+xD6MkxP/svHFVvqxwXV4xDJvc8HlcmDkIAxQtelVzS5LZM2ZUi7vZIhQNrA7TI WC6isbl6OBTxZEPteEYdHTr5zwUnsKYinCBGI= 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=haPh2Xvd7Zt46zY+ZtekFR/RX9PHzoO9GWj53NuZJAg=; b=V7nqgzrZOGvwqA5sI1TCcKCIbZ9um1jPEKc/nm6OoaDnQZbNTHNs9Uv30KIa4I336N ePmfjzSN3K7UjFuFxgls3ButmhMMMSG8ldG8MpjZSYvlCEUxkIKgVKEpDm1La3juUxqf SjtJWptbMw8C/A/fxA15xojnz4h3jhpPoAqJZY6aiPjx0h0BgAZ2peHHdqzhN9bw3BJs XMOMRtSjwTk17EkjntdrG7UDv2D5cm0nqir43RqgBC3lzvIPDEhUNiHUSaG1r+E80Dtw s+c5AxXN0Oin1078naGuR1Z3t4LpvK2JEN3hx5c2Tzqbr30atMs1Rnt+WyngO+kRPPCq 1Aiw== X-Gm-Message-State: AOAM533VVsKwNcLCKP1E6qKLf1Nptasecp9MADhCLqrroVH8yoYXLaJS a55m+sA3i39HGU+AOeH02N/GQMdepHletWkoS/b43A== X-Received: by 2002:a1f:1e0b:: with SMTP id e11mr25308230vke.55.1593050420674; Wed, 24 Jun 2020 19:00:20 -0700 (PDT) MIME-Version: 1.0 References: <20200624084524.259560-1-drinkcat@chromium.org> <20200624120408.12c8fa0d@oasis.local.home> In-Reply-To: From: Nicolas Boichat Date: Thu, 25 Jun 2020 10:00:09 +0800 Message-ID: Subject: Re: [PATCH] kernel/trace: Add TRACING_ALLOW_PRINTK config option To: Alexei Starovoitov Cc: Steven Rostedt , LKML , Ingo Molnar , Andrew Morton , Kees Cook , Jason Gunthorpe , Daniel Vetter , Peter Zijlstra , Vinod Koul , Andy Shevchenko , Alexey Dobriyan , Tiezhu Yang , Thomas Gleixner , "Guilherme G . Piccoli" , Will Deacon , Douglas Anderson , Guenter Roeck 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, Jun 25, 2020 at 1:25 AM Alexei Starovoitov wrote: > > On Wed, Jun 24, 2020 at 9:07 AM Steven Rostedt wrote: > > > > On Wed, 24 Jun 2020 16:45:24 +0800 > > Nicolas Boichat wrote: > > > > > trace_printk is only meant as a debugging tool, and should never be > > > compiled into production code without source code changes, as > > > indicated by the warning that shows up on boot if any trace_printk > > > is called: > > > ** NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE NOTICE ** > > > ** ** > > > ** trace_printk() being used. Allocating extra memory. ** > > > ** ** > > > ** This means that this is a DEBUG kernel and it is ** > > > ** unsafe for production use. ** > > > > > > If this option is set to n, the kernel will generate a build-time > > > error if trace_printk is used. > > > > > > Signed-off-by: Nicolas Boichat > > > > Interesting. Note, this will prevent modules with trace_printk from > > being loaded as well. > > Nack. > The message is bogus. It's used in production kernels. > bpf_trace_printk() calls it. Interesting. BTW, the same information (trace_printk is for debugging only) is repeated all over the place, including where bpf_trace_printk is documented: https://elixir.bootlin.com/linux/latest/source/include/linux/kernel.h#L757 https://elixir.bootlin.com/linux/latest/source/include/uapi/linux/bpf.h#L706 https://elixir.bootlin.com/linux/latest/source/kernel/trace/trace.c#L3157 Steven added that warning (2184db46e425c ("tracing: Print nasty banner when trace_printk() is in use")), so maybe he can confirm if it's still relevant. Also, note that emitting the build error is behind a Kconfig option, you don't have to select it if you don't want to (the default is =y which allows trace_printk). If the overhead is real, we (Chrome OS) would like to make sure trace_printk does not slip into production kernels (we do want to provide basic tracing support so we can't just remove CONFIG_TRACING as a whole which would make trace_printk no-ops). I could also imagine potential security issues if people print raw pointers/sensitive data in trace_printk, assuming that the code is for debugging only. Also, the fact that the kernel test robot already found a stray trace_printk in drivers/usb/cdns3/gadget.c makes me think that this change is working as intended ,-) (we're going to need to add a few Kconfig deps though for other debugging options that intentionally use trace_printk).