Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2388651ybg; Thu, 30 Jul 2020 19:58:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyua/EuyHSgzHfxRGk/u2Ce8XSHC2SxqHGguzVwQqlxL38npDlrjq3XfHh9CrGu8RQhpCd0 X-Received: by 2002:a17:906:4157:: with SMTP id l23mr1954387ejk.491.1596164292225; Thu, 30 Jul 2020 19:58:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596164292; cv=none; d=google.com; s=arc-20160816; b=tkCqUP+bi3KDa/Lpcv/C4/m0b7HasaZIl2KX5Wxr02Trn9cDF4JOsdXmy4fe9zuXV1 5nnImlW7089HjcYGb8azYketydUWNsI9g3TjfZw41EA6kTqfq83k3ZH0JVlLhkbD9lr8 nG7wnSjh6wqdCmxNTWWggNbR272jnZB0B1NgsQoa/YZ6cuJr7BGrw3el9xve3Mdt5vXF 3sobMGpZwzRhN+sfaHd9I3iJYS0+brpvO+m9+Zxrv/bmG2DImfHsufkCd8JwNNWX/3wg 3DE0IPMlLS9lV1nwvrDWzlc9hWsQ/6BgGUDYeoj5KcB0gkQXPDmcHt3ZGoM/epesklQu 2lqw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :ironport-sdr:ironport-sdr; bh=BagiGGMQH8weJBqHrA5D2TwMNRK1tKVQV3qeK+EJHmo=; b=cuzcr4E84+PqBTduZ0x7mgkUFb7ZJDsSdVddKyoQnx64ARBdz1l3bqTX950rsipI6C gD3/uLzf//x9E3j55FTuv30mLUbyJPyu3CN+n/tDserzcvMEUpqWuMn2DFkFyyB8bHR3 DdIyniVISUB19hPRn3deRtIX1/zKjKhnZ5vjfcIvuPGm9JsfOSr+WbFPzCTJxfjzAEfU zvFM0ACQhnrfSKDx+q1WV3FXM7RWM+6XTn0Aw0E4fxeiuYBcF7q+cZQbATGWveEBkIS3 Y9qC0UTk1r0lVY2p1+49p3GlPDRWc21SocK/Z36B2eDFgG5lXm0BDFAsO/keFUftBkrL Mm5g== ARC-Authentication-Results: i=1; mx.google.com; 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si4430110edw.538.2020.07.30.19.57.46; Thu, 30 Jul 2020 19:58:12 -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; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731199AbgGaC5j (ORCPT + 99 others); Thu, 30 Jul 2020 22:57:39 -0400 Received: from mga17.intel.com ([192.55.52.151]:49992 "EHLO mga17.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731162AbgGaC5j (ORCPT ); Thu, 30 Jul 2020 22:57:39 -0400 IronPort-SDR: ko4lvX06MtdGadiPlhxL+4UDWQSq0mlRzM2H9cRVJZE4+cnkPb78OXpngwEaUVYP1XXjGrDRXd XGQxctZ5mGLw== X-IronPort-AV: E=McAfee;i="6000,8403,9698"; a="131794857" X-IronPort-AV: E=Sophos;i="5.75,416,1589266800"; d="scan'208";a="131794857" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga107.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jul 2020 19:57:38 -0700 IronPort-SDR: R5rSCbzYycekZZ4HukUJXuEdWw3IRG+3nauNBPwTSbGgK3VNWZ/mHX0Wcv311vI/HwJIwgZuV8 uWogfHfxWkIA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.75,416,1589266800"; d="scan'208";a="323103310" Received: from kbl-ppc.sh.intel.com ([10.239.159.118]) by fmsmga002.fm.intel.com with ESMTP; 30 Jul 2020 19:57:34 -0700 From: Jin Yao To: peterz@infradead.org, mingo@redhat.com, oleg@redhat.com, acme@kernel.org, jolsa@kernel.org Cc: Linux-kernel@vger.kernel.org, ak@linux.intel.com, kan.liang@intel.com, yao.jin@intel.com, alexander.shishkin@linux.intel.com, mark.rutland@arm.com, Jin Yao Subject: [PATCH v1 1/2] Missing instruction_pointer_set() instances Date: Fri, 31 Jul 2020 10:56:16 +0800 Message-Id: <20200731025617.16243-1-yao.jin@linux.intel.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org There is a potential security issue that perf kernel samples may be leaked even though kernel sampling is disabled. For fixing the potential leakage, the idea is to use instruction_pointer_set to set invalid ip address in leaked perf samples in some cases. But instruction_pointer_set is missing on some architectures. Define instruction_pointer_set for these architectures. Signed-off-by: Jin Yao --- arch/alpha/include/asm/ptrace.h | 6 ++++++ arch/arc/include/asm/ptrace.h | 6 ++++++ arch/nds32/include/asm/ptrace.h | 7 +++++++ arch/xtensa/include/asm/ptrace.h | 6 ++++++ 4 files changed, 25 insertions(+) diff --git a/arch/alpha/include/asm/ptrace.h b/arch/alpha/include/asm/ptrace.h index df5f317ab3fc..c464d525c110 100644 --- a/arch/alpha/include/asm/ptrace.h +++ b/arch/alpha/include/asm/ptrace.h @@ -25,4 +25,10 @@ static inline unsigned long regs_return_value(struct pt_regs *regs) return regs->r0; } +static inline void instruction_pointer_set(struct pt_regs *regs, + unsigned long val) +{ + regs->pc = val; +} + #endif diff --git a/arch/arc/include/asm/ptrace.h b/arch/arc/include/asm/ptrace.h index 2fdb87addadc..8869a6c0fe8c 100644 --- a/arch/arc/include/asm/ptrace.h +++ b/arch/arc/include/asm/ptrace.h @@ -154,6 +154,12 @@ static inline long regs_return_value(struct pt_regs *regs) return (long)regs->r0; } +static inline void instruction_pointer_set(struct pt_regs *regs, + unsigned long val) +{ + regs->ret = val; +} + #endif /* !__ASSEMBLY__ */ #endif /* __ASM_PTRACE_H */ diff --git a/arch/nds32/include/asm/ptrace.h b/arch/nds32/include/asm/ptrace.h index 919ee223620c..19a916bef7f5 100644 --- a/arch/nds32/include/asm/ptrace.h +++ b/arch/nds32/include/asm/ptrace.h @@ -62,6 +62,13 @@ static inline unsigned long regs_return_value(struct pt_regs *regs) { return regs->uregs[0]; } + +static inline void instruction_pointer_set(struct pt_regs *regs, + unsigned long val) +{ + regs->ipc = val; +} + extern void show_regs(struct pt_regs *); /* Avoid circular header include via sched.h */ struct task_struct; diff --git a/arch/xtensa/include/asm/ptrace.h b/arch/xtensa/include/asm/ptrace.h index b109416dc07e..82ab1ba99259 100644 --- a/arch/xtensa/include/asm/ptrace.h +++ b/arch/xtensa/include/asm/ptrace.h @@ -90,6 +90,12 @@ struct pt_regs { # define return_pointer(regs) (MAKE_PC_FROM_RA((regs)->areg[0], \ (regs)->areg[1])) +static inline void instruction_pointer_set(struct pt_regs *regs, + unsigned long val) +{ + regs->pc = val; +} + # ifndef CONFIG_SMP # define profile_pc(regs) instruction_pointer(regs) # else -- 2.17.1