Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp1733986rwb; Thu, 10 Nov 2022 22:34:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf6s4Pwi/Dgaky87WEtgJVDpsBNon+RW1pXARPYLZsxIbrUoDRG5zJ8bQa2Q5AWDZa+/QEaO X-Received: by 2002:a17:902:f115:b0:186:94b8:5980 with SMTP id e21-20020a170902f11500b0018694b85980mr945070plb.113.1668148479096; Thu, 10 Nov 2022 22:34:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668148479; cv=none; d=google.com; s=arc-20160816; b=BEH6TFmG15DJfvnju5AIXVLGOplwaf/C1WBwnqs6+sijGbgt1852AE2+Rerv4E5wf0 KpilvU61OJ4YIgESjhJl53ACCEa5JC73EXCYQ0hxL+A/tEtjYZs+viVrPK0dMVYTHO6B DKv8Bya0fSVIKdOHCAiTBYeR7BkhID2L2FLBVjzYV1xVotXRAYfEnDoONRCwgVWHA9Rv 1eUH7mWGOCKNSpWF9mf/WULN51OJsY87miTKtrh7M+qKmr43JTDm5CRlhnIkj6mQpJiV RexH+jWFEqnidtMVmPBZ3JEmv/CIwDKA5JAXIecpOQ3YF89YNvxwYus7CWtMxPmxoEK+ jnhA== 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 :references:message-id:subject:cc:to:from:date:dkim-signature; bh=3askcQWU5u7LnQuB7pdoKcm0FfvzSf9Zwubk2DsWzGE=; b=kfVlGKy+PYiu71X9+/Z2BJb1Rb1eYoIK11P2lNzly7Cy7fnngVxKUoVngr1gyOMyxT rdStTf54LbWDqvUZo199ysp/DGO5JCM7syTAbc4Yv/dIOCqs7qVbX2CQ54g4Q1dlFaJi UkH6SFH/+TFpFWaJmU3gkrIqoDPBNXKBT2+d6vMmal9XlAROZlR2kJyWM6ZCyMJZoq0U 4oYqOuuyibsTrdAFIswEmtmNx5M2w1KubhWz7DMPjUhCoBkdGOuuZbqd/4tZZWqJysxi TbJYUyFiO7rIraDtmZqByTsq4/S8kZv9RVTgL/dO+59hjJMAg2x/K2t+en5ABzATxRKu 86dQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=L1oBnin8; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u14-20020a170902e5ce00b001869fd74e0csi1885078plf.311.2022.11.10.22.34.27; Thu, 10 Nov 2022 22:34:39 -0800 (PST) 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=@chromium.org header.s=google header.b=L1oBnin8; 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=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232182AbiKKGPt (ORCPT + 93 others); Fri, 11 Nov 2022 01:15:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230377AbiKKGPq (ORCPT ); Fri, 11 Nov 2022 01:15:46 -0500 Received: from mail-pg1-x531.google.com (mail-pg1-x531.google.com [IPv6:2607:f8b0:4864:20::531]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 11D0613FB8 for ; Thu, 10 Nov 2022 22:15:46 -0800 (PST) Received: by mail-pg1-x531.google.com with SMTP id b62so3694238pgc.0 for ; Thu, 10 Nov 2022 22:15:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=3askcQWU5u7LnQuB7pdoKcm0FfvzSf9Zwubk2DsWzGE=; b=L1oBnin8Hpo+fK10aQNq4eUkZbDFTu59oUwCi+IoRQfum8uX7ny0hpNLGFiZnZrCc6 b2TxrxrsaQ/vk4T7zYLJEsEIW7kpHnmiBGbvgLgo+fiuyN3lmpEdy2BY5g7UBWwBkyeQ F6hjncS8YIGSDaG6cKlq1qVZHFTtlXz02EOqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to: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=3askcQWU5u7LnQuB7pdoKcm0FfvzSf9Zwubk2DsWzGE=; b=X0JSzfVKuN/LJZONJF99pO1whs8rYxPF6oapKhWyUUA/jAv53cBSZ4hk/j8pf88cPR jhtOA4aa8lEF7PSie7dHjfvTarCD+xjdnRtJSvE9NjrWWjXgS+DgoMQpCQqQdxrQsY+U UzoGFrGflPtVg/H7o4//h3gvP/N9hR5bYrpqmSVwVDicl4x+l/YTrMLEtG4nsWOkDs7F mAVF50r8JbCkibyzg9Bumy26iKvYrvI3chxyUDB26YIzyTCEkhOuzcwOWgfHJ3MX3ZpK WnJajNMxCaAEsXNjnyN/kQ9eTgNdzv3iQ63V2q7pSYFrENog/OVWD0J+DZvd6Kv2Ri3y m78w== X-Gm-Message-State: ANoB5pkmA7vfEitNc+ei525NpDu42vcr8bgfyAZSH84dAoY2QA/6OPv9 HOwYCwr7pJresqtnzmkAP30syg== X-Received: by 2002:a63:1c09:0:b0:46b:2bd4:f298 with SMTP id c9-20020a631c09000000b0046b2bd4f298mr445240pgc.135.1668147345532; Thu, 10 Nov 2022 22:15:45 -0800 (PST) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id ja13-20020a170902efcd00b0017f7c4e260fsm760315plb.150.2022.11.10.22.15.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 10 Nov 2022 22:15:44 -0800 (PST) Date: Thu, 10 Nov 2022 22:15:44 -0800 From: Kees Cook To: Pedro Falcato Cc: linux-kernel@vger.kernel.org, linux-mm@kvack.org, dalias@libc.org, ebiederm@xmission.com, sam@gentoo.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH v3] fs/binfmt_elf: Fix memsz > filesz handling Message-ID: <202211102214.D764FAE21@keescook> References: <20221108110715.227062-1-pedro.falcato@gmail.com> <202211101934.22CACD615@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham 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 Fri, Nov 11, 2022 at 03:59:08AM +0000, Pedro Falcato wrote: > We could of course also just sort the program headers at load time, > but I assume that's unwanted overhead for most well behaved ELF > program headers :) Large refactoring of the ELF loader needs proper unit testing, and we're still a bit away from that existing. In the meantime, we'll need to make very very small changes to fix bugs. I've sent a minimal change which I think should fix the problem (now at v2 since right after sending it I realized I was trading one accidentally correct state for another in the v1): https://lore.kernel.org/linux-hardening/20221111061315.gonna.703-kees@kernel.org/ -- Kees Cook