Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2657637pxa; Mon, 17 Aug 2020 15:43:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzap8RcS9r5Uo50OlJ34uHXK97AyaGRZsW9pEDgTeUr7KR79cPyVPTLQSEFeJUKGcB2S0Zi X-Received: by 2002:a17:906:a206:: with SMTP id r6mr17051172ejy.70.1597704230716; Mon, 17 Aug 2020 15:43:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704230; cv=none; d=google.com; s=arc-20160816; b=oizP++dy+mTjcCgoB7P98VQrnV5GTSdmQC5qFJ5v9tjiZ5PPDCPtaITisQtyXU5+ig GnwGZs5KOs+A5nBIWrByGKDnB+8W+QS+dyyjhzgRQlRn+Te+Ek4KEaQl+hC+XnTYwb+v XXsoLzH4sa4zIGSXNlA1eXm1oxCCiGAfhXGiCl/56q2CvGLcL+5Lb6icq90YDVf7RGzv 5BIlywISlTSX3eScSLM8ax6Kx0DjdQqTN8wiOkiOUh7s+nFEDk8kjky8+CHH5IaIJEPZ RDw0q3ecdf84XhAaBM47WZxhlDXcVRr2lY0q1EiVqMQbq6XckHLRdB6MyyrP3NKmR7QR 7KeA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=foIUzEqEp2MCjDxOVEodqpO9zgBsMR+XLnf6zVcPhsc=; b=wrXBMlFFC8k8aqQoUZ7/o+aFjrHkkns2o/rfyUxkP8nOVHSt+nu8Q6v4SWrRlHxfkW OLpJDrr7sYjgJgKtJvj0SFO6aUQt5NeySxbbHyQroZq1pczL00lzto1sxMzeQf7eU67X 3ZCRti2ao95xvN7CQRwrIeORE8J4tIqg4mA1qZIHb4aIELMVXt/cItIoZ1ZTXdDmCAAa 9oYzrP7ZemCNg4qpq+yL3sglMhumQaGWZWsmyxT0Gv2cRiFaQqXSvDZIZykREoJIglyB xI1lnitsZ8lb6Yjnt2UYyPMD1pVO9rEzrr690807d4kWim5gBWMxKUEjfXe7kYOdVQDW 8vGQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HYzDXaQ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z12si11585588edk.22.2020.08.17.15.43.27; Mon, 17 Aug 2020 15:43:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=HYzDXaQ7; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2391608AbgHQS5K (ORCPT + 99 others); Mon, 17 Aug 2020 14:57:10 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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; -- 2.25.1