From patchwork Mon Aug 26 03:27:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Max Filippov X-Patchwork-Id: 13777038 Return-Path: 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 1C00FC5320E for ; Mon, 26 Aug 2024 03:28:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 669848D0040; Sun, 25 Aug 2024 23:28:12 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 61A688D0029; Sun, 25 Aug 2024 23:28:12 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4E13F8D0040; Sun, 25 Aug 2024 23:28:12 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 2FD7B8D0029 for ; Sun, 25 Aug 2024 23:28:12 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9A240140ABB for ; Mon, 26 Aug 2024 03:28:11 +0000 (UTC) X-FDA: 82492963182.18.80AB998 Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by imf18.hostedemail.com (Postfix) with ESMTP id DF48D1C0008 for ; Mon, 26 Aug 2024 03:28:09 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P8UsLYLJ; spf=pass (imf18.hostedemail.com: domain of jcmvbkbc@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=jcmvbkbc@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1724642806; 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:references:dkim-signature; bh=ANf/hClzWrqHd4P6Q3XPUC1mPVi6EquIud7d7KHM0gY=; b=Ak4aTFyn9gv06Ss+mB6CqbLjPIzLaZrC97bkDg8EsoYymvEL//G2tQsDjh9oHRmcD+emfz 17vnXipuqnNzM2X5UJq+3BJezbbwiC1rbtvriwU+kgH/6vTPOXS0wWNy+f/uv+v/fOY0IK xNY4QCgnpXKNJRN7R5ClAVXEZV0csOQ= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1724642806; a=rsa-sha256; cv=none; b=CYRbnjQljzpzR6qrGTkCNp48ew+3AL4YKr6beY81FDNIKiNyiDrxTHVJWdJKYzTAggmHq5 UWEB/Bpm/DCm34t/SRKSsqiPk7c6nWn6sLaDaVuvpC73YYJw2kWhNDjRDp6Pz6wYiVLaZx mkvfYv9nN0beLh7Go4Y3Df+5RHmCi9I= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=P8UsLYLJ; spf=pass (imf18.hostedemail.com: domain of jcmvbkbc@gmail.com designates 209.85.210.173 as permitted sender) smtp.mailfrom=jcmvbkbc@gmail.com; dmarc=pass (policy=none) header.from=gmail.com Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-714302e7285so3233469b3a.2 for ; Sun, 25 Aug 2024 20:28:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1724642888; x=1725247688; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=ANf/hClzWrqHd4P6Q3XPUC1mPVi6EquIud7d7KHM0gY=; b=P8UsLYLJAYpiTNzeAAuJAuka1oQqTG+UoQ5BqJFnlsCmTQeyKRXhcWqZhNwgkS0wTU nD6wxiYmM8CImhWaNrJqMcpygU6lBDNlkRsbjc8GI5cPp17afksumAslKmLaA8qOK0he GYFybQPtlDWq4NH0U2uz6dZ1a5hZ4cmZ1fGYHoyVWvC/PoWQY73UPE/oUQ72h7F1B/VM guwvgHfMb8sH+9TzRWw8eHnf7flaHKoHttllynBoqMXXtsSO0oacK/G08m37iUIIabZF cYe/auSNGJk2uQ+n6+iOS6bhLRE2b/Tu42nT8V0HGWWZIUW+5YD6F7wlAn6mdkoDw1Gm eS8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1724642888; x=1725247688; 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=ANf/hClzWrqHd4P6Q3XPUC1mPVi6EquIud7d7KHM0gY=; b=MVdF7hTnR1VfjGNvURO2YoAg0Rsj0sXfHpPdemuYFxpoCYKipRDfxhYFU127KMqy9g qmyNXiHEiH4Zz2wGSG3ZrjVjAyRemPAdx1NP9JIs0ewLgo8yGXSzkh3+jp4bGKvRBH03 xUet0+YGoSKGuPWWgbIxETXKm8ykzqar4iExCu5hXAFYEnVmLFq/4A79k3rBU7ow6nxy ljokx0UwY5l3ZDIVoAi9u7w7MVT/fvQGPruG45RG8qOBoUPqu3Nd1/B93LeQmBk5YvqE RPRuJ2LzNWOfZSimknnY+vq7b6nbSrb7lEZpeSh10n7Z0hvxEz5H8BoKJ3JU6a/vJW0r cQcA== X-Gm-Message-State: AOJu0Ywk7k5QM05tCYfChsbTvWPrg5aPldVbUF3bjmg29P1lvk9tAY3n D3hJXfb3TQ9k9AQ9U/0TOQi8Uzy2IHasl75cI7z9MWZuIVeNO+Q6 X-Google-Smtp-Source: AGHT+IFxBdq2RNdI+6yOhYiEnov1LOzlBT22h9WwHslCdt/ew1B/PxB6w9GmQTx2/TU/Ruqd7jCoVw== X-Received: by 2002:a05:6a20:d492:b0:1c4:a7a0:a7d4 with SMTP id adf61e73a8af0-1cc89d15ec2mr11857864637.7.1724642888345; Sun, 25 Aug 2024 20:28:08 -0700 (PDT) Received: from octofox.hsd1.ca.comcast.net ([2601:646:a200:bbd0:3283:bf27:b1b2:b224]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2d5eba2353csm10875610a91.26.2024.08.25.20.28.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Aug 2024 20:28:07 -0700 (PDT) From: Max Filippov To: Greg Ungerer , linux-kernel@vger.kernel.org Cc: linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, Alexander Viro , Christian Brauner , Jan Kara , Eric Biederman , Kees Cook , Max Filippov , stable@vger.kernel.org Subject: [PATCH] binfmt_elf_fdpic: fix AUXV size calculation when ELF_HWCAP2 is defined Date: Sun, 25 Aug 2024 20:27:45 -0700 Message-Id: <20240826032745.3423812-1-jcmvbkbc@gmail.com> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 X-Rspamd-Queue-Id: DF48D1C0008 X-Stat-Signature: r3f3yoz5g9u9t5oamsq4dg9x9x4eghac X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1724642889-967321 X-HE-Meta: U2FsdGVkX18ljfBHnQVEvQSLeVSZN0us33sevWbvwwFM+vkbm0Y8k4P+9UtSuCiFlpucyxDXNquSYEtsmvTGh8HdVG+tDQamhcIXZZMf3Baes5uSnClZ4RYRyA6PT2QIR8iZnL4n/EEvAcMPThG0khmfOV/DzVc7cnLF90TATVsR1zLE/aKII6m7YARvYKQR7xmR4I/MmpJaY+ogVqfTw6uhDUBNESPWCO6nhWw4uyS1ynU6fCu3wWrE9AnKvkdAKXjAdYJr1yJJwcEMxTNYV4+OCS3UflEFisr5uZAFT5Ej8r0vVFWBOlbfL0Q8b2BAIA9aWff1JUrCRQGKsaBWXnUhb9nOxJ7FZ68Ysm/vtG2U9moXTw6LQxhfVRROTdE9RG3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TJmonpVchnP84= 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: List-Subscribe: List-Unsubscribe: create_elf_fdpic_tables() does not correctly account the space for the AUX vector when an architecture has ELF_HWCAP2 defined. Prior to the commit 10e29251be0e ("binfmt_elf_fdpic: fix /proc//auxv") it resulted in the last entry of the AUX vector being set to zero, but with that change it results in a kernel BUG. Fix that by adding one to the number of AUXV entries (nitems) when ELF_HWCAP2 is defined. Fixes: 10e29251be0e ("binfmt_elf_fdpic: fix /proc//auxv") Cc: stable@vger.kernel.org Reported-by: Greg Ungerer Closes: https://lore.kernel.org/lkml/5b51975f-6d0b-413c-8b38-39a6a45e8821@westnet.com.au/ Signed-off-by: Max Filippov Tested-by: Greg Ungerer --- fs/binfmt_elf_fdpic.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index c11289e1301b..a5cb45cb30c8 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c @@ -594,6 +594,9 @@ static int create_elf_fdpic_tables(struct linux_binprm *bprm, if (bprm->have_execfd) nitems++; +#ifdef ELF_HWCAP2 + nitems++; +#endif csp = sp; sp -= nitems * 2 * sizeof(unsigned long);