Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2814377rdh; Wed, 27 Sep 2023 13:37:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFTKR5PFbMH4yLEqAsuTzW6UtshOUap8vjCKj9TdiOVz+fACci2aXfYfEeak+nCqMATSaQ4 X-Received: by 2002:a05:6a21:33a8:b0:15e:8962:4101 with SMTP id yy40-20020a056a2133a800b0015e89624101mr3100984pzb.54.1695847048092; Wed, 27 Sep 2023 13:37:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695847048; cv=none; d=google.com; s=arc-20160816; b=FMRj9CuAvDSXtmQ99svulh45imYB2qGGsjvS4UBMG2AOWO6w053MVM0sKqYxqfqfG7 CgmP6q2B4fYx6CZdN+N1S30xthT4lLrIkVxlovrfBgAI4MSn/mzIoIj3odBlzZPhUxFT MFeYl1Lud8J8Y4DsOEQSN33mvoMV89p4hADgF+yFd4DF4QL3Z5w1SRNW9d/rKPxQw0fk uqKq5gD0gLI9NzEGkjPfGPt0XWveLj1cU1Dwir620m2T0roxp9sp6IMeTky5u/1+rske gW9K1uiuvQxB4OjRWgGLX5s5qS3bKc9BurDz569y3UvIup5B7b50UOXGZ0Q6mAUHU5Ud 9byw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:mime-version:user-agent:message-id :in-reply-to:date:references:cc:to:from; bh=9FumygMNZmKvLRRrBZtlzRtzdmubQ5q5/W9BWXBpAcA=; fh=N3pYfcTbUxEQ8r3kuAu8LSocIJq9UEHuPuFmnDXfBx4=; b=cvJEd5EoacYL5Qgyg+TBqeYegcJsb9V5RTk9q0dxzufzhGKjwtQMATriJ+6kxsSfz0 v9t55QtuS9zxN+LcmvFmP7hDns0SJ1n74xJWTToHIbWzzvwiGlWanZTK11z+53xw1QG2 hsmYpuE207TubnYjHCMgP3TxZGPYRLFRWQy18r0df9S+PSPQzEaVGfRjOg5Oh+ffN8iH 0Gao+BynU0JScu77liAcSj4a2HyfFTZtxx/CCfTjOz7ToOriva9egAlN95AYkegFqWTR 9uQanHrqjX8wpisMny+aKUxyMkQFnjxf7ImQwFhjSvtTa0wijdtcXVZV7cgVvWXx/tin msEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id v189-20020a6389c6000000b0056a1a149034si16647423pgd.650.2023.09.27.13.37.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 13:37:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) client-ip=23.128.96.33; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.33 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=xmission.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 13EAD807BEE3; Wed, 27 Sep 2023 13:25:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229664AbjI0UZe (ORCPT + 99 others); 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 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-DCC: XMission; sa07 1397; Body=1 Fuz1=1 Fuz2=1 X-Spam-Combo: ;Kees Cook X-Spam-Relay-Country: X-Spam-Timing: total 487 ms - load_scoreonly_sql: 0.04 (0.0%), signal_user_changed: 11 (2.3%), b_tie_ro: 10 (2.0%), parse: 0.90 (0.2%), extract_message_metadata: 15 (3.1%), get_uri_detail_list: 1.14 (0.2%), tests_pri_-2000: 21 (4.3%), tests_pri_-1000: 2.5 (0.5%), tests_pri_-950: 1.31 (0.3%), tests_pri_-900: 1.07 (0.2%), tests_pri_-200: 0.86 (0.2%), tests_pri_-100: 3.7 (0.8%), tests_pri_-90: 67 (13.8%), check_bayes: 66 (13.5%), b_tokenize: 6 (1.3%), b_tok_get_all: 6 (1.3%), b_comp_prob: 1.99 (0.4%), b_tok_touch_all: 47 (9.7%), b_finish: 0.90 (0.2%), tests_pri_0: 200 (41.1%), check_dkim_signature: 0.51 (0.1%), check_dkim_adsp: 2.4 (0.5%), poll_dns_idle: 148 (30.4%), tests_pri_10: 2.2 (0.4%), tests_pri_500: 157 (32.2%), rewrite_mail: 0.00 (0.0%) 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-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Wed, 27 Sep 2023 13:25:48 -0700 (PDT) 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(-)