From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D3951CE7AA8 for ; Mon, 25 Sep 2023 17:06:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229437AbjIYRGK (ORCPT ); Mon, 25 Sep 2023 13:06:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232402AbjIYRGJ (ORCPT ); Mon, 25 Sep 2023 13:06:09 -0400 Received: from mail-pl1-x62c.google.com (mail-pl1-x62c.google.com [IPv6:2607:f8b0:4864:20::62c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52F2610E for ; Mon, 25 Sep 2023 10:06:03 -0700 (PDT) Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1c3d8fb23d9so46089315ad.0 for ; Mon, 25 Sep 2023 10:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695661563; x=1696266363; 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=d5xMja9yFkheQHqE/iXRfDYgX6Arhzs6tk3qD/XhCzk=; b=lmbPPhmzMhFZBmbhpZJM7/G3wWI2zHz4tWe06inVvBywhiINdVthCsbUCMVLMEM0y9 KTwwfucFgIlW+09Mfrv8iqdCPrD5Ksk+M+OF3Mi/PcTEeIdn06v8RoEAQchPHslLD/Xx VURoXtTCmhjGe07NtZRrmeYLbM9ZRunrqG7zs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695661563; x=1696266363; 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=d5xMja9yFkheQHqE/iXRfDYgX6Arhzs6tk3qD/XhCzk=; b=Q89/+Mcx2VViokBTAWVC4a/6AUySDUEykMPIWaBBE2iYEA0KmG5YOkMo/W8Ejuwc5c kLRZ8aPLaMcxtOKy8Xuxbgrjh+B+SAjFc+CHvHNbdu57rBqV2X7EssOziC46C9jvQzAp HvZY3+5JyrNeS9z9rVxLJMJ614rVngPgcnp0W20D1ctiE0jYIBN+4AEikLLW3U/rWpIL zxzY4SFuz205memNeyBFEtB0bhBWoPqBQ8eHl/dQC+NJrbAxAnXrVpDZjU3mZwjJjtKM Xl7Y8SZNucbCvEU2jI5Z4FnPTkfy9DDpkxRPXFkLlV9EKMoGfyCYTqAQFBED1mpyuIDy COTg== X-Gm-Message-State: AOJu0Yzp1flQwnufzhvaFyvbRVYP/0fY6wHBwGUPt5qkXBwHy9cj9fv/ Oqnedb8RN/13KZ5rYa6qT1dZnA== X-Google-Smtp-Source: AGHT+IHpX/s355Isj57+S+omPh8sCxTjLdauW2heADkSvyIbh1n4SyJZJ9E+Cl2v/svT8YApVibwpg== X-Received: by 2002:a17:902:934a:b0:1bc:10cf:50d8 with SMTP id g10-20020a170902934a00b001bc10cf50d8mr4663367plp.23.1695661562783; Mon, 25 Sep 2023 10:06:02 -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 d2-20020a170902cec200b001c5fc11c085sm5222785plg.264.2023.09.25.10.06.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 10:06:02 -0700 (PDT) Date: Mon, 25 Sep 2023 10:06:01 -0700 From: Kees Cook To: Sebastian Ott , "Eric W. Biederman" , Pedro Falcato Cc: Thomas =?iso-8859-1?Q?Wei=DFschuh?= , Alexander Viro , Christian Brauner , Mark Brown , Willy Tarreau , sam@gentoo.org, Rich Felker , 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: <202309251001.C050864@keescook> References: <20230914-bss-alloc-v1-1-78de67d2c6dd@weissschuh.net> <36e93c8e-4384-b269-be78-479ccc7817b1@redhat.com> <87zg1bm5xo.fsf@email.froward.int.ebiederm.org> <37d3392c-cf33-20a6-b5c9-8b3fb8142658@redhat.com> <87jzsemmsd.fsf_-_@email.froward.int.ebiederm.org> <84e974d3-ae0d-9eb5-49b2-3348b7dcd336@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <84e974d3-ae0d-9eb5-49b2-3348b7dcd336@redhat.com> Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org On Mon, Sep 25, 2023 at 05:27:12PM +0200, Sebastian Ott wrote: > On Mon, 25 Sep 2023, Eric W. Biederman wrote: > > > > Implement a helper elf_load that wraps elf_map and performs all > > of the necessary work to ensure that when "memsz > filesz" > > the bytes described by "memsz > filesz" are zeroed. > > > > Link: https://lkml.kernel.org/r/20230914-bss-alloc-v1-1-78de67d2c6dd@weissschuh.net > > Reported-by: Sebastian Ott > > Reported-by: Thomas Weißschuh > > Signed-off-by: "Eric W. Biederman" > > --- > > fs/binfmt_elf.c | 111 +++++++++++++++++++++--------------------------- > > 1 file changed, 48 insertions(+), 63 deletions(-) > > > > Can you please test this one? Eric thanks for doing this refactoring! This does look similar to the earlier attempt: https://lore.kernel.org/lkml/20221106021657.1145519-1-pedro.falcato@gmail.com/ and it's a bit easier to review. > That one did the trick! The arm box booted successful, ran the binaries > that were used for the repo of this issue, and ran the nolibc compiled > binaries from kselftests that initially triggered the loader issues. Thanks for testing! I need to dig out the other "weird" binaries (like the mentioned ppc32 case) and see if I can get those tested too. Pedro, are you able to test ppc64le musl libc with this patch too? -Kees -- Kees Cook