Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp1282962ybe; Fri, 13 Sep 2019 14:04:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqw11Ry2Zi1IGv4zGhSZ2m1vZZBlwQODQ8xbkzdtGImGbuMuFymdPJeM6OLm8Bnu1/lj5ooZ X-Received: by 2002:aa7:cfd0:: with SMTP id r16mr48352279edy.104.1568408679776; Fri, 13 Sep 2019 14:04:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568408679; cv=none; d=google.com; s=arc-20160816; b=G/nxTFOseQA4FHzEcx+YYNOU5vU0m8y+fCJa+/YX7aCeZViZc/n++FqEEyOvuC80fI 2RajVjLew0IbR6FvDcsnRBbtnzpL6VHNYxSe5BtUjGW4LSMAiFjdOhy8zZZ1gVqo35Wa /BkuPU1io9gE+KUQxCFj9Q+D625D3o1IzI1uyEnNzrz/kkKgOqS8m2+5wQOf7vwYy21W neaRxU8UGHYUIHkPUKQ96JNyMQM0JlzhRkyyMXfrpRBMs8bua6rIbFoOabIA5D9HSJrk USufudjZMikoeMV2oG+ZLUkNTc7V9jk8p56sBQrjYwDPWZHGK+gBuju7+fNkJ+X42hBy 6l2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=v4Cua1E8F5eqeL2m3mcDw+ghn/aZUZbABVDxiLkYxm0=; b=sW09tcVEC0mgRW1Ou5tDWhlOn9Iqry7w+qZPepPwvfJl8SdB471CUmgo/xrnjroTqy CZSQ8HL8gCZnRavylbN1siyRTJiIKvuLNuFsf64MhiE1BmLP+HpCweETxUHEV/0uiexu DAff45V8Qv7I1xqhmySJZhEbznpOPgToyRGBgfjtGeQBgSpN9Wl/GMtQZFmGwWLqo1kO xE6oVM/tUZf1Zjsur0pvTd6zHTQf6oJcsmzgAAfns8E0wL1DwcGiVSdTQXf8spquVLt7 zI63i799xsAdT4WtM4Oxtnl1twFQdH9nNiK2Ca9jFg3Tqb7EaqwlVAmI+ZdUkwsqGsg9 QIpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=CXWHfS0M; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y47si18265826edd.236.2019.09.13.14.04.16; Fri, 13 Sep 2019 14:04:39 -0700 (PDT) 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=@google.com header.s=20161025 header.b=CXWHfS0M; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731230AbfIMVAh (ORCPT + 99 others); Fri, 13 Sep 2019 17:00:37 -0400 Received: from mail-qt1-f202.google.com ([209.85.160.202]:37503 "EHLO mail-qt1-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726558AbfIMVAg (ORCPT ); Fri, 13 Sep 2019 17:00:36 -0400 Received: by mail-qt1-f202.google.com with SMTP id s14so780844qtn.4 for ; Fri, 13 Sep 2019 14:00:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=v4Cua1E8F5eqeL2m3mcDw+ghn/aZUZbABVDxiLkYxm0=; b=CXWHfS0MHZL2f3WzGf4neYJjyN10ieyQMBD0UZ/14ufAQeNeZlZYl7FQFSsptXGALI UHHcDJGfn7MbJXfwDwy4O4IeT3d+JvwC6cnlnl+nTWCtGtz3hEAl7qRf1jqjvWplHvrz diCT2shA6tzXFj/wcB3E8dTmtDUSRBRKzV/R6C/8iQd8/7cNSmHL0UHf8ILtezVInUiA E8x8KKLHBCD6s+LSuCDPiM24scH4fPZRen4sONhSfrizn7HCAYBJsvkLfbsIxKSMA86U 0ARxgfNPwj/QlBVABdyCYBuglVoWll9TP1ctq95k5ibTVn/v1A3mHFPEEt0fEks5paED pohA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=v4Cua1E8F5eqeL2m3mcDw+ghn/aZUZbABVDxiLkYxm0=; b=gIzML++dGcvorKGkD4pa/OLN6ygMQMqKDIDdV/XbOTrpiQ4lBnYhoeYWvlxXZ2X04s /FFKZ0xs5wDCgoEhucoqaPzMIoX/SGAFZDs/okBYBdTRHFiePasa4PIUUAI8DyRgvm3L 7JtHJkbJnvVolqd+kY0zQNsEIzcBLfe2XinY/qPQB8ahWtt85ij6kES2czWSgp/2ldZJ k9G6rvDgLn60op0sdD54DA/CYYMUh9qVp0hkCaUO7THqmffqFlAhndigUyQ124G8LUii ZZrKCJuslxTjaT7ozyg5CClFAgWYMn8wUtSlE6pKwcUIP+iNkdARjAuKCsbN9n8YYh+p 2kkQ== X-Gm-Message-State: APjAAAWAVCw+tRVM64pxrddU5nd4fq09MQ3fBOuh/Fho2HdKhC0RbDEh N/gJ7bufcg7zQ6orH4AfRg5SHat8ZIe8mjeyXdI= X-Received: by 2002:a05:6214:1591:: with SMTP id m17mr24411892qvw.222.1568408433526; Fri, 13 Sep 2019 14:00:33 -0700 (PDT) Date: Fri, 13 Sep 2019 14:00:18 -0700 In-Reply-To: <20190913210018.125266-1-samitolvanen@google.com> Message-Id: <20190913210018.125266-5-samitolvanen@google.com> Mime-Version: 1.0 References: <20190913210018.125266-1-samitolvanen@google.com> X-Mailer: git-send-email 2.23.0.237.gc6a4ce50a0-goog Subject: [PATCH 4/4] x86: fix function types in COND_SYSCALL From: Sami Tolvanen To: Andy Lutomirski , Thomas Gleixner , Ingo Molnar , Borislav Petkov , "H . Peter Anvin" , Kees Cook Cc: x86@kernel.org, linux-kernel@vger.kernel.org, Sami Tolvanen Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- arch/x86/include/asm/syscall_wrapper.h | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h index 90eb70df0b18..9a595a544017 100644 --- 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 \ @@ -56,9 +58,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); \ @@ -190,7 +198,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 @@ -202,7 +214,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); -- 2.23.0.237.gc6a4ce50a0-goog