Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2194249rdh; Tue, 26 Sep 2023 16:02:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFiHXEcH0B4UCFtpEsHGELOsumRepdVCI2MigUTDDBSa9krgPh+zDgXeoDj1n/D2ZrI6Ksp X-Received: by 2002:a17:902:650d:b0:1c6:11ca:8861 with SMTP id b13-20020a170902650d00b001c611ca8861mr4375259plk.21.1695769330285; Tue, 26 Sep 2023 16:02:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695769330; cv=none; d=google.com; s=arc-20160816; b=sz7InjDIZ3NSXGyRAjQLiFmbjqVfV/TtEkAv0AvP7vpZ8EqpAjflXfeUzCWQltjjtq maG14SO/hYO0MOrg4SRWKxaDu4gw5lNrFQuYKbDND/CyUEiMxsAA4CHGw86W2CQrNxid cZ6Lmzb2E6rg9xJnZUy9Nu3eLfxcE5e7ZLwhUe0GHng0bJZKdGPzU4hz5+CfUyAyQeiV FScTrZg9vC9mCbu5axVUirek+2xmQy8nRSBxNje0HLvRNr3eGdFlTX1GVEd4sU39UMaR 3PeCoaw4e4rN4N0TiT53Th4cYV6lTWMK0BeuTTTovgjXeE6phihFycrYJkoVW9lYrjoP A8kQ== 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 :message-id:subject:cc:to:from:date:dkim-signature; bh=cRs3HHfGHaH5W3/uj1x1VaVTGyeeNQR7KwXCiLuCrmM=; fh=3HAABJwmKj7dh+VJqxj6dUra625CoQADKQvuVU16T1k=; b=NXLhzXxOAGv/6qgS/9yD833b2UQRH6DM0CT5pYiSnYzQbR6F6MafCsDlrf4IjPQJFg 8Px8vwWFjspwHe1FO0afYMnXICDxs4eVjKgOm00yH/0Y87hZU0T7sH1BrftgVMXmVWLY o/f5kfPggo2wVB2dHkF72ALjhJY9l6v+/5oxgqV9TS8oEzE49gnTHay5gl4ziwvVPe1O OnyjYyciVOOYmnUIMlvz7xzgdHjhO+CQ+BRnCz/XoKTSQp/FUc74i5MSEgxJlDnWGpja Oj80Xh+RgYpW4CLDne+IF5Qn4alNjWqVv4zSHmihUsV/RkpTpHh07M1JDp0pCKe+wCZU zY+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bz7BUBGI; 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=linaro.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id o13-20020a170902d4cd00b001b3d6c68bd1si112837plg.643.2023.09.26.16.02.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 16:02:10 -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=@linaro.org header.s=google header.b=bz7BUBGI; 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=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 6E0A0828DE70; Tue, 26 Sep 2023 06:50:14 -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 S234890AbjIZNuL (ORCPT + 99 others); Tue, 26 Sep 2023 09:50:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234882AbjIZNuK (ORCPT ); Tue, 26 Sep 2023 09:50:10 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AE33CF3 for ; Tue, 26 Sep 2023 06:50:02 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-4053cb57f02so77179845e9.1 for ; Tue, 26 Sep 2023 06:50:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1695736201; x=1696341001; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=cRs3HHfGHaH5W3/uj1x1VaVTGyeeNQR7KwXCiLuCrmM=; b=bz7BUBGI6h61JBq7BxRn1D+HQiufLhNn2a2hvsJ4pr1rTZNqiOQ6xWB8MGtNINuY26 ofOqJ/Zq00wEW4hDfz9MuhaT/uj8dBtcw0i4kXr2JNN/DTTVU6wN1zAys0p4ZOtzz4Q+ 9MI64iukHtMbuB7iXu4FTVIv3IjNrgEkNj3zcF/74MtSrgzWtP6eR6wODi9/CpGsBrai qsSuA0IGwcCzaGMHyIA1SphmKJff+wnUp8sVheWvfR3yP7jZzf5af59UT2iFslxg87C4 ueY2oHMa3JAPt4q239D51f5HuxZ2CKlLJuGLxmLrZBk3EgT01JnCpkUn6ApZTb3qzi0e XMIw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695736201; x=1696341001; h=in-reply-to:content-disposition:mime-version:message-id:subject:cc :to:from:date:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=cRs3HHfGHaH5W3/uj1x1VaVTGyeeNQR7KwXCiLuCrmM=; b=WG62T5snGOb8MleBd6gmbPzcEmKvB26KsRromKcN6PS1JU9N5Exl2Mp2xHF7r5ingJ 8YfXc5Iq55OeO31aYDvehQK3ZIBuK1r2kRpt5VORLmrcFNn8JIX+1Ue1JjihE9k7GerM ScXb/8WJO46sRzAQ2v9hYrJ6gOjxrelOoayWdbBp5xNO9L1i5h9GsqiHREK7ySmKRXee UsMkg0A7cuVwSiwkL3AoX+1TUejmE4KlEKeCJZ2b2jhCuVf7aUqyHUnFsntJ1WLtomts 2xz6uvsnHE9ZH6fxLMZMtNyDyPLYlcRmgUO0Q3a4BVkOOB/7mgoPoUfOGahYgbe13us5 CfvQ== X-Gm-Message-State: AOJu0YzbZrbEKhYSMr71rDVUa8t+G3yTflFhln+9YxdSL5vBDNkov9Wi ilZRPdm3CYmPL8X6LfAkcE0IzA== X-Received: by 2002:a5d:4fc9:0:b0:31a:dc2e:2db2 with SMTP id h9-20020a5d4fc9000000b0031adc2e2db2mr9310520wrw.49.1695736200924; Tue, 26 Sep 2023 06:50:00 -0700 (PDT) Received: from localhost ([102.36.222.112]) by smtp.gmail.com with ESMTPSA id o11-20020a056000010b00b0031c52e81490sm14821340wrx.72.2023.09.26.06.49.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 06:50:00 -0700 (PDT) Date: Tue, 26 Sep 2023 16:49:57 +0300 From: Dan Carpenter To: oe-kbuild@lists.linux.dev, "Eric W. Biederman" , Sebastian Ott Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev, Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Alexander Viro , Christian Brauner , Kees Cook , Mark Brown , Willy Tarreau , linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] binfmt_elf: Support segments with 0 filesz and misaligned starts Message-ID: <60c7fdeb-da32-4d21-9e34-368050224d6c@kadam.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <87jzsemmsd.fsf_-_@email.froward.int.ebiederm.org> X-Spam-Status: No, score=-0.9 required=5.0 tests=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 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]); Tue, 26 Sep 2023 06:50:14 -0700 (PDT) Hi Eric, kernel test robot noticed the following build warnings: https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Eric-W-Biederman/binfmt_elf-Support-segments-with-0-filesz-and-misaligned-starts/20230925-210022 base: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/execve patch link: https://lore.kernel.org/r/87jzsemmsd.fsf_-_%40email.froward.int.ebiederm.org patch subject: [PATCH] binfmt_elf: Support segments with 0 filesz and misaligned starts config: i386-randconfig-141-20230926 (https://download.01.org/0day-ci/archive/20230926/202309261925.QvgPAYL7-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14) 12.2.0 reproduce: (https://download.01.org/0day-ci/archive/20230926/202309261925.QvgPAYL7-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot | Reported-by: Dan Carpenter | Closes: https://lore.kernel.org/r/202309261925.QvgPAYL7-lkp@intel.com/ smatch warnings: fs/binfmt_elf.c:431 elf_load() error: uninitialized symbol 'map_addr'. vim +/map_addr +431 fs/binfmt_elf.c a6409120b31666 Eric W. Biederman 2023-09-25 390 static unsigned long elf_load(struct file *filep, unsigned long addr, a6409120b31666 Eric W. Biederman 2023-09-25 391 const struct elf_phdr *eppnt, int prot, int type, a6409120b31666 Eric W. Biederman 2023-09-25 392 unsigned long total_size) a6409120b31666 Eric W. Biederman 2023-09-25 393 { a6409120b31666 Eric W. Biederman 2023-09-25 394 unsigned long zero_start, zero_end; a6409120b31666 Eric W. Biederman 2023-09-25 395 unsigned long map_addr; a6409120b31666 Eric W. Biederman 2023-09-25 396 a6409120b31666 Eric W. Biederman 2023-09-25 397 if (eppnt->p_filesz) { a6409120b31666 Eric W. Biederman 2023-09-25 398 map_addr = elf_map(filep, addr, eppnt, prot, type, total_size); a6409120b31666 Eric W. Biederman 2023-09-25 399 if (BAD_ADDR(map_addr)) a6409120b31666 Eric W. Biederman 2023-09-25 400 return map_addr; a6409120b31666 Eric W. Biederman 2023-09-25 401 if (eppnt->p_memsz > eppnt->p_filesz) { a6409120b31666 Eric W. Biederman 2023-09-25 402 zero_start = map_addr + ELF_PAGEOFFSET(eppnt->p_vaddr) + a6409120b31666 Eric W. Biederman 2023-09-25 403 eppnt->p_filesz; a6409120b31666 Eric W. Biederman 2023-09-25 404 zero_end = map_addr + ELF_PAGEOFFSET(eppnt->p_vaddr) + a6409120b31666 Eric W. Biederman 2023-09-25 405 eppnt->p_memsz; a6409120b31666 Eric W. Biederman 2023-09-25 406 a6409120b31666 Eric W. Biederman 2023-09-25 407 /* Zero the end of the last mapped page */ a6409120b31666 Eric W. Biederman 2023-09-25 408 padzero(zero_start); a6409120b31666 Eric W. Biederman 2023-09-25 409 } a6409120b31666 Eric W. Biederman 2023-09-25 410 } else { a6409120b31666 Eric W. Biederman 2023-09-25 411 zero_start = ELF_PAGESTART(addr); a6409120b31666 Eric W. Biederman 2023-09-25 412 zero_end = zero_start + ELF_PAGEOFFSET(eppnt->p_vaddr) + a6409120b31666 Eric W. Biederman 2023-09-25 413 eppnt->p_memsz; For this else path, map_addr is only set if there is an error. a6409120b31666 Eric W. Biederman 2023-09-25 414 } a6409120b31666 Eric W. Biederman 2023-09-25 415 if (eppnt->p_memsz > eppnt->p_filesz) { a6409120b31666 Eric W. Biederman 2023-09-25 416 /* a6409120b31666 Eric W. Biederman 2023-09-25 417 * Map the last of the segment. a6409120b31666 Eric W. Biederman 2023-09-25 418 * If the header is requesting these pages to be a6409120b31666 Eric W. Biederman 2023-09-25 419 * executable, honour that (ppc32 needs this). a6409120b31666 Eric W. Biederman 2023-09-25 420 */ a6409120b31666 Eric W. Biederman 2023-09-25 421 int error; a6409120b31666 Eric W. Biederman 2023-09-25 422 a6409120b31666 Eric W. Biederman 2023-09-25 423 zero_start = ELF_PAGEALIGN(zero_start); a6409120b31666 Eric W. Biederman 2023-09-25 424 zero_end = ELF_PAGEALIGN(zero_end); a6409120b31666 Eric W. Biederman 2023-09-25 425 a6409120b31666 Eric W. Biederman 2023-09-25 426 error = vm_brk_flags(zero_start, zero_end - zero_start, a6409120b31666 Eric W. Biederman 2023-09-25 427 prot & PROT_EXEC ? VM_EXEC : 0); a6409120b31666 Eric W. Biederman 2023-09-25 428 if (error) a6409120b31666 Eric W. Biederman 2023-09-25 429 map_addr = error; a6409120b31666 Eric W. Biederman 2023-09-25 430 } a6409120b31666 Eric W. Biederman 2023-09-25 @431 return map_addr; a6409120b31666 Eric W. Biederman 2023-09-25 432 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki