Message ID | 20230927034223.986157-2-keescook@chromium.org (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> 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 EBE70E7F15C for <linux-mm@archiver.kernel.org>; Wed, 27 Sep 2023 03:42:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 8424F8D0072; Tue, 26 Sep 2023 23:42:30 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 7F0518D0002; Tue, 26 Sep 2023 23:42:30 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5A8BF8D0072; Tue, 26 Sep 2023 23:42:30 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 4CF528D0002 for <linux-mm@kvack.org>; Tue, 26 Sep 2023 23:42:30 -0400 (EDT) Received: from smtpin13.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 1968D120E5B for <linux-mm@kvack.org>; Wed, 27 Sep 2023 03:42:30 +0000 (UTC) X-FDA: 81280980060.13.B7670E8 Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) by imf21.hostedemail.com (Postfix) with ESMTP id 39C0E1C000F for <linux-mm@kvack.org>; Wed, 27 Sep 2023 03:42:28 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=P2UnknQm; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf21.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.178 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695786148; 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-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=oGhwDBPbCWZ00dYqQrvOzcYwuI2lZJAyT/mcJzKB6R4=; b=XECPTWoSSn8Cnai/F9OPTsh0vB0U+9hIZpyM1oa+hDSka2B6Zj8Fq8FcnmV/e2EzGi90VK NlIaf5FZ2aWwzhM6zOQ54rJ694TJhPBNcGx2/YrZmrlcSHlnRVsedWvGdG/tp4VAJzRBjm e+LgevMLYb3bMsgjqy86r6sm8+qvnb4= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=P2UnknQm; dmarc=pass (policy=none) header.from=chromium.org; spf=pass (imf21.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.178 as permitted sender) smtp.mailfrom=keescook@chromium.org ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695786148; a=rsa-sha256; cv=none; b=QiQj4k0Z2JwDdUh8FO9TwQtiYv1ynLSRsywks/tLISnRHl6JdDnQhnB8pt9gg443lGg78u 8FxdWtVIdYhaszCKj9/OAiIPm0coKdcZLi/AZMQiWGT314Yo+q6AiNu1UklEdmW+htWdYq TtoAiIMMFMeXaUzhIVEZC5Y36CyJGD0= Received: by mail-pl1-f178.google.com with SMTP id d9443c01a7336-1c1e3a4a06fso73190355ad.3 for <linux-mm@kvack.org>; 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=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=oGhwDBPbCWZ00dYqQrvOzcYwuI2lZJAyT/mcJzKB6R4=; b=P2UnknQmbDlDZ11WWTe1HX2egWJ/bJr/0NfOE5d+X+yEwep1sgF/HRuzkjF0dhu5OW OO31celQMacX8a/V+nZKoGvDvsT0w2QdWijSNooLGmSBdsV2HUS56Jr2y7VXP6aZ0mAk ZvMyOAihuD882lYOFgffm2FTuNena9AqItBL4= 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:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=oGhwDBPbCWZ00dYqQrvOzcYwuI2lZJAyT/mcJzKB6R4=; b=EH/bE1/cRWjtb5zm9z/pmuyIFW1JdTpdyw+0zd/7aaFSumg7EFt0IGwfpRf6+zahWx HTDDj+Ck0k1/ZQjcRwcjJU/1w6w2N47/E0QWLFAG5EAUwVzzRgfM+YFtFyGbdyZUpnxi s934ZjMavsbIwSZ5yXSaLzu56ixZlotm0pjl4S2XJlaIWz3RJR0NrWtX/8IZb0uZar5d SZWgoFdHQON0jg8MKAq9cwO/vPp4nsfUECPf7dSQX5gMv/7LkQuP4+ZH3+GlVgMGlxpS 8FaiHPsRxzm9BADyCkh6MHQYHjZN1aNzsOEfD9eCuk7BpD/ZRXhKxVe2d98vdXUfrS2u iEPg== X-Gm-Message-State: AOJu0Yw9+N1Pk5xiLu364uBNBQ3k5XWf6o6qMTM8C9L5alkzPg+060PZ 5I/QSyghsOwxyECH2mjCX7NFjA== X-Google-Smtp-Source: AGHT+IEMRh07dxmRBvxAFfE5SwpELfOldF0XUoKYTyABrKV6bOgIMJW1wNCR/iQbnr++EfKTyUevcg== X-Received: by 2002:a17:902:e74f:b0:1c6:112f:5d02 with SMTP id p15-20020a170902e74f00b001c6112f5d02mr741873plf.55.1695786147186; Tue, 26 Sep 2023 20:42:27 -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 v7-20020a170902b7c700b001c61073b064sm5974160plz.69.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 <keescook@chromium.org> To: Eric Biederman <ebiederm@xmission.com> Cc: Kees Cook <keescook@chromium.org>, Alexander Viro <viro@zeniv.linux.org.uk>, Christian Brauner <brauner@kernel.org>, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, Sebastian Ott <sebott@redhat.com>, =?utf-8?q?Thomas_Wei?= =?utf-8?q?=C3=9Fschuh?= <linux@weissschuh.net>, Pedro Falcato <pedro.falcato@gmail.com>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v3 2/4] binfmt_elf: elf_bss no longer used by load_elf_binary() Date: Tue, 26 Sep 2023 20:42:19 -0700 Message-Id: <20230927034223.986157-2-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230927033634.make.602-kees@kernel.org> References: <20230927033634.make.602-kees@kernel.org> MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1738; i=keescook@chromium.org; h=from:subject; bh=G8gKivjP+bPsGdacm75CduzZVarN6sAt0dfrtCVUjtY=; b=owEBbQKS/ZANAwAKAYly9N/cbcAmAcsmYgBlE6Sd2BuLhX7iIAkgIu+LW3P3r4pxnZlwRaDRf vA/0AICBj2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZROknQAKCRCJcvTf3G3A JoZiEACxnnqWBzMIIDewc78beSt5xMPBmGmN6i2luWvAqAMFgVuNI0nDLE57tnMWit7yDj2XgJ1 2Z/pa68XIcntr/l4Ox2lUHBpmeW82kMxXbte18Ecfkifetz5bSTNhT4eqz9iInkevtzRWO3uUpq i3Sjs/gANX1ErFrzlbJdGorFoQ2WChDbSXKcGCifcF+7ByszsUMc7ciRkTfJ+c69ymHfkIjFnB4 NABq4TtLUWJgQ4fWWHfAXP7ibJqTV+vue/6haJy4EBtrPblhUpyXmaPHPlLFqfB4NWp67PspCGn Xt+4d8whIqgJJO12woWoD2kad16SwfEWwy6rtb5glKxP4P8lwFkwUY2npYvmLb7oLp/JOBGWtT4 zN8stmcyYoHO5JH1fxDZ/M4IbnvhDjIyT/v4bcz2Sn/t26aRdaLx2dvl1fz3GLavqQm1IhRhQ+f XxYEJIe0C5lZ5EdXJrERty9WadxoFIpFZuQtqKSIfGNDtWQIQ1fwZPbObiOfsYvT6LcbQLKMUG1 /xXJ+v8+u3jW+HTFnzZ+EE7ig4RRSprVCTd5QEzX4RbC8KXboi2yMozBdmUhOTOlkUJSU/uUZ1+ VZHcMo6rE0t3wu84BkMjvDVBAPXSGtNLDJ9xoujVrtMltIzQDhdxPz2ce74LXQ2WEx1wn991e8y t1zbNpVW5qc63Kw== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 39C0E1C000F X-Stat-Signature: 17ocpq5ofcafb5gm1snz5m1p87d679bk X-HE-Tag: 1695786147-241827 X-HE-Meta: U2FsdGVkX19bnBwljbhNQdjfGc8i6uKShOsfZuBV8lotxFqNiNYU9b11MD/xcQM6Syw9Lk2R8/avbjfZXeBMOETKtIvWrQrjIzmYx4JNkMKDvFFvyybtW4M6CmaI2Trm6EKcGBC+Ixcb3EvjLlV3Wc3hXkz2EG3rR8tGbzPeLbV91rKX9CgPA7UKpJNVjXX1kzIbjrXxZ6AJuqPyaq4KeyzTNy2uMHSapdtUiS09xMcJBbaYp3dfxYna+r/rV4m30BGGqcST8pQ9DviyZzItJVxEeyrFG1ntJQIRASB2wQKA4X2SotbYKEAaocmzsIqk4kz+ov1yVv5pXGQhQSGvLFqLEsiObNRmD0ZkIjT+HX053euWR9bFASgZS5hlZ/waUULwBEOwhE6q5B4bpGeG/UkObFEIooHBYz3etUmIRrmdEL/gtkaK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DTnwSr1YcfKARoAwYdMdZOQOfrhYEbTp6S8SBKs0eu3pmZfL6GPPNonHKmPrXaKHdAbAYFE2E6IvtXFmlMOgjjaQvs5PvWBN9qfNw+ugy2cf+0RLWLGBFjJnLXKnSroHY22gAlAO8K14CXD4vXNeqmHcYyUaKZlSZtwyMxJEBkmEEki3Tjf4978v5R5IzIVK7xl7nCj2ZiVW1NFoK4JGb9KiUY2JT2wFLqO3YwlcmBNcJjruK7mMlea 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: <linux-mm.kvack.org> |
Series |
binfmt_elf: Support segments with 0 filesz and misaligned starts
|
expand
|
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 2a615f476e44..0214d5a949fc 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c @@ -854,7 +854,7 @@ static int load_elf_binary(struct linux_binprm *bprm) unsigned long error; struct elf_phdr *elf_ppnt, *elf_phdata, *interp_elf_phdata = NULL; struct elf_phdr *elf_property_phdata = NULL; - unsigned long elf_bss, elf_brk; + unsigned long elf_brk; int retval, i; unsigned long elf_entry; unsigned long e_entry; @@ -1045,7 +1045,6 @@ static int load_elf_binary(struct linux_binprm *bprm) if (retval < 0) goto out_free_dentry; - elf_bss = 0; elf_brk = 0; start_code = ~0UL; @@ -1208,8 +1207,6 @@ static int load_elf_binary(struct linux_binprm *bprm) k = elf_ppnt->p_vaddr + elf_ppnt->p_filesz; - if (k > elf_bss) - elf_bss = k; if ((elf_ppnt->p_flags & PF_X) && end_code < k) end_code = k; if (end_data < k) @@ -1221,7 +1218,6 @@ static int load_elf_binary(struct linux_binprm *bprm) e_entry = elf_ex->e_entry + load_bias; phdr_addr += load_bias; - elf_bss += load_bias; elf_brk += load_bias; start_code += load_bias; end_code += load_bias;
With the BSS handled generically via the new filesz/memsz mismatch handling logic in elf_load(), elf_bss no longer needs to be tracked. Drop the variable. Cc: Eric Biederman <ebiederm@xmission.com> Cc: Alexander Viro <viro@zeniv.linux.org.uk> Cc: Christian Brauner <brauner@kernel.org> Cc: linux-fsdevel@vger.kernel.org Cc: linux-mm@kvack.org Suggested-by: Eric Biederman <ebiederm@xmission.com> Signed-off-by: Kees Cook <keescook@chromium.org> --- fs/binfmt_elf.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-)