Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp3827111rdh; Fri, 29 Sep 2023 03:42:20 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFvEIzeS8d7RM9GPtzgHnBeNHhDG87ko+1oy5nbE46kLGABIirTCfzizD6lCjQKelugf/e1 X-Received: by 2002:a05:6a20:938f:b0:163:11b2:1068 with SMTP id x15-20020a056a20938f00b0016311b21068mr1370848pzh.42.1695984139607; Fri, 29 Sep 2023 03:42:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695984139; cv=none; d=google.com; s=arc-20160816; b=iJ4b3+HtVRL4o+UtF1FjETT2xo+ptSTA1rq8kRH5ntnvECOxCOcOTjvPjc4eMsqb+y Sz4WlUXsg4MQk7QYJM0FGDXl6ES2CsrlnRqtzGttJAq6MQzyPRez3M8BrN+bWHhlOVJa b/V2QPa0+QN2I13eWTpQ76dUWiml09DTJLe/hRMXiVq5w7GironGoKLDAnawbMh8MM21 XgdX5lF9bL+Yk0e9jPoYrTqjCunojfBlNbC+sNQlwEFq9s38/+DsXcgF8xhQF1ivYAv/ UqIyUUdwva5guNxokfga6RyXPMpVA/QJ595j1zPsWsX9VYXCuYFmCwoZ7XFmPSyxM/9S KRAQ== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=DZpy/gLfnuMsQ3zYwfMZFr7l/UudGqfvJfNYCKkC6BA=; fh=XX5IXYH8cr6m1JvqVhV2T0rYnPj2s5ee3zd7sxhMDe4=; b=r2SJOGEZ3sSae09JaL74rgS2yTgfHd6+qXQiadlJE4VXT29eOK+yZFGHolKAxaeCIT MwfFvkv/nw5Orrp1zUNnG87nc/J+LhCNcv49tQMVS15mVcfCvXJUY/F8Hzch3CVN0WZD 6iO3Ghu0BY7bKEvjGvfvpaDODtZtsliZaQUilbQfkXX3qnRB5uwgQraGkK+3hnidK7/Q t2xVAjLakg4P0+MvtusgGIzwI4JONThpuQeqPebKdRnky25FHwXtjo4+J4qzk/s68bFs x1IdFgMEIMFPDLpgfi3mnL8Qyg2zEyiTogs/A9TVvIlUEy4CNKYAZwEsJ1Hd71SJU4Oc SwHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=OjoTLLKT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lipwig.vger.email (lipwig.vger.email. [23.128.96.33]) by mx.google.com with ESMTPS id ay6-20020a1709028b8600b001c465e1e219si19855668plb.30.2023.09.29.03.42.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Sep 2023 03:42:19 -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; dkim=pass header.i=@chromium.org header.s=google header.b=OjoTLLKT; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 3F9808363675; Thu, 28 Sep 2023 20:24:54 -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 S229815AbjI2DYl (ORCPT + 99 others); Thu, 28 Sep 2023 23:24:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50996 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229541AbjI2DYk (ORCPT ); Thu, 28 Sep 2023 23:24:40 -0400 Received: from mail-pl1-x62d.google.com (mail-pl1-x62d.google.com [IPv6:2607:f8b0:4864:20::62d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 99872199 for ; Thu, 28 Sep 2023 20:24:37 -0700 (PDT) Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1c453379020so102778515ad.1 for ; Thu, 28 Sep 2023 20:24:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695957877; x=1696562677; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=DZpy/gLfnuMsQ3zYwfMZFr7l/UudGqfvJfNYCKkC6BA=; b=OjoTLLKT2BLmAAwOCFmylxZWmrd8SbraEqzMVMu3orKXWJYB8mjAuosRLOmD+TC7Bz gTfm+1xA0YRedGX5bo4NUJdIq4ndJ82qIhixDAUh/u86sYdd057zDna4w4uR8QNZAQy7 G4xgnn+D3W9igApDT5au+08XUNb1n1kMzAES0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695957877; x=1696562677; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=DZpy/gLfnuMsQ3zYwfMZFr7l/UudGqfvJfNYCKkC6BA=; b=aXpff0M4Rpphv9IIo6UiLs4z4h5X++5kAa17nL9WjfspSkFGVs5Xzh0xdHe7LsrC3T LN5TxmdbWYGetKMsoTdymOrxeGIO4FKU3kb+IA9GWGKhtoUAD1pzawd1q2vs9wEFmee0 WW2dvAzkv2uV7+vv7Oo8Dsp5AunIdSKkSZC5IKeAWIAVOJBXFih172yLt9LqFuG+SHTY wsWhHj0K9Cr+W+1Z8WqnDqp9rXq21+0zNawzAXmZwhqFGbDWoTOVJNdEVCnGyA/EjdzA B/4Q3+wDscGzgsrwLh6OxyMfxuxLJygyg8EpA34h67eyMwI0kvBJlGaC9+cFQ36xz0q8 TztA== X-Gm-Message-State: AOJu0YwQ2k0gf7zE1Xu88vNmDzyGcp+TIdrUZJbv/NCOpjTC1Mc7PeVF FxxdjtifsPN1wqaWKuBpRyVx0g== X-Received: by 2002:a17:903:1cf:b0:1b8:94e9:e7b0 with SMTP id e15-20020a17090301cf00b001b894e9e7b0mr3606862plh.9.1695957877031; Thu, 28 Sep 2023 20:24:37 -0700 (PDT) Received: from www.outflux.net (198-0-35-241-static.hfc.comcastbusiness.net. [198.0.35.241]) by smtp.gmail.com with ESMTPSA id iw12-20020a170903044c00b001bf574dd1fesm6250537plb.141.2023.09.28.20.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 20:24:36 -0700 (PDT) From: Kees Cook To: Eric Biederman Cc: Kees Cook , Sebastian Ott , =?UTF-8?q?Thomas=20Wei=C3=9Fschuh?= , Pedro Falcato , Al Viro , Christian Brauner , Andrew Morton , linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-hardening@vger.kernel.org Subject: [PATCH v4 0/6] binfmt_elf: Support segments with 0 filesz and misaligned starts Date: Thu, 28 Sep 2023 20:24:28 -0700 Message-Id: <20230929031716.it.155-kees@kernel.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 X-Developer-Signature: v=1; a=openpgp-sha256; l=1382; i=keescook@chromium.org; h=from:subject:message-id; bh=uV4AJsRv4n/gB4mSOC9KIOnGOAI8uNiU0zUGBP7t1x8=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlFkNxLv+WtDGXS3EGA7QG2806nd9yzM662vbJz Z/QF9lP7jqJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRZDcQAKCRCJcvTf3G3A Jl1KD/4w77J7PmG0TdHjUB7lH4ZlBX43xi8xD755lb9vhHxLRTtI3hqQ+JvyAc97r4JGaph3Jk3 +kKf02DqkcBcEm0W7oeO0JKZtqIfM8XEHkHQ9/pE8mKfalwC5DCFnIJbNcsdxr9SSwhz0POUO3E QaUEJZjccKFkHTwDKLd3XRvNdDZ3jll5HxQfWEKXvyjNCHVTG5jgC+GQB8d+RSZPwp1CGvEWqN5 4GDF1tB2l1DHa4lX6yI8qPhawqRzZuJFTO3SSse+E2IPkgfkt6VfJ8cWyqDd6AMALfIOl3hIq7E u0hVjNyK8WcQSmSzMHbrAHi1hVxdRRZzfKJw49k9mbc3zUKx2iTEbJRitqjEQOXaE9xDtpENZ8z ACRF8mJ3ewqtPtv5N3XhiB9SiOUGIBaWR5qCcgL989zLDhLf7IdBgj6pCpz+35BH+8Jx3ioPlse tvWvLx1KjocOYMQWqde+FJQsJokrG/P2gt8jKDPp96b16uQlble+qU64f0zUbbTRQXjRaGP9JE6 lUxI28L4rZ/qPL2gFq6pMGTT2offlDs6i1y5OBptudXqWdphur4s1n/ctL4RlT89tTT81h/qPgm T2AB0n5jBX6DQm4Ji0DI78f0/MRN0aAbjeLYg7EiWO86oDL4JmXSqgzGwkWXgxhXTqngX8Gnzoc dw/DwpD vMJ3XKAQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email 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]); Thu, 28 Sep 2023 20:24:54 -0700 (PDT) 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 - refactor load_elf_interp() to use elf_load() - refactor load_elf_library() to use elf_load() - report padzero() errors when PROT_WRITE is present - drop vm_brk() Thanks! -Kees v4: - refactor load_elf_library() too - don't refactor padzero(), just test in the only remaining caller - drop now-unused vm_brk() v3: https://lore.kernel.org/all/20230927033634.make.602-kees@kernel.org v2: https://lore.kernel.org/lkml/87sf71f123.fsf@email.froward.int.ebiederm.org v1: https://lore.kernel.org/lkml/87jzsemmsd.fsf_-_@email.froward.int.ebiederm.org Eric W. Biederman (1): binfmt_elf: Support segments with 0 filesz and misaligned starts Kees Cook (5): binfmt_elf: elf_bss no longer used by load_elf_binary() binfmt_elf: Use elf_load() for interpreter binfmt_elf: Use elf_load() for library binfmt_elf: Only report padzero() errors when PROT_WRITE mm: Remove unused vm_brk() fs/binfmt_elf.c | 214 ++++++++++++++++----------------------------- include/linux/mm.h | 3 +- mm/mmap.c | 6 -- mm/nommu.c | 5 -- 4 files changed, 76 insertions(+), 152 deletions(-) -- 2.34.1