Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3581540imm; Mon, 18 Jun 2018 00:02:36 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKzGrCOl/vVc4lglR8mg0hT19nrLH+Ix+/EEkVtpyNJXFZJhDX6wbjmK89BeXiT90zrVTMX X-Received: by 2002:a17:902:bb81:: with SMTP id m1-v6mr12747253pls.117.1529305356280; Mon, 18 Jun 2018 00:02:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529305356; cv=none; d=google.com; s=arc-20160816; b=zc82p4yEr9hgTQlg28eQ+bJ1HvIu6xoxwDrQ0Yya6CnttnuR/K2hDj8rjf1diP6RWh hEKJaDKEfnSeryOOYsexYu+FvOesbxCDWERdbMVq2mY4aNugNNXLzUD5Zj2zDCDQ3Ong 5Nmrqmn2jxBZ6eQjT/0X1/4WFYXwrGUbDagv5yBQMMIDMHe6ibY2M8rZyDEaCLDLzzLP Gj1odRmOrx9IZXDZTTsd5DI6CWU2eDWLZifDIYmH5vVS+LL+Ed2oH+RGumNV+bT0sm+z 1t1okk2PHRxq35Sjoz171hUF9CWIoRFKuSnhWqNzlOCRgJWPqhwtvDfVPakBgRC3cX49 WFEw== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:arc-authentication-results; bh=hRXL1OscnYa0x+AJWh01MAObCUwr48pefqbyjIYTQC4=; b=Jsr8sVmq/04T/3hej7KRX4GyQxbogOaFvaVnzauJz+FRvBWFZ1ewhRYW6O/q/ln0PO 3aohVbGw0iImPTvO+mpobnwdquYpiWQ63ATgzsxJQfUbskY12Z6KkTBkMR6/4KGCyRgu eiIbDzvmC/wynaFRm/B4P9dluoWQhwnt93ZMIYbUOpnqhU9jOFXksCUSW+eBCTmylB1/ GSivD/d/VZJAsE1oY1EU8rDXl0FU37x+UUF8mkpT30iD+1B0fMCc5gX3KrycLKST7QP5 qEJ816I6ngme1LWu2iU3iIo+6EyI6sBGZ9yiMXS1UdXQZKlIBDrFbAhx17XPongu5CRX QXUQ== ARC-Authentication-Results: i=1; mx.google.com; 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 l26-v6si7334965pgc.438.2018.06.18.00.02.22; Mon, 18 Jun 2018 00:02:36 -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; 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 S1755162AbeFRHB2 (ORCPT + 99 others); Mon, 18 Jun 2018 03:01:28 -0400 Received: from pegase1.c-s.fr ([93.17.236.30]:24300 "EHLO pegase1.c-s.fr" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755141AbeFRHB0 (ORCPT ); Mon, 18 Jun 2018 03:01:26 -0400 Received: from localhost (mailhub1-int [192.168.12.234]) by localhost (Postfix) with ESMTP id 418MSs01Xqz9ttlc; Mon, 18 Jun 2018 09:01:17 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at c-s.fr Received: from pegase1.c-s.fr ([192.168.12.234]) by localhost (pegase1.c-s.fr [192.168.12.234]) (amavisd-new, port 10024) with ESMTP id bRUGuSVImyWT; Mon, 18 Jun 2018 09:01:16 +0200 (CEST) Received: from messagerie.si.c-s.fr (messagerie.si.c-s.fr [192.168.25.192]) by pegase1.c-s.fr (Postfix) with ESMTP id 418MSr6TfQz9ttlX; Mon, 18 Jun 2018 09:01:16 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 4BE438B80A; Mon, 18 Jun 2018 09:01:23 +0200 (CEST) X-Virus-Scanned: amavisd-new at c-s.fr Received: from messagerie.si.c-s.fr ([127.0.0.1]) by localhost (messagerie.si.c-s.fr [127.0.0.1]) (amavisd-new, port 10023) with ESMTP id pjoqG5II4fxC; Mon, 18 Jun 2018 09:01:23 +0200 (CEST) Received: from PO15451 (unknown [192.168.232.3]) by messagerie.si.c-s.fr (Postfix) with ESMTP id 1BC258B74B; Mon, 18 Jun 2018 09:01:22 +0200 (CEST) Subject: Re: [PATCH 2/3] disable -Wattribute-alias warning for SYSCALL_DEFINEx() To: Paul Burton , linux-kbuild@vger.kernel.org Cc: Mauro Carvalho Chehab , linux-mips@linux-mips.org, Arnd Bergmann , Ingo Molnar , Matthew Wilcox , Thomas Gleixner , Douglas Anderson , Josh Poimboeuf , Andrew Morton , Matthias Kaehlcke , He Zhe , Benjamin Herrenschmidt , Michal Marek , Khem Raj , Al Viro , Stafford Horne , Gideon Israel Dsouza , Masahiro Yamada , Kees Cook , Michael Ellerman , Heiko Carstens , linux-kernel@vger.kernel.org, Paul Mackerras , linuxppc-dev@lists.ozlabs.org References: <20180616005323.7938-1-paul.burton@mips.com> <20180616005323.7938-3-paul.burton@mips.com> From: Christophe LEROY Message-ID: <8b6f684a-38d4-c757-ce0f-fdb2e0a3476b@c-s.fr> Date: Mon, 18 Jun 2018 09:01:21 +0200 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: <20180616005323.7938-3-paul.burton@mips.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: fr Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Le 16/06/2018 à 02:53, Paul Burton a écrit : > From: Arnd Bergmann > > gcc-8 warns for every single definition of a system call entry > point, e.g.: > > include/linux/compat.h:56:18: error: 'compat_sys_rt_sigprocmask' alias between functions of incompatible types 'long int(int, compat_sigset_t *, compat_sigset_t *, compat_size_t)' {aka 'long int(int, struct *, struct *, unsigned int)'} and 'long int(long int, long int, long int, long int)' [-Werror=attribute-alias] > asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))\ > ^~~~~~~~~~ > include/linux/compat.h:45:2: note: in expansion of macro 'COMPAT_SYSCALL_DEFINEx' > COMPAT_SYSCALL_DEFINEx(4, _##name, __VA_ARGS__) > ^~~~~~~~~~~~~~~~~~~~~~ > kernel/signal.c:2601:1: note: in expansion of macro 'COMPAT_SYSCALL_DEFINE4' > COMPAT_SYSCALL_DEFINE4(rt_sigprocmask, int, how, compat_sigset_t __user *, nset, > ^~~~~~~~~~~~~~~~~~~~~~ > include/linux/compat.h:60:18: note: aliased declaration here > asmlinkage long compat_SyS##name(__MAP(x,__SC_LONG,__VA_ARGS__))\ > ^~~~~~~~~~ > > The new warning seems reasonable in principle, but it doesn't > help us here, since we rely on the type mismatch to sanitize the > system call arguments. After I reported this as GCC PR82435, a new > -Wno-attribute-alias option was added that could be used to turn the > warning off globally on the command line, but I'd prefer to do it a > little more fine-grained. > > Interestingly, turning a warning off and on again inside of > a single macro doesn't always work, in this case I had to add > an extra statement inbetween and decided to copy the __SC_TEST > one from the native syscall to the compat syscall macro. See > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83256 for more details > about this. > > [paul.burton@mips.com: > - Rebase atop current master. > - Split GCC & version arguments to __diag_ignore() in order to match > changes to the preceding patch. > - Add the comment argument to match the preceding patch.] > > Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82435 > Signed-off-by: Arnd Bergmann > Signed-off-by: Paul Burton > Cc: Michal Marek > Cc: Masahiro Yamada > Cc: Douglas Anderson > Cc: Al Viro > Cc: Heiko Carstens > Cc: Mauro Carvalho Chehab > Cc: Matthew Wilcox > Cc: Matthias Kaehlcke > Cc: Arnd Bergmann > Cc: Ingo Molnar > Cc: Josh Poimboeuf > Cc: Kees Cook > Cc: Andrew Morton > Cc: Thomas Gleixner > Cc: Gideon Israel Dsouza > Cc: Christophe Leroy > Cc: Benjamin Herrenschmidt > Cc: Paul Mackerras > Cc: Michael Ellerman > Cc: Stafford Horne > Cc: Khem Raj > Cc: He Zhe > Cc: linux-kbuild@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > Cc: linux-mips@linux-mips.org > Cc: linuxppc-dev@lists.ozlabs.org Tested-by: Christophe Leroy > --- > > include/linux/compat.h | 8 +++++++- > include/linux/syscalls.h | 4 ++++ > 2 files changed, 11 insertions(+), 1 deletion(-) > > diff --git a/include/linux/compat.h b/include/linux/compat.h > index b1a5562b3215..c68acc47da57 100644 > --- a/include/linux/compat.h > +++ b/include/linux/compat.h > @@ -72,6 +72,9 @@ > */ > #ifndef COMPAT_SYSCALL_DEFINEx > #define COMPAT_SYSCALL_DEFINEx(x, name, ...) \ > + __diag_push(); \ > + __diag_ignore(GCC, 8, "-Wattribute-alias", \ > + "Type aliasing is used to sanitize syscall arguments");\ > asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)); \ > asmlinkage long compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ > __attribute__((alias(__stringify(__se_compat_sys##name)))); \ > @@ -80,8 +83,11 @@ > asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)); \ > asmlinkage long __se_compat_sys##name(__MAP(x,__SC_LONG,__VA_ARGS__)) \ > { \ > - return __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\ > + long ret = __do_compat_sys##name(__MAP(x,__SC_DELOUSE,__VA_ARGS__));\ > + __MAP(x,__SC_TEST,__VA_ARGS__); \ > + return ret; \ > } \ > + __diag_pop(); \ > static inline long __do_compat_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) > #endif /* COMPAT_SYSCALL_DEFINEx */ > > diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h > index 73810808cdf2..a368a68cb667 100644 > --- a/include/linux/syscalls.h > +++ b/include/linux/syscalls.h > @@ -231,6 +231,9 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) > */ > #ifndef __SYSCALL_DEFINEx > #define __SYSCALL_DEFINEx(x, name, ...) \ > + __diag_push(); \ > + __diag_ignore(GCC, 8, "-Wattribute-alias", \ > + "Type aliasing is used to sanitize syscall arguments");\ > asmlinkage long sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) \ > __attribute__((alias(__stringify(__se_sys##name)))); \ > ALLOW_ERROR_INJECTION(sys##name, ERRNO); \ > @@ -243,6 +246,7 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event) > __PROTECT(x, ret,__MAP(x,__SC_ARGS,__VA_ARGS__)); \ > return ret; \ > } \ > + __diag_pop(); \ > static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__)) > #endif /* __SYSCALL_DEFINEx */ > >