From: Josh Poimboeuf <jpoimboe@redhat.com>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Peter Zijlstra <peterz@infradead.org>,
the arch/x86 maintainers <x86@kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Kees Cook <keescook@chromium.org>
Subject: Re: Remaining randconfig objtool warnings, linux-next-20200428
Date: Thu, 30 Apr 2020 14:46:30 -0500 [thread overview]
Message-ID: <20200430194630.jkwysx6eftkaf6bu@treble> (raw)
In-Reply-To: <20200430143350.qezebqmx2xwdxqxq@treble>
On Thu, Apr 30, 2020 at 09:33:50AM -0500, Josh Poimboeuf wrote:
> On Thu, Apr 30, 2020 at 03:41:56PM +0200, Arnd Bergmann wrote:
> > On Thu, Apr 30, 2020 at 1:28 AM Josh Poimboeuf <jpoimboe@redhat.com> wrote:
> > >
> > > On Wed, Apr 29, 2020 at 06:11:15PM -0500, Josh Poimboeuf wrote:
> > > > > We can probably move those SYS_NI() instances to kernel/sys_ni.c,
> > > > > which does not include the header, but it's still a bit ugly. I'll try
> > > > > that tomorrow
> > > > > unless you come up with a better suggestion first.
> > > >
> > > > Oh I guess arm32 doesn't have SYS_NI defined. All this syscall aliasing
> > > > stuff is a total mystery to me.
> > >
> > > Another idea would be to split up syscalls.h into two files: one for
> > > SYSCALL_* macros and one for sys_*() function prototypes. It sounds
> > > like the latter aren't needed by most header files anyway.
> > >
> > > * Please note that these prototypes here are only provided for information
> > > * purposes, for static analysis, and for linking from the syscall table.
> > > * These functions should not be called elsewhere from kernel code.
> >
> > To me the main purpose of the header is to ensure the calling conventions
> > are sane, so I'd definitely want to see the declarations included whenever
> > a syscall is defined. I would also expect to see a warnig from sparse, or
> > from gcc with "make W=1" when an extern function is defined with no
> > prior declaration.
>
> Yup, makes sense. I think I've been getting confused by the syscall
> wrappers.
>
> > How hard would it be to change objtool instead of changing the sources?
>
> It might be a little tricky, but I can look into it.
So there's an easy fix below, just define an x86-specific SYSCALL_ALIAS.
It also requries moving the syscall alias macros to syscalls.h, but
that's probably where they belong anyway.
But the objtool .cold parent alias function detection is a little
smelly, so I might end up cleaning that up instead if I can figure out a
good way to do it.
diff --git a/arch/x86/include/asm/syscall_wrapper.h b/arch/x86/include/asm/syscall_wrapper.h
index a84333adeef2..abe6e633f8dc 100644
--- a/arch/x86/include/asm/syscall_wrapper.h
+++ b/arch/x86/include/asm/syscall_wrapper.h
@@ -79,6 +79,8 @@ extern long __ia32_sys_ni_syscall(const struct pt_regs *regs);
return __se_##name(__VA_ARGS__); \
}
+#define SYSCALL_ALIAS(alias, name) __alias(name) typeof(name) alias
+
#define __COND_SYSCALL(abi, name) \
__weak long __##abi##_##name(const struct pt_regs *__unused) \
{ \
diff --git a/include/linux/linkage.h b/include/linux/linkage.h
index d796ec20d114..369c65d4386c 100644
--- a/include/linux/linkage.h
+++ b/include/linux/linkage.h
@@ -22,20 +22,6 @@
#define asmlinkage CPP_ASMLINKAGE
#endif
-#ifndef cond_syscall
-#define cond_syscall(x) asm( \
- ".weak " __stringify(x) "\n\t" \
- ".set " __stringify(x) "," \
- __stringify(sys_ni_syscall))
-#endif
-
-#ifndef SYSCALL_ALIAS
-#define SYSCALL_ALIAS(alias, name) asm( \
- ".globl " __stringify(alias) "\n\t" \
- ".set " __stringify(alias) "," \
- __stringify(name))
-#endif
-
#define __page_aligned_data __section(.data..page_aligned) __aligned(PAGE_SIZE)
#define __page_aligned_bss __section(.bss..page_aligned) __aligned(PAGE_SIZE)
diff --git a/include/linux/syscalls.h b/include/linux/syscalls.h
index 1815065d52f3..dc93d7e595af 100644
--- a/include/linux/syscalls.h
+++ b/include/linux/syscalls.h
@@ -252,6 +252,20 @@ static inline int is_syscall_trace_event(struct trace_event_call *tp_event)
static inline long __do_sys##name(__MAP(x,__SC_DECL,__VA_ARGS__))
#endif /* __SYSCALL_DEFINEx */
+#ifndef SYSCALL_ALIAS
+#define SYSCALL_ALIAS(alias, name) asm( \
+ ".globl " __stringify(alias) "\n\t" \
+ ".set " __stringify(alias) "," \
+ __stringify(name))
+#endif
+
+#ifndef cond_syscall
+#define cond_syscall(x) asm( \
+ ".weak " __stringify(x) "\n\t" \
+ ".set " __stringify(x) "," \
+ __stringify(sys_ni_syscall))
+#endif
+
/*
* Called before coming back to user-mode. Returning to user-mode with an
* address limit different than USER_DS can allow to overwrite kernel memory.
next prev parent reply other threads:[~2020-04-30 19:46 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-28 14:49 Arnd Bergmann
2020-04-28 16:10 ` Josh Poimboeuf
2020-04-28 19:11 ` Kees Cook
2020-04-28 20:19 ` Arnd Bergmann
2020-04-28 20:38 ` Josh Poimboeuf
2020-04-28 21:55 ` Peter Zijlstra
2020-04-28 22:03 ` Josh Poimboeuf
2020-04-28 22:33 ` Peter Zijlstra
2020-04-28 22:48 ` Josh Poimboeuf
2020-04-28 23:08 ` Josh Poimboeuf
2020-04-29 18:55 ` Josh Poimboeuf
2020-04-29 22:46 ` Arnd Bergmann
2020-04-29 23:01 ` Josh Poimboeuf
2020-04-29 23:11 ` Josh Poimboeuf
2020-04-29 23:28 ` Josh Poimboeuf
2020-04-30 13:41 ` Arnd Bergmann
2020-04-30 14:33 ` Josh Poimboeuf
2020-04-30 19:46 ` Josh Poimboeuf [this message]
2020-04-30 20:59 ` Arnd Bergmann
2020-04-30 21:10 ` Josh Poimboeuf
2020-04-30 21:08 ` Josh Poimboeuf
2020-04-30 23:02 ` Josh Poimboeuf
2020-04-29 19:18 ` Josh Poimboeuf
2020-05-01 12:23 ` Peter Zijlstra
2020-04-30 14:05 ` Arnd Bergmann
2020-05-01 0:28 ` Josh Poimboeuf
2020-05-01 11:41 ` Arnd Bergmann
2020-05-01 17:16 ` Peter Zijlstra
2020-05-01 12:27 ` Peter Zijlstra
2020-05-01 1:07 ` Josh Poimboeuf
2020-05-01 11:18 ` Arnd Bergmann
2020-05-01 12:33 ` Peter Zijlstra
2020-05-01 13:08 ` Arnd Bergmann
2020-05-01 15:49 ` Josh Poimboeuf
2020-05-01 17:21 ` Arnd Bergmann
2020-05-01 17:26 ` Peter Zijlstra
2020-05-01 17:50 ` Josh Poimboeuf
2020-05-01 19:47 ` Arnd Bergmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200430194630.jkwysx6eftkaf6bu@treble \
--to=jpoimboe@redhat.com \
--cc=arnd@arndb.de \
--cc=keescook@chromium.org \
--cc=linux-kernel@vger.kernel.org \
--cc=peterz@infradead.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®