Message ID | 20230929032435.2391507-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 7E48AE743C0 for <linux-mm@archiver.kernel.org>; Fri, 29 Sep 2023 03:24:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BE10B8D00E4; Thu, 28 Sep 2023 23:24:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B68B98D0002; Thu, 28 Sep 2023 23:24:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 9227A8D00E4; Thu, 28 Sep 2023 23:24:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 79C0A8D0002 for <linux-mm@kvack.org>; Thu, 28 Sep 2023 23:24:44 -0400 (EDT) Received: from smtpin21.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 3874C1210B2 for <linux-mm@kvack.org>; Fri, 29 Sep 2023 03:24:44 +0000 (UTC) X-FDA: 81288192888.21.B43357A Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by imf10.hostedemail.com (Postfix) with ESMTP id 4D729C0002 for <linux-mm@kvack.org>; Fri, 29 Sep 2023 03:24:42 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JDBQ5xum; spf=pass (imf10.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.170 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1695957882; 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=zy6odpD2rRS97YNbyqpdnjO7kWxRD9X04VsSkBGt0MRq/1M56wYE4PnI/h4wlTkD0vodbv dS0OS5fF/yboT7ZGzvvt0xcD3A4kJS0Lrs2EwFZBUzs3ofGso6GibP6b1DGGqcmOEtVsQb QHlXntAP4DUVV8SWLei+dzYpP8mlahE= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1695957882; a=rsa-sha256; cv=none; b=IIVPJow8VrL4SrRVnVW/ibfEK71o1Wjcc88oXY0LSgdiE/CndOyzyVBHcvJ7YhqVpj+TN+ aO/Plwh0LJDdTZ3xvwS41tTBBPLQ2q1brQLso4nNzhNXhsavHrnwAqnO4adQaXitTa3fCH Zlr8lwaCYlfJwaCxpktINCZFAK6WBqs= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=JDBQ5xum; spf=pass (imf10.hostedemail.com: domain of keescook@chromium.org designates 209.85.210.170 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-690ba63891dso10738747b3a.2 for <linux-mm@kvack.org>; Thu, 28 Sep 2023 20:24:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1695957881; x=1696562681; 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=JDBQ5xumsYZxnqJbzOq2DoVWESqRfCGjfZhN9V1X1xrPc4xS0oosVAE5FYzrtYAvDk qF2Ik0c/Vrx3pTMjNujFAcjJE3j51UmqF+l7F7OyUZlAHBh5x2yGJEHVYr4BmkX4Gs0k sPKKBB4TjjIr8J+toe2K67fscDKH+kPHs91Ew= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1695957881; x=1696562681; 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=Nr8yaMlHvGkhfM1Q8tgeVhRfuK0lDPitIV/G/JmCq0YTG5hHa3yDrl2eMPBBhOIx0w N3Dg1b4cZf+a90yqk2zLayAudsVrDsOTA3Wq/85zX2fHUNQKjSOGdaA6nGx9SjvGJ9K5 VftzJEwO3JjUvLr1dHYjeNkscHL8LGVP/c5ROOTZZ6oMfAT5TRJ6AlXRqevMtKRJIZjl xB0GXh4kSA3LEhMAp3T4QXFTCd31TcSxxO+f26HVKV1fl6qF/chTA4WVOrat+0Ua9Aq3 9dK/PvOG3IPdkTKZjVGpqhoyJLI3iVarwDQ+EmGPUNBIUa+tnNA0ZyOkeX0oTb8m2apo ckwQ== X-Gm-Message-State: AOJu0YwOniPcB54liH/3ei7aEkjDljKcuInugguLcDpNbeOi3fj5jdep z4YrZAbIUOE4YRWnSIHgHd9Yng== X-Google-Smtp-Source: AGHT+IEefjdEHzDxwiSxbmO/u6TF6zB5AljlbT04olaKMdKQR8C/b8AJwKo7ESYTNvbBR3eWZ847tQ== X-Received: by 2002:a05:6a00:190e:b0:690:ce30:47ba with SMTP id y14-20020a056a00190e00b00690ce3047bamr2938508pfi.10.1695957881184; Thu, 28 Sep 2023 20:24:41 -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 s26-20020aa78d5a000000b00672ea40b8a9sm14427552pfe.170.2023.09.28.20.24.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Sep 2023 20:24:39 -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>, Andrew Morton <akpm@linux-foundation.org>, linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org Subject: [PATCH v4 2/6] binfmt_elf: elf_bss no longer used by load_elf_binary() Date: Thu, 28 Sep 2023 20:24:30 -0700 Message-Id: <20230929032435.2391507-2-keescook@chromium.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230929031716.it.155-kees@kernel.org> References: <20230929031716.it.155-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/cbcAmAcsmYgBlFkNx2BuLhX7iIAkgIu+LW3P3r4pxnZlwRaDRf vA/0AICBj2JAjMEAAEKAB0WIQSlw/aPIp3WD3I+bhOJcvTf3G3AJgUCZRZDcQAKCRCJcvTf3G3A JpKyD/9/zd7E+5U1dJPLc6FAk+4qelFfCB75a77Kwxx0x/dnFrrOEedqqpaOK3ve3TybifJrVjE h8wTDDoxua66DT705EB1I4t9hKVj7ivb1dRVQdU3WehX4HAJzhPWJ7EtDjtX4AeM5D+Hf7hDpz4 hfwpwEYxXXAs73zeYWM19Na85lFwu6nSgf/ttA5F2ewH+beQAvHkMQN6gO9tp95OrFyS1MZdXBI NrkU9qg/ruk3uLO2OsVV6oDaLOu79M+4Kf6narATryoLsN4PLTkC8vQrd2qtvfiFgrJMPpbfCn8 mEteP/5U+mKLFaCYdxhauFlCzaPVAwvY9GsSaOxsm+ilLLoz76BgaZJ3mTlmC1hryS1DfX5TNYm BmEtiulolRPfz4jsO8ynBLlG9W3OMzNzN8tAFwtRv5C9pp0Y+Fp2Q4+kBwt72QGCQLH4GAe0o9t m4EhUZsGXS3t3VJlwU/3NoxBNO9bz5DuQRp5K6qTCwsnbFMQXMIL3xR1Vd0jwfPPrscAtd+3IlT pbesK8GLRSzYSy4YOE92dGY+Av5QlXCA+DMcppAI/si2TTqnM19+SkKDASB7HwxP2YQiCADAV3U 67MufnT9YBLfq2RWMu1o2nR3+x4f5uWbDtEvSPRE7Ki8QD8I5Ldh64XqqxhTjKdmqEPIl7TvgC2 QoH6u6C/JkEFAwQ== X-Developer-Key: i=keescook@chromium.org; a=openpgp; fpr=A5C3F68F229DD60F723E6E138972F4DFDC6DC026 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4D729C0002 X-Rspam-User: X-Stat-Signature: uib3c3dfc4hbi1s97badqco7n8me3wjt X-Rspamd-Server: rspam03 X-HE-Tag: 1695957882-718508 X-HE-Meta: U2FsdGVkX19HCvteWk5WOV0njJpNWoxEDWrz/Q37o8V1BU/BHMqo7S1r56o1JfZ8moNdauTjeZnZD2UBUoES6xxTwFWymBHWEyHz6jp6goO7rSqAkhgUdPkbF7XccbEJvmKDF6vIMeQoXXat8RzRVHBpZ6DMV/GIvMEj8VfMVd0wrUrBieqcbSkPnj/bCcMKkLIOcMG7jmBwieRSEXXYER2q5X9ogEFsST8+NYaoT/QrrE26AT5bQqBNXuqJ9u210s/mLboueR7DJXIkXPOjLNrfIcM5jcWJzdpycp5Ns7hlNaXPyu0gqlYpeL2bTI6edyLihlCzBiGUHiuHV/Bl9cwcoisbkIHfLgz+/5CzbCuGmUlIjhXR0ZQzVF5/OCb3419ZKraKh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zJdlp2FuLRJsAWrhxVmWaALHr3qunBRzMtbmxksMW/jjwLAV3sqsNbqowyd6x9ARJ66h58sntlseaEMtdK/OkrKwrGsipQAaVdC1r5vMi4gudzrenfy3F2fs6i3lxBVi6U3GensbDZ8qWK2KRu7/yMuzx+cJjyn0R5aTyitL7dNsiiX9Zib+TabYyHDnuoICWexVGDhvZAFshzQcxptJRYiZhoru0L4xXyeybJiio99o1s0D7gm2RK90hiWbnkx2fc0YjTcv9PJo7BZMUP+0WHPEJ X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, 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(-)