Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp2503330rdh; Wed, 27 Sep 2023 04:55:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFPM1Rn8EFs7I0GdBId23W//RHwrN0Ngq4UHwLpeKubex4FtBLSqJ/QRyWXdl934pvhZt7r X-Received: by 2002:a17:90a:6081:b0:273:cec7:23ee with SMTP id z1-20020a17090a608100b00273cec723eemr1427624pji.37.1695815708690; Wed, 27 Sep 2023 04:55:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695815708; cv=none; d=google.com; s=arc-20160816; b=B337f0ROrpz/iRdhEqlY6jzKbBaeGUt0Qeynb+/2ByadKovAU4rTtY9ppOxqs6VXGc 3ntI9cJ6bD3tTiMgqvTgsdKHHwvUHFwUuq6vW5OWorZUv7siXMYan/V25nFizBzfLavd umjR9q/2c8UHjImx+MfyZaGjABwNvKchzf4JJSp0hobJvO7XwzIo6lTzmZ1+c5G2EJwe cY1yxCA5K1+gHru/B87SYK2r4ym6sN8N6d9POrBgi8pQXFfVbwIKXoP7+XM1DclWIy/g 694aPHOWdAjoqpHrP038LCV4l+ol34OPTI3fxoDVJe45/Uelru1wx6cMyWuRqK8xfLRL J1xQ== 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=PGJfI+lZ4iSfQ93mihAmCKetWCxWqPDzFkg6Q6FWgBc=; fh=P4Uo5mCdy/9CDzRumP301c4uGkyxyxnnPfF9guP4zY0=; b=hDwoHZSxD/2sjX9JjX1fArSkZtDS/JDHNG6oft20cyDyk3aaru5PPbe87ZEKRW1h0D YGhbZdDSO5q/gsA2CdLtxVXh5flGlvZlqihnNmLcD2C+D9pOC+4u2xLsBRbX49xPM/KM BsRaqgiSw3NThlyL/33PsKc2of+k9xDnjTejE3/tnGdu5MsQfCH6l54kTjxJ4iS2OJS1 cjCP/LupYWv2ru997WCLOxLc2u1Pyvqc4PQ3jZ3KrywoPKOpskOcpyNBia9wVudv6X5K gWX5D7S4EgcnBaleWe27YYPEwtiVgEekAIbPgDG08Q09RKVMGdH96uirT7xsnL7xnCy6 8GlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Bs7xjUEu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id fs11-20020a17090af28b00b00268178130a2si5289327pjb.60.2023.09.27.04.55.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Sep 2023 04:55:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Bs7xjUEu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 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 groat.vger.email (Postfix) with ESMTP id 848CC805DEF9; Tue, 26 Sep 2023 21:20:48 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjI0EUh (ORCPT + 99 others); Wed, 27 Sep 2023 00:20:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39962 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229611AbjI0ETa (ORCPT ); Wed, 27 Sep 2023 00:19:30 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 841A91BDA for ; Tue, 26 Sep 2023 20:42:27 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id d9443c01a7336-1c46b30a1ceso91357555ad.3 for ; Tue, 26 Sep 2023 20:42:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695786147; x=1696390947; 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=PGJfI+lZ4iSfQ93mihAmCKetWCxWqPDzFkg6Q6FWgBc=; b=Bs7xjUEuS8NkFPZHJGDJ2TEI8MNHM5Tz6S/mOzXHCqJoYeG8s73+rqFxehM6W9d0Kt wgxsaFDT4RoUKAw+CU0VmHrZgfzI1vpBz7Y07O6WES0bdXkIyYu2DrOxTBJ5JixFquGM J/7Qe5i1yvKNnVZ0c/UHwkPScoP7L+UScfV04= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695786147; x=1696390947; 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=PGJfI+lZ4iSfQ93mihAmCKetWCxWqPDzFkg6Q6FWgBc=; b=AwsgNzkci2jCzScoIX5A6WRlEli6j56FGy/HA/ge/hl0W6xvWi533sMDSLGL+yHqzK 0DWEJF/FL3dLn3oHc5D2v1o3L7MJQlGBJ8BoFSPCsiUsODq7wHhXDH5vj83jcCmZCtS/ WRJLz61b+nZ8HljgRKY/rNyoR+Xn/2IUDsvPlhH1bukJzlwLhdX02ZqwiyfH+BdwGngP pndE/8xcuL0MeHIt2c6k8dHIEi/Zw5JEeX3ZTS0J0xAbRGenTFxLtx2G1XYJwL1yZKf2 6jh2Rbxsiy270Igk7zawI+TxUFtIpkkbijRaVuEHv9lo5t3ZE+7sBQKBHsXRTmOSl5zI 9+Yw== X-Gm-Message-State: AOJu0YybTGo5VqP7NnKgAsPh7cSZl+hArZQlSjN8DGkWWTBkj97QvUDg SW0MVmgcxA9oQEEjRQKEA1h1ug== X-Received: by 2002:a17:902:c94f:b0:1bb:598a:14e5 with SMTP id i15-20020a170902c94f00b001bb598a14e5mr992121pla.43.1695786146709; Tue, 26 Sep 2023 20:42:26 -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 jj11-20020a170903048b00b001bdc6ca748esm11918838plb.185.2023.09.26.20.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Sep 2023 20:42:24 -0700 (PDT) From: Kees Cook To: Eric Biederman Cc: Kees Cook , Sebastian Ott , =?UTF-8?q?Thomas=20Wei=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 Subject: [PATCH v3 0/4] binfmt_elf: Support segments with 0 filesz and misaligned starts Date: Tue, 26 Sep 2023 20:42:17 -0700 Message-Id: <20230927033634.make.602-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=868; i=keescook@chromium.org; h=from:subject:message-id; bh=lOC6dIm6BOZ5YdJlYfTe2LeekCnJ++QGcs0vKnnP4ps=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlE6ScQrYRvW7/cLoTymNp+QzCK4E5+g2pQV1h7 2TULnPSJZmJAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZROknAAKCRCJcvTf3G3A JoDCEACiqN/qgoJ0Ne6hePry6JkdekxC2ghpkyg+pmI99pumwTcgld+j67+ZMdlJ1uoiL+ZLTZW kpZQc19iF4kz/hS2BzF5fc3o9zbbnksf5M41zq8EHUWlTko2ebswjaLUUI/dADhqmcfsFOxdlYK a9Wn4Yo+Jsryxk8lZr8iC1UsqxoN2OD1JZ/IScy8PRDGyoj5SW/8KXm4YVbT+dUCx5rv/HJ+qzk n6mLTE09gnExRim0Wkug8xsfhXdnRLf3JEwhHm1uYDvLhIVG4jp9a/C/HyB52YRBBD0pM7HD93r eDzoVjwiGJLGETpwCEoKdJaiNrkBYYwZ4uS/OTgkBkxm/y/MykXwxzIH2FQRU6ex9YHjbc68Re4 abj6Ut8m5K8OBP497GvZJeM6fR4y1bL3UtMBqHGNipTauOPZtp14wuE26++n4jCcIdnbdo9FmYz GXg3/jNe4JkK4sHhwUXSCm07Gn3QavzFisWXca4G/AqBjF5k4hwBnYd8jg6ObkJgzPZgIHuZ+CN AiMdCAMOGj2d0N/Jlti27JIkfB5ifjxiV+OXygf99lkJgwVe18U6L6cPvdtxbYOW3xWLKUwxgqL mpHIt8n/rKLRvretb5VXJySNBh2q2kAngczfkZzyHdbxaj6wAKLbZiiVdt+WDa7CcxMhvKi9oot B6BlPROL CGrPl5w== 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 groat.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 (groat.vger.email [0.0.0.0]); Tue, 26 Sep 2023 21:20:48 -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 - 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... -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(-) -- 2.34.1