From: Arnd Bergmann <arnd@arndb.de>
To: Namhyung Kim <namhyung@gmail.com>
Cc: Andrew Morton <akpm@linux-foundation.org>,
Phillip Lougher <phillip@lougher.demon.co.uk>,
Al Viro <viro@zeniv.linux.org.uk>,
linux-kernel@vger.kernel.org
Subject: Re: [RFC v2 PATCH 1/3] init: add sys-wrapper.h
Date: Mon, 30 Aug 2010 14:11:43 +0200 [thread overview]
Message-ID: <201008301411.43910.arnd@arndb.de> (raw)
In-Reply-To: <1283102928-3051-2-git-send-email-namhyung@gmail.com>
On Sunday 29 August 2010, Namhyung Kim wrote:
> +
> +/* These macro are called just before/after actual syscalls. */
> +#define KSYS_PREPARE \
> + mm_segment_t old_fs = get_fs(); \
> + set_fs(KERNEL_DS);
> +
> +#define KSYS_RESTORE \
> + set_fs(old_fs);
These macros are not that nice, because they depend on context.
I would probably open-code them in each function, or possibly
use a single macro to combine it to something like
#define kern_sys_call(call, ...) \
({ \
mm_segment_t old_fs = get_fs(); \
long result; \
set_fs(KERNEL_DS); \
result = call(__VA_ARGS__); \
set_fs(old_fs); \
result; \
})
static inline int kern_sys_link(const char *oldname, const char *newname)
{
return kern_sys_call(sys_link, (const char __user __force *)oldname,
(const char __user __force *)newname);
}
> +static inline int kern_sys_fchown(unsigned int fd, uid_t user, gid_t group)
> +{
> + int ret;
> + KSYS_PREPARE;
> +
> + ret = sys_fchown(fd, user, group);
> +
> + KSYS_RESTORE;
> + return ret;
> +}
When there are no pointer arguments, there is no need to do set_fs
tricks.
Arnd
next prev parent reply other threads:[~2010-08-30 12:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-08-29 17:28 [RFC v2 PATCH 0/3] initramfs: cleanups Namhyung Kim
2010-08-29 17:28 ` [RFC v2 PATCH 1/3] init: add sys-wrapper.h Namhyung Kim
2010-08-30 12:11 ` Arnd Bergmann [this message]
2010-08-30 14:17 ` Namhyung Kim
2010-08-29 17:28 ` [RFC v2 PATCH 2/3] initramfs: use kern_sys_* wrappers instead of syscall Namhyung Kim
2010-08-29 17:28 ` [RFC v2 PATCH 3/3] init: introduce CONFIG_USE_INIT_SYSCALL_AS_KERNEL_ROUTINE Namhyung Kim
2010-08-30 12:02 ` [RFC v2 PATCH 0/3] initramfs: cleanups Arnd Bergmann
2010-08-30 14:05 ` Namhyung Kim
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=201008301411.43910.arnd@arndb.de \
--to=arnd@arndb.de \
--cc=akpm@linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=namhyung@gmail.com \
--cc=phillip@lougher.demon.co.uk \
--cc=viro@zeniv.linux.org.uk \
/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