From: Yury Norov <ynorov@caviumnetworks.com>
To: heiko.carstens@de.ibm.com, arnd@arndb.de,
catalin.marinas@arm.com, linux-kernel@vger.kernel.org,
linux-s390@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-arch@vger.kernel.org, linux-doc@vger.kernel.org
Cc: Prasun.Kapoor@caviumnetworks.com, pinskia@gmail.com,
agraf@suse.de, broonie@kernel.org, joseph@codesourcery.com,
christoph.muellner@theobroma-systems.com,
Nathan_Lynch@mentor.com, klimov.linux@gmail.com,
bamvor.zhangjian@huawei.com,
Yury Norov <ynorov@caviumnetworks.com>
Subject: [PATCH 1/5] all: syscall wrappers: add documentation
Date: Fri, 26 Feb 2016 17:34:51 +0300 [thread overview]
Message-ID: <1456497295-22991-2-git-send-email-ynorov@caviumnetworks.com> (raw)
In-Reply-To: <1456497295-22991-1-git-send-email-ynorov@caviumnetworks.com>
Signed-off-by: Yury Norov <ynorov@caviumnetworks.com>
---
Documentation/adding-syscalls.txt | 32 ++++++++++++++++++++++++++++++++
1 file changed, 32 insertions(+)
diff --git a/Documentation/adding-syscalls.txt b/Documentation/adding-syscalls.txt
index cc2d4ac..d02a6bd 100644
--- a/Documentation/adding-syscalls.txt
+++ b/Documentation/adding-syscalls.txt
@@ -341,6 +341,38 @@ To summarize, you need:
- instance of __SC_COMP not __SYSCALL in include/uapi/asm-generic/unistd.h
+Compatibility System Calls Wrappers
+--------------------------------
+
+Some architectures prevent 32-bit userspace from access to top halves of 64-bit
+registers, but some not. It's not a problem if specific argument is the same
+size in kernel and userspace. It also is not a problem if system call is already
+handled by compatible routine. Otherwise we'd take care of it. Usually, glibc
+and compiler handles register's top halve, but from kernel side, we cannot rely
+on it, as malicious code may cause incorrect behaviour and/or security
+vulnerabilities.
+
+For now, only s390 and arm64/ilp32 are affected.
+
+To clear that top halves, automatic wrappers are introduced. They clear all
+required registers before passing control to regular syscall handler.
+
+If your architecture allows userspace code to access top halves of register,
+you need to:
+ - enable COMPAT_WRAPPER in configuration file;
+ - declare: "#define __SC_WRAP(nr, sym) [nr] = compat_##sym,", just before
+ compatible syscall table declaration, if you use generic unistd; or
+ - declare compat wrappers manually, if you use non-generic syscall table.
+ The list of unsafe syscalls is in kernel/compat_wrapper.
+
+If you write new syscall, make sure, its arguments are the same size in both
+64- and 32-bits modes. If no, and if there's no explicit compat version for
+syscall handler, you need to:
+ - declare compat version prototype in 'include/linux/compat.h';
+ - in 'include/uapi/asm-generic/unistd.h' declare syscall with macro '__SC_WRAP'
+ instead of '__SYSCALL';
+ - add corresponding line to 'kernel/compat_wrapper.c' to let it generate wrapper.
+
Compatibility System Calls (x86)
--------------------------------
--
2.5.0
next prev parent reply other threads:[~2016-02-26 14:34 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-26 14:34 [PATCH v3 0/5] all: s390: make compat wrappers the generic solution Yury Norov
2016-02-26 14:34 ` Yury Norov
2016-02-26 14:34 ` Yury Norov [this message]
2016-02-26 14:34 ` [PATCH 1/5] all: syscall wrappers: add documentation Yury Norov
2016-02-26 14:34 ` [PATCH 2/5] all: introduce COMPAT_WRAPPER option and enable it for s390 Yury Norov
2016-02-26 14:34 ` Yury Norov
2016-02-26 14:34 ` [PATCH 3/5] all: s390: move wrapper infrastructure to generic headers Yury Norov
2016-02-26 14:34 ` [PATCH 4/5] all: s390: move compat_wrappers.c from arch/s390/kernel to kernel Yury Norov
2016-02-26 14:34 ` Yury Norov
2016-02-26 14:34 ` [PATCH 5/5] all: wrap needed syscalls in generic unistd Yury Norov
2016-02-26 14:34 ` Yury Norov
-- strict thread matches above, loose matches on Subject: below --
2016-02-24 18:34 [PATCH v2 0/5] all: s390: make compat wrappers the generic solution Yury Norov
2016-02-24 18:34 ` [PATCH 1/5] all: syscall wrappers: add documentation Yury Norov
2016-02-24 18:34 ` Yury Norov
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=1456497295-22991-2-git-send-email-ynorov@caviumnetworks.com \
--to=ynorov@caviumnetworks.com \
--cc=Nathan_Lynch@mentor.com \
--cc=Prasun.Kapoor@caviumnetworks.com \
--cc=agraf@suse.de \
--cc=arnd@arndb.de \
--cc=bamvor.zhangjian@huawei.com \
--cc=broonie@kernel.org \
--cc=catalin.marinas@arm.com \
--cc=christoph.muellner@theobroma-systems.com \
--cc=heiko.carstens@de.ibm.com \
--cc=joseph@codesourcery.com \
--cc=klimov.linux@gmail.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pinskia@gmail.com \
/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