Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp132561rdb; Fri, 29 Sep 2023 20:52:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHP8mrZy5YagaEuG4/yglT5JLL0YALALKlSPVFVLrmsnW8cSSst41RfOj9Kxnqv9FQu85NU X-Received: by 2002:a05:6a21:193:b0:15e:22a4:b897 with SMTP id le19-20020a056a21019300b0015e22a4b897mr10861136pzb.10.1696045926531; Fri, 29 Sep 2023 20:52:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696045926; cv=none; d=google.com; s=arc-20160816; b=pqHPMwY326WLWuIZFUK85KObpKFiYcl1pxknZ9TYI9cKQ1/VvtbX08TC+ZGAIM/z4w tL/MFEY0SClYcBfuECmn16t6RWa1rg6c5VENK3iW9tsqoUhYkoITh3Gyx9r0jkKc0xsD 7cr5hHQqrhcKAXYEZH/asU5y/P4S8tMePL4zhT3mOF+PABS2pzoV3+MsQcqGLJCjf923 EDz6LtJqqQdVyUZd7lfoe/OLvTaL0GVl7de601w7Aoaa4RN88GOa7glCz7pgAVLjNswx DKFYKX8Wi5OT9jg0Od2ylIbAYAPoGZV0QB7HUWOTzeyieJmsD5QsgH1omwLy+HNGKN03 vHOQ== 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-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=aC5cjqNqRJMxYKokdjVvuutOF44kRshAAYS87I+O62E=; fh=9BbDkAnwFoCLMgNnJaP/m4M8xo0D2ZFRh9+QSELz7UM=; b=KXNduxZdxkbuCTP7zdDWYfXuy/8fM++PcHZV3Udear+26Eo093geHxr+J8oXeh9NzS 4oQUKiJ+La/SXV1PlvwICNbEi0ZDyIV3hmhCapGsTzz9nN7oh0oKqC1uZJSVA6XH0g3a d6tav/py75IcYWDMQyNmgN5MEWiXhw6kK/o5ThIA/UL4nQnzhbJgEunNO7PPFu0YlGVw IAZwcRmtWcKaOFNJWjesT992OXfL6emFBXcnTRD7XFNgbJF4sv4K0DIuFufYw3aiphmP 3+a1D+O/2VaZ1t5UH2SiBhZIY3LVv2nS7BTbDqXJhM22+SjLl7CfWAIK3ocR5wovS13N jzpQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JNmmSwTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (pete.vger.email. [23.128.96.36]) by mx.google.com with ESMTPS id g24-20020a633758000000b00573fbbf187dsi22692290pgn.216.2023.09.29.20.52.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 20:52:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 as permitted sender) client-ip=23.128.96.36; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=JNmmSwTE; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.36 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 pete.vger.email (Postfix) with ESMTP id A07A08135BF0; Fri, 29 Sep 2023 10:58:32 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at pete.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233586AbjI2R6O (ORCPT + 99 others); Fri, 29 Sep 2023 13:58:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57090 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233313AbjI2R6O (ORCPT ); Fri, 29 Sep 2023 13:58:14 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9378B1AC for ; Fri, 29 Sep 2023 10:58:10 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id d9443c01a7336-1c63164a2b6so7125535ad.0 for ; Fri, 29 Sep 2023 10:58:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1696010290; x=1696615090; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=aC5cjqNqRJMxYKokdjVvuutOF44kRshAAYS87I+O62E=; b=JNmmSwTEcryloizv5tdu+Ls/qdTcndi6/swlVQSdJlnZynz0f1ozH0IXOUiQwwacWX gA53iIFBa18TppC0po0wY9Vyw80uxJ975Xn/Lk9lax8r2p66Vb4K1sS6lakTuy1c7IB/ XF00Pp105IxxTIoCr1/G2dBs0nGD4hfD4HNTs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696010290; x=1696615090; h=in-reply-to:content-transfer-encoding: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=aC5cjqNqRJMxYKokdjVvuutOF44kRshAAYS87I+O62E=; b=Lx7vknFj0PipeQXbQBB8cJWxZ0ovUX2lHwR/0yZZqpJH0Eei/cObWSlRadap8rV1F4 1t+5AywK8INM/f8oggtuJF8QEjQ/ObNWJ1rKlDfiP8g8NsBEJe5kdFFjBDsIhSyN4beV YYWs/ANxd8GZ/pqasjhzD338o1GmapQwkWRJ3zLJ13EqyGGPEh/1btrujYBWuSltcTVw MQnoufP58Wq8USVITqReZ2+yAdf3Rk0/D4hyspdgVWneKUkY04fzK9feT9ERTy7snkHK rMuJ8hoiOfo/YoXRaEcHTUWl7A58sXOL4Z7LiObxZrTkRKxO/Zx1S4ad/HRtvxr8s6P3 JS4g== X-Gm-Message-State: AOJu0Yx8RWhTpNGD8BG0TIWtmi9l15hogw3WWrIdeh+0PMnfxkx8sgUt 1FMJu3089t9hBG3/l5NRxxZN+w== X-Received: by 2002:a17:902:e5d1:b0:1c3:e5bf:a9fe with SMTP id u17-20020a170902e5d100b001c3e5bfa9femr8315131plf.30.1696010290068; Fri, 29 Sep 2023 10:58:10 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id j24-20020a170902759800b001c5f0fe64c2sm1628550pll.56.2023.09.29.10.58.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 10:58:09 -0700 (PDT) Date: Fri, 29 Sep 2023 10:58:09 -0700 From: Kees Cook To: Greg Ungerer Cc: linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, palmer@rivosinc.com, ebiederm@xmission.com, brauner@kernel.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH] binfmt_elf_fdpic: clean up debug warnings Message-ID: <202309291057.6D4993BA@keescook> References: <20230927132933.3290734-1-gerg@kernel.org> <202309270858.680FCD9A85@keescook> <9e4cf2c9-a1a9-43a8-3f72-2824301bbc98@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <9e4cf2c9-a1a9-43a8-3f72-2824301bbc98@kernel.org> 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 autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on pete.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 (pete.vger.email [0.0.0.0]); Fri, 29 Sep 2023 10:58:32 -0700 (PDT) On Thu, Sep 28, 2023 at 02:53:09PM +1000, Greg Ungerer wrote: > Hi Kees, > > On 28/9/23 01:59, Kees Cook wrote: > > On Wed, Sep 27, 2023 at 11:29:33PM +1000, Greg Ungerer wrote: > > > The binfmt_elf_fdpic loader has some debug trace that can be enabled at > > > build time. The recent 64-bit additions cause some warnings if that > > > debug is enabled, such as: > > > > > > fs/binfmt_elf_fdpic.c: In function ‘elf_fdpic_map_file’: > > > fs/binfmt_elf_fdpic.c:46:33: warning: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘Elf64_Addr’ {aka ‘long long unsigned int’} [-Wformat=] > > > 46 | #define kdebug(fmt, ...) printk("FDPIC "fmt"\n" ,##__VA_ARGS__ ) > > > | ^~~~~~~~ > > > ./include/linux/printk.h:427:25: note: in definition of macro ‘printk_index_wrap’ > > > 427 | _p_func(_fmt, ##__VA_ARGS__); \ > > > | ^~~~ > > > > > > Cast values to the largest possible type (which is equivilent to unsigned > > > long long in this case) and use appropriate format specifiers to match. > > > > It seems like these should all just be "unsigned long", yes? > > Some of them yes, but not all. > For example trying to use unsigned long in the last chunk of this patch: > > fs/binfmt_elf_fdpic.c: In function ‘elf_fdpic_map_file_by_direct_mmap’: > fs/binfmt_elf_fdpic.c:46:33: warning: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘long long unsigned int’ [-Wformat=] Oh, something is actually using "long long" already. :P Gotcha. Thanks! -Kees -- Kees Cook