From: James Morris <jmorris@namei.org>
To: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Stephen Smalley <sds@tycho.nsa.gov>, linux-kernel@vger.kernel.org
Subject: [PATCH 05/11] security: revalidate rw permissions for sys_splice and sys_vmsplice
Date: Sun, 8 Jul 2007 22:58:05 -0400 (EDT) [thread overview]
Message-ID: <Line.LNX.4.64.0707082257390.12256@d.namei> (raw)
In-Reply-To: <Line.LNX.4.64.0707082253040.12256@d.namei>
Revalidate read/write permissions for splice(2) and vmslice(2), in case
security policy has changed since the files were opened.
Signed-off-by: James Morris <jmorris@namei.org>
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
---
fs/splice.c | 14 ++++++++++++++
1 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/fs/splice.c b/fs/splice.c
index e7d7080..98025ec 100644
--- a/fs/splice.c
+++ b/fs/splice.c
@@ -28,6 +28,7 @@
#include <linux/module.h>
#include <linux/syscalls.h>
#include <linux/uio.h>
+#include <linux/security.h>
struct partial_page {
unsigned int offset;
@@ -931,6 +932,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);
}
@@ -953,6 +958,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);
}
@@ -1271,6 +1280,7 @@ static int get_iovec_page_array(const struct iovec __user *iov,
static long do_vmsplice(struct file *file, const struct iovec __user *iov,
unsigned long nr_segs, unsigned int flags)
{
+ long err;
struct pipe_inode_info *pipe;
struct page *pages[PIPE_BUFFERS];
struct partial_page partial[PIPE_BUFFERS];
@@ -1289,6 +1299,10 @@ static long do_vmsplice(struct file *file, const struct iovec __user *iov,
else if (unlikely(!nr_segs))
return 0;
+ err = security_file_permission(file, MAY_WRITE);
+ if (unlikely(err < 0))
+ return err;
+
spd.nr_pages = get_iovec_page_array(iov, nr_segs, pages, partial,
flags & SPLICE_F_GIFT);
if (spd.nr_pages <= 0)
--
1.5.0.6
next prev parent reply other threads:[~2007-07-09 2:58 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-07-09 2:54 [PATCH 0/11] SELinux patches for 2.6.23 James Morris
2007-07-09 2:55 ` [PATCH 01/11] selinux: add support for querying object classes and permissions from the running policy James Morris
2007-07-09 2:56 ` [PATCH 02/11] selinux: rename sel_remove_bools() for more general usage James Morris
2007-07-09 2:56 ` [PATCH 03/11] selinux: change sel_make_dir() to specify inode counter James Morris
2007-07-09 2:57 ` [PATCH 04/11] selinux: add selinuxfs structure for object class discovery James Morris
2007-07-09 2:58 ` James Morris [this message]
2007-07-12 2:04 ` [PATCH 05/11] security: revalidate rw permissions for sys_splice and sys_vmsplice James Morris
2007-07-12 6:13 ` Jens Axboe
2007-07-09 2:58 ` [PATCH 06/11] selinux: introduce schedule points in policydb_destroy() James Morris
2007-07-09 2:59 ` [PATCH 08/11] SELinux: Use %lu for inode->i_no when printing avc James Morris
2007-07-09 2:59 ` [PATCH 09/11] security: Protection for exploiting null dereference using mmap James Morris
2007-07-10 7:52 ` Jan Engelhardt
2007-07-10 13:10 ` James Morris
2007-07-09 3:00 ` [PATCH 10/11] SELinux: use SECINITSID_NETMSG instead of SECINITSID_UNLABELED for NetLabel James Morris
2007-07-09 3:01 ` [PATCH 11/11] security: unexport mmap_min_addr James Morris
2007-07-09 3:02 ` [PATCH 07/11] SELinux: allow preemption between transition permission checks James Morris
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=Line.LNX.4.64.0707082257390.12256@d.namei \
--to=jmorris@namei.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sds@tycho.nsa.gov \
--cc=torvalds@linux-foundation.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
Powered by JetHome