mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: H Hartley Sweeten <hartleys@visionengravers.com>
To: Linux Kernel <linux-kernel@vger.kernel.org>
Cc: <akpm@linux-foundation.org>
Subject: [RFC PATCH 1/2] init: introduce private syscall wrappers for non-user space pointers
Date: Mon, 16 Apr 2012 17:33:36 -0700	[thread overview]
Message-ID: <201204161733.36380.hartleys@visionengravers.com> (raw)

Wrap the syscalls used by the init mount code so that the appropriate
__user markups are added for kernel pointers.

Signed-off-by: H Hartley Sweeten <hsweeten@visionengravers.com>
Cc: Andrew Morton <akpm@linux-foundation.org>

---

diff --git a/init/do_mounts.h b/init/do_mounts.h
index f5b978a..e7d36de 100644
--- a/init/do_mounts.h
+++ b/init/do_mounts.h
@@ -8,6 +8,109 @@
 #include <linux/major.h>
 #include <linux/root_dev.h>
 
+static inline long __sys_mount(char *dev_name, char *dir_name,
+			       char *type, unsigned long flags, void *data)
+{
+	return sys_mount((char __user __force *)dev_name,
+			 (char __user __force *)dir_name,
+			 (char __user __force *)type, flags,
+			 (void __user __force *)data);
+}
+
+static inline long __sys_umount(char *name, int flags)
+{
+	return sys_umount((char __user __force *)name, flags);
+}
+
+static inline long __sys_newlstat(const char *filename, struct stat *statbuf)
+{
+	return sys_newlstat((const char __user __force *)filename,
+			    (struct stat __user __force *)statbuf);
+}
+
+static inline long __sys_chroot(const char *filename)
+{
+	return sys_chroot((const char __user __force *)filename);
+}
+
+static inline long __sys_mknod(const char *filename, umode_t mode,
+			       unsigned dev)
+{
+	return sys_mknod((const char __user __force *)filename, mode, dev);
+}
+
+static inline long __sys_link(const char *oldname, const char *newname)
+{
+	return sys_link((const char __user __force *)oldname,
+			(const char __user __force *)newname);
+}
+
+static inline long __sys_symlink(const char *old, const char *new)
+{
+	return sys_symlink((const char __user __force *)old,
+			   (const char __user __force *)new);
+}
+
+static inline long __sys_unlink(const char *pathname)
+{
+	return sys_unlink((const char __user __force *)pathname);
+}
+
+static inline long __sys_chmod(const char *filename, umode_t mode)
+{
+	return sys_chmod((const char __user __force *)filename, mode);
+}
+
+static inline long __sys_open(const char *filename,
+				int flags, umode_t mode)
+{
+	return sys_open((const char __user __force *)filename, flags, mode);
+}
+
+static inline long __sys_chown(const char *filename, uid_t user, gid_t group)
+{
+	return sys_chown((const char __user __force *)filename, user, group);
+}
+
+static inline long __sys_lchown(const char *filename, uid_t user, gid_t group)
+{
+	return sys_lchown((const char __user __force *)filename, user, group);
+}
+
+static inline long __sys_read(unsigned int fd, char *buf, size_t count)
+{
+	return sys_read(fd, (char __user __force *)buf, count);
+}
+
+static inline long __sys_write(unsigned int fd, const char *buf, size_t count)
+{
+	return sys_write(fd, (const char __user __force *)buf, count);
+}
+
+static inline long __sys_mkdir(const char *pathname, umode_t mode)
+{
+	return sys_mkdir((const char __user __force *)pathname, mode);
+}
+
+static inline long __sys_chdir(const char *filename)
+{
+	return sys_chdir((const char __user __force *)filename);
+}
+
+static inline long __sys_rmdir(const char *pathname)
+{
+	return sys_rmdir((const char __user __force *)pathname);
+}
+
+static inline long __sys_getdents64(unsigned int fd,
+				    struct linux_dirent64 *dirent,
+				    unsigned int count)
+{
+	return sys_getdents64(fd,
+			      (struct linux_dirent64 __user __force *)dirent,
+			      count);
+}
+
 void  change_floppy(char *fmt, ...);
 void  mount_block_root(char *name, int flags);
 void  mount_root(void);
@@ -15,8 +118,8 @@ extern int root_mountflags;
 
 static inline int create_dev(char *name, dev_t dev)
 {
-	sys_unlink(name);
-	return sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
+	__sys_unlink(name);
+	return __sys_mknod(name, S_IFBLK|0600, new_encode_dev(dev));
 }
 
 #if BITS_PER_LONG == 32

                 reply	other threads:[~2012-04-17  0:33 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=201204161733.36380.hartleys@visionengravers.com \
    --to=hartleys@visionengravers.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.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®