From mboxrd@z Thu Jan 1 00:00:00 1970 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,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 579CCC4CEC9 for ; Wed, 18 Sep 2019 06:20:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2C48521D6C for ; Wed, 18 Sep 2019 06:20:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787649; bh=i2uhVoobwgcY3wczFCTJwDYUidkYyrusQvKFiPPZeso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=cboBPWWNAiTcb3B5dsI7h0Ap/msV4hUBq58KiNzl65iv78kD7HgXohfkmv0NsBlYD jiVgABGeY1TrgTd1kiuTplUyC3NA62IQpzY9axiRXlLm/fMbhZOSaGTfpWPXh/D0Pp LbEJu0YbeUgn/mT3tuyZQCmUmHZHmz5wMSO0kPUE= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728797AbfIRGUs (ORCPT ); Wed, 18 Sep 2019 02:20:48 -0400 Received: from mail.kernel.org ([198.145.29.99]:39712 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728774AbfIRGUo (ORCPT ); Wed, 18 Sep 2019 02:20:44 -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 16EB6218AF; Wed, 18 Sep 2019 06:20:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787643; bh=i2uhVoobwgcY3wczFCTJwDYUidkYyrusQvKFiPPZeso=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nP5DD9L4GI0F/pIYAYAmNMsGe0xCv1Bd7ygSgnz8w7QOEHO7w6TCchVOGzHMGaiIf r2vbaBdToSIK5NLFNOf1rMWl6NJAtJjW1LL7nhtc8OCxOhPFr+P9Ld+8W4HQbYTS9R Ce7EFaXoxnc14AbxBCYB4oipOpz5iQ/vQRttDpr8= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Paul Burton , Matt Redfearn , Ralf Baechle , James Hogan , linux-mips@linux-mips.org, Guenter Roeck Subject: [PATCH 4.14 25/45] MIPS: VDSO: Prevent use of smp_processor_id() Date: Wed, 18 Sep 2019 08:19:03 +0200 Message-Id: <20190918061225.619232350@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061222.854132812@linuxfoundation.org> References: <20190918061222.854132812@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Paul Burton commit 351fdddd366245c0fb4636f32edfb4198c8d6b8c upstream. VDSO code should not be using smp_processor_id(), since it is executed in user mode. Introduce a VDSO-specific path which will cause a compile-time or link-time error (depending upon support for __compiletime_error) if the VDSO ever incorrectly attempts to use smp_processor_id(). [Matt Redfearn : Move before change to smp_processor_id in series] Signed-off-by: Paul Burton Signed-off-by: Matt Redfearn Patchwork: https://patchwork.linux-mips.org/patch/17932/ Cc: Ralf Baechle Cc: James Hogan Cc: linux-mips@linux-mips.org Cc: Guenter Roeck Signed-off-by: Greg Kroah-Hartman --- arch/mips/include/asm/smp.h | 12 +++++++++++- arch/mips/vdso/Makefile | 3 ++- 2 files changed, 13 insertions(+), 2 deletions(-) --- a/arch/mips/include/asm/smp.h +++ b/arch/mips/include/asm/smp.h @@ -25,7 +25,17 @@ extern cpumask_t cpu_sibling_map[]; extern cpumask_t cpu_core_map[]; extern cpumask_t cpu_foreign_map[]; -#define raw_smp_processor_id() (current_thread_info()->cpu) +static inline int raw_smp_processor_id(void) +{ +#if defined(__VDSO__) + extern int vdso_smp_processor_id(void) + __compiletime_error("VDSO should not call smp_processor_id()"); + return vdso_smp_processor_id(); +#else + return current_thread_info()->cpu; +#endif +} +#define raw_smp_processor_id raw_smp_processor_id /* Map from cpu id to sequential logical cpu number. This will only not be idempotent when cpus failed to come on-line. */ --- a/arch/mips/vdso/Makefile +++ b/arch/mips/vdso/Makefile @@ -7,7 +7,8 @@ ccflags-vdso := \ $(filter -I%,$(KBUILD_CFLAGS)) \ $(filter -E%,$(KBUILD_CFLAGS)) \ $(filter -mmicromips,$(KBUILD_CFLAGS)) \ - $(filter -march=%,$(KBUILD_CFLAGS)) + $(filter -march=%,$(KBUILD_CFLAGS)) \ + -D__VDSO__ cflags-vdso := $(ccflags-vdso) \ $(filter -W%,$(filter-out -Wa$(comma)%,$(KBUILD_CFLAGS))) \ -O2 -g -fPIC -fno-strict-aliasing -fno-common -fno-builtin -G 0 \