Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>Welcome to stackoverflow!</strong> IIRC you want <code>sys_chmod()</code></p> <blockquote> <p><strong>From the Linux Kernel Mailing List</strong> </p> <p>On Thu, Feb 20, 2003 at 11:10:27PM +0100, Andrea Arcangeli wrote: On Thu, Feb 20, 2003 at 12:40:43PM -0500, Jeff Garzik wrote:</p> <blockquote> <p>On Thu, Feb 20, 2003 at 11:04:37PM +0530, Prasad wrote:</p> <blockquote> <p>Is there a way using which i could invoke a syscall in the kernel space? The syscall is to be run disguised as another process. The actual</p> </blockquote> <p>Call sys_whatever(). Look at the kernel code for examples.</p> <p>The kernel already does this in various places. sys_read, sys_write, open_filp, sys_close, and other functions are safe to call from kernel code -- though this is discouraged. init/do_mounts.c is a particularly annoying case, and is a big reason why klibc needs to be merged. syscalls should be made from userspace, not the kernel.</p> </blockquote> </blockquote> <p>People are starting to worry, as this isn't the kind of thing you might do in the kernel (unless you are use you know what you are doing). If you just want to change permissions on a certain event, do it from userspace with <a href="http://en.wikipedia.org/wiki/Inotify" rel="nofollow noreferrer">inotify</a> or similar.</p> <p>Disclaimer aside:</p> <p>Here is some code I found in another kernel module, which uses the sys_* calls:</p> <pre><code>#include &lt;linux/init.h&gt; #include &lt;linux/fs.h&gt; #include &lt;linux/slab.h&gt; #include &lt;linux/types.h&gt; #include &lt;linux/fcntl.h&gt; #include &lt;linux/delay.h&gt; #include &lt;linux/string.h&gt; #include &lt;linux/syscalls.h&gt; /* Snip */ int openflags = O_WRONLY|O_CREAT; if (ml != 1) openflags |= O_TRUNC; wfd = sys_open(collected, openflags, mode); if (wfd &gt;= 0) { sys_fchown(wfd, uid, gid); sys_fchmod(wfd, mode); state = CopyFile; } </code></pre> <p>Also found:</p> <pre><code>asmlinkage long sys_rename(const char __user *oldname, const char __user *newname); asmlinkage long sys_chmod(const char __user *filename, mode_t mode); asmlinkage long sys_fchmod(unsigned int fd, mode_t mode); </code></pre> <p>in <code>include/linux/syscalls.h</code></p> <p>Mind you, it has been a while since I did any kernel stuff. <strong>Check</strong> that this is the appropriate interface for chmod stuff and that you arn't shortcutting any other call that might implement security hooks, for example.</p> <p>Also, <strong><a href="http://tldp.org/HOWTO/KernelAnalysis-HOWTO-3.html" rel="nofollow noreferrer">This link contains information on syscalls</a></strong> and their symbols. Also <strong><a href="http://www.digilife.be/quickreferences/QRC/LINUX%20System%20Call%20Quick%20Reference.pdf" rel="nofollow noreferrer">Here</a></strong> is a quick-reference of user-space API system calls and where they are implemented in the kernel. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload