Received: by 2002:a05:7412:37c9:b0:e2:908c:2ebd with SMTP id jz9csp1732315rdb; Wed, 20 Sep 2023 19:19:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEQWdIu9pFtSpTzTWJnTH49wmvRmWr66QmO37i2FLVgYuMhBgtYDJnqy4loJCY9zbmRdiRd X-Received: by 2002:a05:6a20:e54f:b0:15d:53ad:22fe with SMTP id nf15-20020a056a20e54f00b0015d53ad22femr242026pzb.3.1695262766480; Wed, 20 Sep 2023 19:19:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695262766; cv=none; d=google.com; s=arc-20160816; b=NE4YUwkXlT+W9fLB5StqhHNAJTSdq6oFsgB06lqM3UhUZoC58qyN4/52f0EsPXV3WL obJPqaJtpUalot9MQdJ+39avpV240prOGPZeKVwRwigQOQX/yHdpK/SLD4pLDraBYL9d JRuCWXdtxSBirOUKrl5J/N/1eWsbd1WLhNRmOHoAALIvsXrg5E40HaJjQzjtEwaN320f V5qi8J6+4YhSyyebEW/JEbgGokZ4tUH83rGRKB5sMeqXMroq2nMPCi0Cn0KC4JojPgBd b6x2J+F0hVdUOdjNTbbzrYKqtjtJm7K/J5mK0Yizm7VmyvKtXTLntNvEoHQweDpQJxRp pNaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=7QWcQ2h6Fw58l2vD8cmILL2QYzm24hRo+bt6z0nA9pA=; fh=dke3/OVK8bkt/Thm9hz8g00OyZNFI3KfdK/9UrABGGQ=; b=ycrbxqmQ8zheevFP0w01VdO2WgKNxB/PXC52vyfsyRlnkEBKtSUjGeS39PfrfFFlw/ Q6mmeR46m3ehDPS8kv99oh5/PAseNpxpPUbs5oE6tKLqzf5fCcqlZ6EhawPnUHe8rQbl a8a8LeCEnPnh5qr6gDRyteUWDdv6kPIBs4QRKAQY65DHA1zNUH23Y00UHcCexdwArbDx cXeLthMRyCIlUJaHX/LrovGfX2I9oZGQoqYoSeJJ/SFOOimm58GHDu+DGOVh+/5223Sn UEFXcGT09zksn1lah4XdBxCvj8Xn22BBDRGqB9UGciv55CEylT5Ke3u68NtM+fX2rIeB LixA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aGGp6pEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 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 lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id r3-20020a632b03000000b0056fc3ceaba4si395866pgr.432.2023.09.20.19.19.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 19:19:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aGGp6pEJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 38AF4829A571; Wed, 20 Sep 2023 19:19:19 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229526AbjIUCTL (ORCPT + 99 others); Wed, 20 Sep 2023 22:19:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229513AbjIUCTK (ORCPT ); Wed, 20 Sep 2023 22:19:10 -0400 Received: from mail-pl1-x636.google.com (mail-pl1-x636.google.com [IPv6:2607:f8b0:4864:20::636]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5852DAC for ; Wed, 20 Sep 2023 19:19:04 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c44a25bd0bso10739865ad.0 for ; Wed, 20 Sep 2023 19:19:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695262744; x=1695867544; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=7QWcQ2h6Fw58l2vD8cmILL2QYzm24hRo+bt6z0nA9pA=; b=aGGp6pEJXIytDCC2wCTaYALwWbZCQoGxD3I4wLx8D9bql6Fad2Il72SP0qY+bmcows l1O4pTb7XCFlD929DAsduFgJY5Vhndu/CsOp0Q1uue5KgIVjcGTcaSc2DlS+m0zPdLhO fZBkgaYxysZdL2kHlN42n0BN3CQFUk/GC7ccA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695262744; x=1695867544; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=7QWcQ2h6Fw58l2vD8cmILL2QYzm24hRo+bt6z0nA9pA=; b=hy58J/YF0+vtwtSqPnJ+jpJtw0M2qkwUJERUfYs/yS7UOtJZ7OUncQaURYkVtGUKNp 6oPtKiURRzMaAmMFujD2XMJgXLMjzs2Rkrdw/fWeySxjY5R+3GU7BZctccl43VU7ghXM /ptO/u6QWYVDhmC37TNhHb9UbLfUGHJ2/poIyBg5bGKdhL3bkZ5YB1j0uopjeq2ywnoX c9MRZ7vCj5ww7SB7CpQwiAEbuV865AB9rOyqJhj7oTceuLxuCHuyZdzBNj2Zezx/kuZf fM085JK2TmzXDdi0cslqy4SNaUQrYXvEZ7z4vWf9Hz+KoTpuak2fkCnRk9OmMJa3u6f8 Y6KA== X-Gm-Message-State: AOJu0YwMdmmIuEVwFAzbn50UktcF7aT+sjUOSoEyLXRXfDCDbilQAaLL mLycrVM4UYZYkXqhTbFeOyTq9A== X-Received: by 2002:a17:902:d506:b0:1c1:d5d1:a364 with SMTP id b6-20020a170902d50600b001c1d5d1a364mr5646179plg.33.1695262743607; Wed, 20 Sep 2023 19:19:03 -0700 (PDT) Received: from google.com ([2401:fa00:8f:203:9dd3:363a:be52:b271]) by smtp.gmail.com with ESMTPSA id f21-20020a170902e99500b001c55db80b14sm173881plb.221.2023.09.20.19.19.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 19:19:02 -0700 (PDT) Date: Thu, 21 Sep 2023 11:18:59 +0900 From: Sergey Senozhatsky To: John Ogness Cc: Petr Mladek , Sergey Senozhatsky , Steven Rostedt , Thomas Gleixner , linux-kernel@vger.kernel.org, kernel test robot Subject: Re: [PATCH printk v1] printk: fix illegal pbufs access for !CONFIG_PRINTK Message-ID: <20230921021859.GA14418@google.com> References: <20230920155238.670439-1-john.ogness@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230920155238.670439-1-john.ogness@linutronix.de> X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 20 Sep 2023 19:19:19 -0700 (PDT) On (23/09/20 17:58), John Ogness wrote: > When CONFIG_PRINTK is not set, PRINTK_MESSAGE_MAX is 0. This > leads to a zero-sized array @outbuf in @printk_shared_pbufs. In > console_flush_all() a pointer to the first element of the array > is assigned with: > > char *outbuf = &printk_shared_pbufs.outbuf[0]; > > For !CONFIG_PRINTK this leads to a compiler warning: > > warning: array subscript 0 is outside array bounds of > 'char[0]' [-Warray-bounds] > > This is not really dangerous because printk_get_next_message() > always returns false for !CONFIG_PRINTK, which leads to @outbuf > never being used. However, it makes no sense to even compile > these functions for !CONFIG_PRINTK. I wonder if anyone really use !PRINTK kernels. Can we get rid of CONFIG_PRINTK? > Extend the existing '#ifdef CONFIG_PRINTK' block to contain > the formatting and emitting functions since these have no > purpose in !CONFIG_PRINTK. This also allows removing several > more !CONFIG_PRINTK dummies as well as moving > @suppress_panic_printk into a CONFIG_PRINTK block. > > Reported-by: kernel test robot > Closes: https://lore.kernel.org/oe-kbuild-all/202309201724.M9BMAQIh-lkp@intel.com/ > Signed-off-by: John Ogness FWIW, Reviewed-by: Sergey Senozhatsky