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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CB13BE82CD3 for ; Wed, 27 Sep 2023 20:25:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229595AbjI0UZe (ORCPT ); Wed, 27 Sep 2023 16:25:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49160 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229458AbjI0UZd (ORCPT ); Wed, 27 Sep 2023 16:25:33 -0400 Received: from out02.mta.xmission.com (out02.mta.xmission.com [166.70.13.232]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D6FBF10E; Wed, 27 Sep 2023 13:25:29 -0700 (PDT) Received: from in02.mta.xmission.com ([166.70.13.52]:34862) by out02.mta.xmission.com with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1qlb68-004E9A-TM; Wed, 27 Sep 2023 14:25:28 -0600 Received: from ip68-227-168-167.om.om.cox.net ([68.227.168.167]:55018 helo=email.froward.int.ebiederm.org.xmission.com) by in02.mta.xmission.com with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.93) (envelope-from ) id 1qlb67-00DYm2-Qk; Wed, 27 Sep 2023 14:25:28 -0600 From: "Eric W. Biederman" To: Kees Cook Cc: Sebastian Ott , Thomas =?utf-8?Q?Wei=C3=9Fschuh?= , Al Viro , Christian Brauner , Pedro Falcato , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org References: <20230927033634.make.602-kees@kernel.org> Date: Wed, 27 Sep 2023 15:25:21 -0500 In-Reply-To: <20230927033634.make.602-kees@kernel.org> (Kees Cook's message of "Tue, 26 Sep 2023 20:42:17 -0700") Message-ID: <87il7v8itq.fsf@email.froward.int.ebiederm.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain X-XM-SPF: eid=1qlb67-00DYm2-Qk;;;mid=<87il7v8itq.fsf@email.froward.int.ebiederm.org>;;;hst=in02.mta.xmission.com;;;ip=68.227.168.167;;;frm=ebiederm@xmission.com;;;spf=pass X-XM-AID: U2FsdGVkX18Gql5jFySccJ7lzoWBXWBHedBRO+fGkGw= X-SA-Exim-Connect-IP: 68.227.168.167 X-SA-Exim-Mail-From: ebiederm@xmission.com Subject: Re: [PATCH v3 0/4] binfmt_elf: Support segments with 0 filesz and misaligned starts X-SA-Exim-Version: 4.2.1 (built Sat, 08 Feb 2020 21:53:50 +0000) X-SA-Exim-Scanned: Yes (on in02.mta.xmission.com) Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org Kees Cook writes: > Hi, > > This is the continuation of the work Eric started for handling > "p_memsz > p_filesz" in arbitrary segments (rather than just the last, > BSS, segment). I've added the suggested changes: > > - drop unused "elf_bss" variable > - report padzero() errors when PROT_WRITE is present > - refactor load_elf_interp() to use elf_load() > > This passes my quick smoke tests, but I'm still trying to construct some > more complete tests... Acked-by: "Eric W. Biederman" You might also consider using elf_load in load_elf_library. The code in load_elf_library only supports files with a single program header, and I think is only needed for libc5. The advantage is that load_elf_library would be using well tested code, vm_brk would have no callers, and padzero would only be called by elf_load, and load_elf_library would do little more than just call load_elf_library. Eric > > -Kees > > Eric W. Biederman (1): > binfmt_elf: Support segments with 0 filesz and misaligned starts > > Kees Cook (3): > binfmt_elf: elf_bss no longer used by load_elf_binary() > binfmt_elf: Provide prot bits as context for padzero() errors > binfmt_elf: Use elf_load() for interpreter > > fs/binfmt_elf.c | 192 ++++++++++++++++++------------------------------ > 1 file changed, 71 insertions(+), 121 deletions(-)