Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp8561293ybl; Thu, 16 Jan 2020 19:38:15 -0800 (PST) X-Google-Smtp-Source: APXvYqx9gQCpiGNHUJmfVpEiiT027sZcSqp9PjxyQ8W5Jgn3dsYd4Ktw00x4L/OH5pjeUI5PBSMG X-Received: by 2002:aca:4d58:: with SMTP id a85mr1902825oib.35.1579232295014; Thu, 16 Jan 2020 19:38:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579232295; cv=none; d=google.com; s=arc-20160816; b=ZgQEJdppxI9BPYBupwteAPLg1MtPwsnhOCWNvMWjsFS0/5Ku0KL+FVOyQUum7dpq57 3g3axLEE1X8BYsuEi5fV9uePMsd2O13iKf6nGo4cisHSu0muRDLYgIxLViLCQzDsvJst C5KSgiobn4YA5fX9KqCs6iD25KDkne4D3bnuxTiCNQ6UoHr0lpSRTfovTkBtFsgOV7YU 81MMlOVCofpWcTnbI91hFn/NzcVSKsnkLOLlw71SmqtWt4jkYozquhnwRrj44oxIan+u tCDMNhxD1t2GGypkeEwZMt9pxS4oH1iCyYn9DrsWIxXp5kb97YwFCh38xNyIF+k5QYMR X22Q== 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=p3f5gpnE8x/d3NHciobQC8RrdBkiEFzZ4NgokQCdBmg=; b=QybLVoXkIRZzA57IOpg4te7g+q6rXOD8SO6mvt+ylLKcCaog4DpqFiSf4vwBMhopMW vxwW8+GjoKPNQ/3PELcnprlLj+Xi4eRnpfbVlyZLQBMco6MHyB5SKC5YKMYyTEoXS7e3 lV740mDp7MD6bnT21SJJo9E+ZMYRSD0ZYBnYlPgps8cSxGU5Fgo/R5sWqMdvQlzRgBVY FPrUudmPHXExwcpm2r6bJw9hPgFUktP3btW9CfN0PuRCHAbDA+8fxE7CZU80eVPTO0Y1 RLX5UE3nvQ90l9hTyoZL+BOIIBNALU03mfLlcKNVdYuRufv36/KnMBBPfUZJsFP5mESt HcyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1+nRt6OM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o20si13761703otl.60.2020.01.16.19.38.03; Thu, 16 Jan 2020 19:38:15 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1+nRt6OM; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392062AbgAPXqn (ORCPT + 99 others); Thu, 16 Jan 2020 18:46:43 -0500 Received: from mail.kernel.org ([198.145.29.99]:49124 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390857AbgAPXVl (ORCPT ); Thu, 16 Jan 2020 18:21:41 -0500 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 95F35206D9; Thu, 16 Jan 2020 23:21:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1579216901; bh=uCgsCD/PC8upsUFz8l4cub7gwgwpAiMz3Y8qPsgJln0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1+nRt6OMvuiakbes7GAgo/rVURrJaR4DKaKJbJQjXB+VVaPE0/I/9MZNkY7Fp0Mg/ 4hWyRxAVAjEZrgvt5O+INKAeoJ/MJHaATQZWrM0RbqjfgcQ/XEGnQbex6eJ3G79xnI QoDCIWdnsTkfEMAjDHxgYbRJr+ion51+256VuluY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Sami Tolvanen , Andy Lutomirski , Borislav Petkov , "H . Peter Anvin" , Kees Cook , Linus Torvalds , Peter Zijlstra , Thomas Gleixner , Ingo Molnar Subject: [PATCH 5.4 050/203] syscalls/x86: Fix function types in COND_SYSCALL Date: Fri, 17 Jan 2020 00:16:07 +0100 Message-Id: <20200116231748.356024867@linuxfoundation.org> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200116231745.218684830@linuxfoundation.org> References: <20200116231745.218684830@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: Sami Tolvanen commit 6e4847640c6aebcaa2d9b3686cecc91b41f09269 upstream. Define a weak function in COND_SYSCALL instead of a weak alias to sys_ni_syscall(), which has an incompatible type. This fixes indirect call mismatches with Control-Flow Integrity (CFI) checking. Signed-off-by: Sami Tolvanen Acked-by: Andy Lutomirski Cc: Borislav Petkov Cc: H . Peter Anvin Cc: Kees Cook Cc: Linus Torvalds Cc: Peter Zijlstra Cc: Thomas Gleixner Link: https://lkml.kernel.org/r/20191008224049.115427-6-samitolvanen@google.com Signed-off-by: Ingo Molnar Signed-off-by: Greg Kroah-Hartman --- arch/x86/include/asm/syscall_wrapper.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) --- a/arch/x86/include/asm/syscall_wrapper.h +++ b/arch/x86/include/asm/syscall_wrapper.h @@ -6,6 +6,8 @@ #ifndef _ASM_X86_SYSCALL_WRAPPER_H #define _ASM_X86_SYSCALL_WRAPPER_H +struct pt_regs; + /* Mapping of registers to parameters for syscalls on x86-64 and x32 */ #define SC_X86_64_REGS_TO_ARGS(x, ...) \ __MAP(x,__SC_ARGS \ @@ -64,9 +66,15 @@ SYSCALL_ALIAS(__ia32_sys_##sname, __x64_sys_##sname); \ asmlinkage long __x64_sys_##sname(const struct pt_regs *__unused) -#define COND_SYSCALL(name) \ - cond_syscall(__x64_sys_##name); \ - cond_syscall(__ia32_sys_##name) +#define COND_SYSCALL(name) \ + asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ + { \ + return sys_ni_syscall(); \ + } \ + asmlinkage __weak long __ia32_sys_##name(const struct pt_regs *__unused)\ + { \ + return sys_ni_syscall(); \ + } #define SYS_NI(name) \ SYSCALL_ALIAS(__x64_sys_##name, sys_ni_posix_timers); \ @@ -218,7 +226,11 @@ #endif #ifndef COND_SYSCALL -#define COND_SYSCALL(name) cond_syscall(__x64_sys_##name) +#define COND_SYSCALL(name) \ + asmlinkage __weak long __x64_sys_##name(const struct pt_regs *__unused) \ + { \ + return sys_ni_syscall(); \ + } #endif #ifndef SYS_NI @@ -230,7 +242,6 @@ * For VSYSCALLS, we need to declare these three syscalls with the new * pt_regs-based calling convention for in-kernel use. */ -struct pt_regs; asmlinkage long __x64_sys_getcpu(const struct pt_regs *regs); asmlinkage long __x64_sys_gettimeofday(const struct pt_regs *regs); asmlinkage long __x64_sys_time(const struct pt_regs *regs);