Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp5083589pxb; Tue, 5 Oct 2021 17:24:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzAbBW2Wf3Lkqhjz+QNMb1sX+myzpvqjfjbltb9nqSxP39Y08azN8rPqiHTunOEBxaArVFl X-Received: by 2002:a17:906:c0d7:: with SMTP id bn23mr29698534ejb.426.1633479878467; Tue, 05 Oct 2021 17:24:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633479878; cv=none; d=google.com; s=arc-20160816; b=yitzE37tdn7fJL72hrCzkd/c5WrQlewemqRrub8CYtqP0CQUT/nZyBtfrda1dMPuNR UlZkcItsJX0tvy8vNGBxv0dbDZPFqA0/th4lkE7lvD2Sb7yYzmdAiAKnzSjqDUP2DFKS 0jVXql0MZRPqifEzHONR6hMU6Q+0SWx7A0esSdm+4CESSPjH65DiQWYvz4nMvHoRihOF EEOrPQhVcDH4nTpaCtg3HxCvQsZyqCExvAIuwmVB9L6d+h40ctNAagOA7SKyyZKtFT7g qDlO8baV1/BCslymdbH2ffLjOkN3a4Lldvjn822JdzGOa5K8rLLG7Y5xAxU4v9r9rbHE L8Tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=LFv1XLvRMSlq3XwmbMt00XdN87w55MLlvhyPKKzC144=; b=OKqESdJdnnbk3Y/4vXU/CRCOUPMFoIAIsphyYKcI3N9VFCwi6OsN9Bw1nlyyGzfz1Y F5u+zh6zbIhwVycDL+gMUxTGHko34zTbL1h15vFgfztvQl9ZZUAIgwlTwyFXAzWyKSb0 zrGrqjo+CVfJ3Efyl+eY0tb2cs1venmjxigyA3utrAnWLnZ7qZSnqNG/2Pu4sBbeaMRd qiFiRCgWUxwOi6klX958Ofo8SycJTenL7c6VXcWQ9fxtLEYIPFUytsuztilm6u7llBf9 JP4M6Ea+Xdm5pW1q61T6+Adz2sL0DqjUeS9K0rg7bILydBXdwJNiogPvq3IB0ojoPjUi +gGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=S03C9f3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f10si2461815ejf.597.2021.10.05.17.24.14; Tue, 05 Oct 2021 17:24:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux-foundation.org header.s=korg header.b=S03C9f3C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233540AbhJFAXV (ORCPT + 99 others); Tue, 5 Oct 2021 20:23:21 -0400 Received: from mail.kernel.org ([198.145.29.99]:34266 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230218AbhJFAXV (ORCPT ); Tue, 5 Oct 2021 20:23:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id DAA5B61130; Wed, 6 Oct 2021 00:21:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1633479690; bh=ltKsTN9cZ4N8XPWfPdkSWUVeIpLJzf3W7XZH7D6zU+A=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=S03C9f3C4Q4+KP1/KFfr03vmY5lzBVy0D4IpwpVkXnmO+thjW1Fv7bB4p65NWgTU/ 5Q7KQGaaaF31hx8cBfKS1WL+5FKZnk4O3rLfiGARWzZ/Y3g/cwWkcx6iHdbrjmU3EC 043YloI9L5buArku8zgAq+DihYuUyz9gRnkPbHL0= Date: Tue, 5 Oct 2021 17:21:29 -0700 From: Andrew Morton To: Alexey Dobriyan Cc: linux-kernel@vger.kernel.org, Kees Cook Subject: Re: [PATCH] ELF: fix overflow in total mapping size calculation Message-Id: <20211005172129.4092cc4148bbcac36a128b55@linux-foundation.org> In-Reply-To: References: X-Mailer: Sylpheed 3.5.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 3 Oct 2021 15:11:24 +0300 Alexey Dobriyan wrote: > Kernel assumes that ELF program headers are ordered by mapping address, > but doesn't enforce it. It is possible to make mapping size extremely huge > by simply shuffling first and last PT_LOAD segments. > > As long as PT_LOAD segments do not overlap, it is silly to require > sorting by v_addr anyway because mmap() doesn't care. > > Don't assume PT_LOAD segments are sorted and calculate min and max > addresses correctly. It sounds good, but why do I have the feeling this will explode in some unexpected fashion? Because it's elf, and that's what it does :(