Skip to content

Commit

Permalink
security: revalidate rw permissions for sys_splice and sys_vmsplice
Browse files Browse the repository at this point in the history
Revalidate read/write permissions for splice(2) and vmslice(2), in case
security policy has changed since the files were opened.

Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
  • Loading branch information
James Morris authored and Jens Axboe committed Jul 13, 2007
1 parent d3f35d9 commit 29ce205
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions fs/splice.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/uio.h>
#include <linux/security.h>

/*
* Attempt to steal a page from a pipe buffer. This should perhaps go into
Expand Down Expand Up @@ -961,6 +962,10 @@ static long do_splice_from(struct pipe_inode_info *pipe, struct file *out,
if (unlikely(ret < 0))
return ret;

ret = security_file_permission(out, MAY_WRITE);
if (unlikely(ret < 0))
return ret;

return out->f_op->splice_write(pipe, out, ppos, len, flags);
}

Expand All @@ -983,6 +988,10 @@ static long do_splice_to(struct file *in, loff_t *ppos,
if (unlikely(ret < 0))
return ret;

ret = security_file_permission(in, MAY_READ);
if (unlikely(ret < 0))
return ret;

return in->f_op->splice_read(in, ppos, pipe, len, flags);
}

Expand Down

0 comments on commit 29ce205

Please sign in to comment.