Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1541277rdh; Mon, 25 Sep 2023 16:39:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEwcoDCcy8ejHUzVGTzgDKmKCBzhlHXbaCzGlKZl1fLCC7VUyWywpmg8zxQ6FiKks3H1u77 X-Received: by 2002:a05:6a21:607:b0:13b:d080:aa03 with SMTP id ll7-20020a056a21060700b0013bd080aa03mr5536041pzb.60.1695685145206; Mon, 25 Sep 2023 16:39:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695685145; cv=none; d=google.com; s=arc-20160816; b=mhQ0B5lm5//i+PqebN03KfRzEP7mu/ymGEsztquLB5Hrvs+YXRgrYOiTf9AbuZbtEn lgJh0zAbMdwSZSRmkSuqewgBwbMDrD7Lq+CdjsBkhO3Qfa0hbnKAEkDS8mWZwv9gtOTc 9Xc6fWuG2fOL7M1Gw49muREKa+lvMXJxT8xyR7nA6AEBbJdf3HoKXzDWHyvA9JMMfqOd Nv56ngVREQpqCOh54H5o7U1Qc/PuJsbgmdA4/lj/4g8Cy2Ia6SIWHU57jqAAQj/T3X4E WI4wQtNLChPLKa2vm7uRTsHXpwpRd6eI9tXPnMklhkmg9Lu9zK5kQlhljhjNBKQ/t8Wx WQ6w== 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=d5xMja9yFkheQHqE/iXRfDYgX6Arhzs6tk3qD/XhCzk=; fh=BkvD4RoAnYFGA6MVV+tXDRvBauDYilk5jrAkoZVgd10=; b=YycNF1msNjlb+mgA5yRzTCmFcZMLxso9Y5WnaTbtFJ95J3Oi70WbsclWD6Vnh8QGKV C2ViX4utXsIaUZNdKx4IbgQg7d0/9SC+qxhpFsnVHAuMtjMm+5UDwBXDVldSwcKT1ko9 VUt+qnwG846g5TseJyrGLZjncldjZsL5FBq6UXTG7cNOA0EjIkmZ7qtS/HMezGmJHnmB tVlsC1t00fwVJla8DMiUY1U2nsCvKt9agn+ysSv89puLHV6IZB99EY7BZqAIf6pPFBDv bqWrFCO4v7+eB4TOsfq5HpwHdozp22h45Vo7Wwiqrr7K5Q+p+H+TKuvZLV8ssQ/r5uWR YiSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lmbPPhmz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id lb14-20020a170902fa4e00b001c4605546b5si10632288plb.42.2023.09.25.16.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 16:39:05 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=lmbPPhmz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 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 groat.vger.email (Postfix) with ESMTP id D578E804B29E; Mon, 25 Sep 2023 10:06:31 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232542AbjIYRGM (ORCPT + 99 others); Mon, 25 Sep 2023 13:06:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231352AbjIYRGK (ORCPT ); Mon, 25 Sep 2023 13:06: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 539F110F for ; Mon, 25 Sep 2023 10:06:03 -0700 (PDT) Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1c465d59719so46061215ad.1 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=M10z+Pm2+KvOUzSG1h6J31lWZaEfmx7bsg1sz68ErUauluNPT1zeOyqjkS2fsjWKOs jXfXmpMP6RaJPEj1SBiLa/+3iMGcnv4sMf6K1wIunOYUqTqP4QdzzITn83ratM1xtTjt V+x6sKOLMvEPaUkyOSSlyWreCZT3xBobMgN+BvzYVfXKvIbmxp06Z35lOJDbnSeLJqdu PemQtu4n3nySju7QmXs4+Q52jEfDpY9at9YsLsGYPpSHLNwFh6/Hf864C6phzPwLqniD A1sIG6+0bYcfoFrDrPkemJKwSd0FsFHy8OG5L4D3RftXrViBDRVIxapOy6r0ZQzioeKI CPMw== X-Gm-Message-State: AOJu0YwQejPuhcAMf9NKPVauRcW+3V+Wpb9t7xyChetVc75QvRs4LPpd wKofeA6DLEWzdiI5Uu+K3oIBnQ== 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> 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 groat.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 (groat.vger.email [0.0.0.0]); Mon, 25 Sep 2023 10:06:32 -0700 (PDT) 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