From patchwork Mon Aug 17 15:14:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 266116 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CD643C433E1 for ; Mon, 17 Aug 2020 18:57:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F465204EC for ; Mon, 17 Aug 2020 18:57:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597690631; bh=jJAfb9izliHNMEvk8Evv7SuRFbc/Cm7+xtlxZxHaqy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=nO/BjLfcztcLihL+zdndsI8tpvxjY4C+RBW84opm31RuWYyiqfMS4ncy5UdbgMPjs WKQxI7jk1QP2tyhsTXuVLNjRygLgt0k0c3AAoANXGTqTSCelPUWCbeEc6NixRo5c9h QwA5GpadG5aaBWSuQZwgAfncsffBN/rkfgZneG6o= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387746AbgHQS5G (ORCPT ); Mon, 17 Aug 2020 14:57:06 -0400 Received: from mail.kernel.org ([198.145.29.99]:34602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730873AbgHQPuR (ORCPT ); Mon, 17 Aug 2020 11:50:17 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C00DE2067C; Mon, 17 Aug 2020 15:50:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597679416; bh=jJAfb9izliHNMEvk8Evv7SuRFbc/Cm7+xtlxZxHaqy4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HYzDXaQ7j6gOydMQZMcebjqOCNeHP1PhvbYJ80kMQh45kCsTdzaYSEgm7jw7QQhOa Lsh7hRwbhzb+gGytKRtJFrfhh7iAPxJ7G05FpNNIlGPW8aL86V3G0o8TkoZDQ9mvm1 m6TF/o6VXiD+fjUHdKyZU0P17HXarHXHASzh1qtE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Milton Miller , Anton Blanchard , Michael Ellerman , Sasha Levin Subject: [PATCH 5.7 204/393] powerpc/vdso: Fix vdso cpu truncation Date: Mon, 17 Aug 2020 17:14:14 +0200 Message-Id: <20200817143829.518416563@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Milton Miller [ Upstream commit a9f675f950a07d5c1dbcbb97aabac56f5ed085e3 ] The code in vdso_cpu_init that exposes the cpu and numa node to userspace via SPRG_VDSO incorrctly masks the cpu to 12 bits. This means that any kernel running on a box with more than 4096 threads (NR_CPUS advertises a limit of of 8192 cpus) would expose userspace to two cpu contexts running at the same time with the same cpu number. Note: I'm not aware of any distro shipping a kernel with support for more than 4096 threads today, nor of any system image that currently exceeds 4096 threads. Found via code browsing. Fixes: 18ad51dd342a7eb09dbcd059d0b451b616d4dafc ("powerpc: Add VDSO version of getcpu") Signed-off-by: Milton Miller Signed-off-by: Anton Blanchard Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/20200715233704.1352257-1-anton@ozlabs.org Signed-off-by: Sasha Levin --- arch/powerpc/kernel/vdso.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index f38f26e844b64..1c07df1ad560e 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c @@ -678,7 +678,7 @@ int vdso_getcpu_init(void) node = cpu_to_node(cpu); WARN_ON_ONCE(node > 0xffff); - val = (cpu & 0xfff) | ((node & 0xffff) << 16); + val = (cpu & 0xffff) | ((node & 0xffff) << 16); mtspr(SPRN_SPRG_VDSO_WRITE, val); get_paca()->sprg_vdso = val;