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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AA4AC433FE for ; Fri, 11 Nov 2022 06:15:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 5D0156B0071; Fri, 11 Nov 2022 01:15:47 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 57DE66B0072; Fri, 11 Nov 2022 01:15:47 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 444EB6B0074; Fri, 11 Nov 2022 01:15:47 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 30A166B0071 for ; Fri, 11 Nov 2022 01:15:47 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id 02D8CC1435 for ; Fri, 11 Nov 2022 06:15:46 +0000 (UTC) X-FDA: 80120150334.05.E4848C4 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf15.hostedemail.com (Postfix) with ESMTP id A105CA000A for ; Fri, 11 Nov 2022 06:15:46 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id q71so3652333pgq.8 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=nG0m4+gKbYYELu6vhDkXC+zspadUEO+4/7QKpfKtEATX6K+9PZGWbO79qcqEfuLj1B 0kBT7Vvnx/9iiVK3zR3wu1JmB0ggaSOMlmFzq2ZVNQ1VKbiwE1tw0AZLjKikzojavWkh 3htlKafITqnnFTsDk+eRPWamt60uJB+DLESMMSkq78LFlhpZHEBRi0ERHgHn2bltzKhe XhKM6P+5aIsoCOsqKTDd+v/WUsSHJzbSZFu1QnCkGMnXEY/sKZ77MyvOUyRBK+2QpYKM 78UUdcSQwqsmJ/9Bpyj1suihXCTOYBsrNWdoLhGzNIuqZJGGR0KPeBhUx2SxORotzqIL +dFg== X-Gm-Message-State: ANoB5pmWbEt8ByFfQvRlDqyqo1LKFO41xcIh2UdNoWPoUD7V751uAi0m mePNo0EFoVtISUho4bHwLm/lpQ== X-Google-Smtp-Source: AA0mqf6WEaBmALGXMxgkBBL09bKlayGHwQr4T1+exECrVOPEE5WFAGY9fLj9KxzTz7lJim+9TSVTEA== 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: ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1668147346; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=3askcQWU5u7LnQuB7pdoKcm0FfvzSf9Zwubk2DsWzGE=; b=P4SKIqiPMeeFT8NTBY+nCSStEaT2bmgDoZqmnb/YVjLPho+SiR0E4KVkecEVirQL/IL2PY oa2EFluWf0XmhCB1bSOWLuKFcTfcnQEupMCNiqA9wZI7c9W4JTV0zS37qf5wgimPs1MYi+ ZTb3sMSB4NPi19h8unV6jg5FuX1E5lY= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=L1oBnin8; spf=pass (imf15.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1668147346; a=rsa-sha256; cv=none; b=8mZEVrk0jW/6b2V0JvAMd1DdfkM5XrfgbLEF2itzXg6Ov79ANOhP7IaYqmy2Kph3FTH3qH Pzu7V16bVDYVFq1y4rnQsOviwcl2zmp4o+cDuUd3/3aRhHg0EVzqjvSRzj6cYbjXSmCE85 jIiL5aIRIIgPIJGUPgC2O4PqO9Y7Yj0= X-Stat-Signature: h53gmiupfuz6crhzhux9f1circbsud3f X-Rspamd-Queue-Id: A105CA000A Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=L1oBnin8; spf=pass (imf15.hostedemail.com: domain of keescook@chromium.org designates 209.85.215.172 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam07 X-Rspam-User: X-HE-Tag: 1668147346-468672 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000006, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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