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 AC0B1C4332F for ; Tue, 8 Nov 2022 06:13:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id EA63E6B0071; Tue, 8 Nov 2022 01:13:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id E32D56B0073; Tue, 8 Nov 2022 01:13:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id CF6C06B0074; Tue, 8 Nov 2022 01:13:57 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id BD5496B0071 for ; Tue, 8 Nov 2022 01:13:57 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 89F9A140646 for ; Tue, 8 Nov 2022 06:13:57 +0000 (UTC) X-FDA: 80109259314.09.C1D7E68 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf08.hostedemail.com (Postfix) with ESMTP id 31415160009 for ; Tue, 8 Nov 2022 06:13:56 +0000 (UTC) Received: by mail-pl1-f178.google.com with SMTP id u6so13261313plq.12 for ; Mon, 07 Nov 2022 22:13:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=JX8vpBAhEPvSt1OhZU+reIbz1YtH+hIe7fUISAFUShE=; b=SM/vWxZTraSrV/v0BlwwX8bt91xcPBxY3QrouPIrkHI0YxPj3GjvN1lD9Attu5fxPJ h/Y0eq8oV4SKlMt7BvDmXKEPyr/bCAScGD6fR9JCTw6FXExTLarpAuFn0OrR0aW/TX1Z pLPXaG4wK8XVd8XlHXyLDzurQ5E+gOJjmiE4+CglliTOqUWhIpPfFMnr2riTZdu0uD1L UiEyS41YO4c6CixfTdHp97XZHfBqZa5AtANwF704hOERS6P8GZN4eUHxKgzce+ykMx9a 86MDKkbbdta3t0oSML2mw81cO7xfmoK2Ib8HM2hTmAYOXro7/dUzkE48nTmFRyaHgHm0 VTVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=JX8vpBAhEPvSt1OhZU+reIbz1YtH+hIe7fUISAFUShE=; b=VsJVuCdlPS3+v4IfiQzZ1XzYKw77S68fEmiXwTkL9VOy3gIXpeUazjA9LCfCxsFYVr hGlaFMiVoOfJ5n1MrVdkncL+BtbsLvOr+6vfDz4VPqZHZKgnr4xEEqtbtr6y6zVPW6yQ hwCQMlymIt86tzi1zy5NiZ8HWNO3yLll+umDQXfiaXhz0dZhBrzutn65hL0G297Yvhf8 3zFyEEfKX7hiIMX9lSlf+w9oCOsB3yrZ+WxUaBRqN8Ji1pL75NT01Rksp6tP0RDyYPtb P1JkA/C7W7KxTKAhAHM9V+RQs2VaG8N+BgMlc00Ik9YF75jyRi30Fvo/X1JeOx0btpBb IJZQ== X-Gm-Message-State: ACrzQf1wk8zS1froD75lVZSeyazriSEkpqDOiFyfI0E1F2K/SepRsqVy Pg8Cvx7BPDpkqL3rNMNr+2NzpytfCKNOv8Z9VJw= X-Google-Smtp-Source: AMsMyM6KKESqyvJU86mzQNQh1K6dBtWqiValwvnSMJ3R7swKmxjxJTeLjwDJho9Wz5ChwzSm/S6T/1zCTB/USBPpUWM= X-Received: by 2002:a17:90b:1113:b0:216:616c:5fa0 with SMTP id gi19-20020a17090b111300b00216616c5fa0mr25717145pjb.225.1667888036052; Mon, 07 Nov 2022 22:13:56 -0800 (PST) MIME-Version: 1.0 References: <20221106021657.1145519-1-pedro.falcato@gmail.com> <202211061948.46D3F78@keescook> In-Reply-To: <202211061948.46D3F78@keescook> From: Pedro Falcato Date: Tue, 8 Nov 2022 06:13:44 +0000 Message-ID: Subject: Re: [PATCH] fs/binfmt_elf: Fix memsz > filesz handling To: Kees Cook Cc: David Gow , linux-kernel@vger.kernel.org, linux-mm@kvack.org, sam@gentoo.org, Alexander Viro , Eric Biederman , linux-fsdevel@vger.kernel.org, Rich Felker , linux-kselftest@vger.kernel.org, kunit-dev@googlegroups.com Content-Type: text/plain; charset="UTF-8" ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="SM/vWxZT"; spf=pass (imf08.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1667888037; a=rsa-sha256; cv=none; b=O8VdOYNL+MUnvVdx97SdDFAA3f6GMSiGCTvKYjLASIatDzpENHWS4ma9R3ANm5tPKV1BUo vhOg63URahIkQWlW+u2kRYRGd5pJP3PpDoeY3gxEHkuGt49YFvE2GIyHp+wucvFEcyptEX xwLPb9bFjIZ8guCSHQLyrepoww7za/Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1667888037; 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=JX8vpBAhEPvSt1OhZU+reIbz1YtH+hIe7fUISAFUShE=; b=Qc0tXuwTxsu/oHQDjf68Jm8bX6GBMBTBY/EKbAJwE2jGCrywYKgdw5EEOdsVRWxihnL5Eq Kr9DRz+g+paurPR8m8ah+VctWN5w7ExcoUo/0MFVAG+ZkpUJGlel+stKwq+5g70bcfybi/ PEtgDMorDHhhugxdlm3ntjlsqHuRD+I= X-Rspam-User: Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b="SM/vWxZT"; spf=pass (imf08.hostedemail.com: domain of pedro.falcato@gmail.com designates 209.85.214.178 as permitted sender) smtp.mailfrom=pedro.falcato@gmail.com; dmarc=pass (policy=none) header.from=gmail.com X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: 31415160009 X-Stat-Signature: 87cqipr1h1ri8agimef7x3dmj83y7hfz X-HE-Tag: 1667888036-359119 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Mon, Nov 7, 2022 at 3:59 AM Kees Cook wrote: > Thanks for the patch! I need to triple-check this logic, as there have > been some overlapping (or out-of-order) LOAD bugs in the past too, and I > want to make sure we don't accidentally zero things that already got > loaded, etc. Hi Kees, Thanks for looking at my patch. I've submitted an (unprompted) v2 with an additional fix for a loading bug that could load segments after a .bss on top of .bss itself, which would overwrite any bss zeroing efforts. Note that this bug was already present in load_elf_binary. See a repro at https://github.com/heatd/elf-bug-questionmark, and the comments on the patch/repro for more info. Most ELF loading operating systems out there seem to fail on this one. As for overlapping/out-of-order LOAD segments, what kind of handling do we want here? The ELF spec (http://www.sco.com/developers/gabi/latest/ch5.pheader.html) says that "Loadable segment entries in the program header table appear in ascending order, sorted on the p_vaddr member.", so do we really want to support that? My -v2 was substantially simplified based on assuming ELF-compliant executables. > David, has there been any work on adding a way to instantiate > userspace VMAs in a KUnit test? I tried to write this myself, but I > couldn't figure out how to make the userspace memory mappings appear. > Here's my fumbling attempt: > https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/log/?h=devel/kunit/usercopy > > I really wish KUnit had userspace mapping support -- I have a bunch of > unit tests that need to get built up around checking for regressions > here, etc. +1 on getting this unit-tested, this is a bit of a minefield Thanks, Pedro