Received: by 2002:a6b:fb09:0:0:0:0:0 with SMTP id h9csp796406iog; Mon, 13 Jun 2022 13:11:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxzQwP/4SWoSou57LBDMQFsGlL7u1TRSeGjUM0/3pax8SWYScWCP9SNLAn+j/eWoDgykkmI X-Received: by 2002:a65:5b08:0:b0:401:cf39:c35c with SMTP id y8-20020a655b08000000b00401cf39c35cmr1156535pgq.396.1655151098484; Mon, 13 Jun 2022 13:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1655151098; cv=none; d=google.com; s=arc-20160816; b=abPfKIo7UX/2nJQbpK8dQ3+c8PHBtagw6D0Gt7WACOZ8hWkEXPtFr3SrKi0Svw+cF7 aRMFqswxAa8eCtuCGmuVw0Q2Q0SE/84aHRSYskivaQ16d3XJATFGlqmr54/gd5h6bM79 4HTFfLbmDaFsm0Tb0MJXK7PAYruzlMRwQVvpkwM5Gi1OsALVJM+IAvaALAoEEQgH+l8f Bq0VlEVfEwwSA+edsGv8CfgHCkIffktftDyUctmM5vRa8M0eYGzfndA9jfsBuaXMHlg9 uVvgUwq1f3zUjP5Y0Rb9p20VTZdZHqixSYnDvU6MYVON0+9C32Yfo5e3Yc6qHKdH8XoX UX4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=SW1J4TxrbvE0J+NvABWMWUwXUDHi8O6WM5U0kmdXuvs=; b=fNgE+fUN/oAf6ehCzGVw46F+8YRh+6Yp4DFtreXQQpl5ikusEuWIc/N2n6ZRTxlh/t QDLNlK+ZFK02BUvCqJ6gaoqvM2qxvJi3JENfEJ3mCat44Yu0STHdErfyixWQiBqj/ccd wIyH1iFpWNrQ0I7aOp8pDqgkx0iphySLiA2EtuHFHax8KzBDk1Bi4zFDOrCjmBVh3B35 BBxccQ/ZXviSZnCWGkew2AYoTGEgXD5pX36E4mcIRWXZfcOTenVhyLcu0tHM5WB2AEai J9wFFfCfYizI4H3qlLikkvvII9Pk/LYdo+AZrrzYzHkmYCUE89jQTlgQbQrXMcE0U+FF fi2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YcOMN9J8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i22-20020a63cd16000000b003db97293633si10806841pgg.184.2022.06.13.13.11.26; Mon, 13 Jun 2022 13:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=YcOMN9J8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 S1345007AbiFMUF4 (ORCPT + 99 others); Mon, 13 Jun 2022 16:05:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345169AbiFMUFp (ORCPT ); Mon, 13 Jun 2022 16:05:45 -0400 Received: from mail-lj1-x22b.google.com (mail-lj1-x22b.google.com [IPv6:2a00:1450:4864:20::22b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D8BFBA556 for ; Mon, 13 Jun 2022 11:40:21 -0700 (PDT) Received: by mail-lj1-x22b.google.com with SMTP id b7so7154880ljr.6 for ; Mon, 13 Jun 2022 11:40:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SW1J4TxrbvE0J+NvABWMWUwXUDHi8O6WM5U0kmdXuvs=; b=YcOMN9J8NO13M1lsQJ09hM7cCxE8MS8M7Gv1MrIUfDqyrowxYIz0M4kq/4DzZS1VvJ X+WwlBoGf6CzRGJ8G1EjU7INISE4kKU0Z/BuQnIyh3+0qLr9mDdeVrnpP8AHGXywflLI gn4vt4eUHsaKF6mpPhECp6pZ2U/kiDWVsOWPKlO9R4E2oApQGpBRq/kLZZK9nbrMH8Vs rXrYvlBgBc2y9ISFPMRSym0HBSe8rRlM0D6NK0Ddpva36u6S2KIqGMmwmrN+Mz2tgqDy Zm5vDhOTpucmZ8RQFhCIrZBcGzE3vnnOhB0faQ7Lbps3yLPlEQLVSwLrlcC8TPCjgrM+ 10Rw== 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=SW1J4TxrbvE0J+NvABWMWUwXUDHi8O6WM5U0kmdXuvs=; b=AM7NvhQc++aXNIUMN/mvMysebFHz72BoCI+sSMJLq8FA+5G1t94vK9K12tAZ1FkJPI ovDVp3vGxgyybnfAe9/SnOoa4N+VfSNUGO1w8iP60EBd5fvmTGgHW0KRONjuUSBKmh4T ZtRg+lG3eR7SA0BtMktd+qLLpKT5W2GD3wX6vPHFtxuHQPFbTgsXPNQ61w4mFas+HbVy kYWVIQ5NcpzTPQm6+omND76d555KG+Q5EGbL5NUI/JPrEey4SSVawtQE1L0rhx85airw smwIRI++sLDBxlQy33A4smaIfV9Pu6mQXnATWhjUGGwD9mqSrPk5zXtx6mU+VNtzRWrI uyqg== X-Gm-Message-State: AJIora/qNFQ64fUeHBKMnCEkOAtJL/lpH0svfpy0mjSFAadgYFIHf33U 9wUbdaNkBbwZPPibkmPJku+pO/FbSDhR9TfiDlAJ X-Received: by 2002:a05:651c:1581:b0:255:48d1:fdae with SMTP id h1-20020a05651c158100b0025548d1fdaemr459115ljq.286.1655145619959; Mon, 13 Jun 2022 11:40:19 -0700 (PDT) MIME-Version: 1.0 References: <20220609221702.347522-1-morbo@google.com> <20220609221702.347522-8-morbo@google.com> In-Reply-To: From: Bill Wendling Date: Mon, 13 Jun 2022 11:40:08 -0700 Message-ID: Subject: Re: [PATCH 07/12] driver/char: use correct format characters To: Greg Kroah-Hartman Cc: Bill Wendling , Tony Luck , Borislav Petkov , Thomas Gleixner , Ingo Molnar , Dave Hansen , "maintainer:X86 ARCHITECTURE (32-BIT AND 64-BIT)" , "H. Peter Anvin" , Phillip Potter , Arnd Bergmann , "Rafael J. Wysocki" , Jan Kara , Andrew Morton , Pablo Neira Ayuso , Jozsef Kadlecsik , Florian Westphal , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jaroslav Kysela , Takashi Iwai , Nathan Chancellor , Nick Desaulniers , Tom Rix , Daniel Kiper , Ross Philipson , linux-edac@vger.kernel.org, LKML , ACPI Devel Maling List , linux-mm@kvack.org, netfilter-devel@vger.kernel.org, coreteam@netfilter.org, Networking , alsa-devel@alsa-project.org, clang-built-linux Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE,USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jun 9, 2022 at 10:18 PM Greg Kroah-Hartman wrote: > > On Thu, Jun 09, 2022 at 10:16:26PM +0000, Bill Wendling wrote: > > From: Bill Wendling > > Why isn't that matching your From: line in the email? > There must be something wrong with my .gitconfig file. I"ll check into it. > > > > When compiling with -Wformat, clang emits the following warnings: > > Is that ever a default build option for the kernel? > We want to enable -Wformat for clang. I believe that these specific warnings have been disabled, but I'm confused as to why, because they're valid warnings. When I compiled with the warning enabled, there were only a few (12) places that needed changes, so thought that patches would be a nice cleanup, even though the warning itself is disabled. > > drivers/char/mem.c:775:16: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security] > > NULL, devlist[minor].name); > > ^~~~~~~~~~~~~~~~~~~ > > > > Use a string literal for the format string. > > > > Link: https://github.com/ClangBuiltLinux/linux/issues/378 > > Signed-off-by: Bill Wendling > > --- > > drivers/char/mem.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/drivers/char/mem.c b/drivers/char/mem.c > > index 84ca98ed1dad..32d821ba9e4d 100644 > > --- a/drivers/char/mem.c > > +++ b/drivers/char/mem.c > > @@ -772,7 +772,7 @@ static int __init chr_dev_init(void) > > continue; > > > > device_create(mem_class, NULL, MKDEV(MEM_MAJOR, minor), > > - NULL, devlist[minor].name); > > + NULL, "%s", devlist[minor].name); > > Please explain how this static string can ever be user controlled. > All someone would need to do is accidentally insert an errant '%' in one of the strings for this function call to perform unexpected actions---at the very least reading memory that's not allocated and may contain garbage, thereby decreasing performance and possibly overrunning some buffer. Perhaps in this specific scenario it's unlikely, but "device_create()" is used in a lot more places than here. This patch is a general code cleanup. -bw