projects/linux·commit e7edf9cd

[PATCH] LSM: add missing hook to do_compat_readv_writev()

e7edf9cd · James Morris <[email protected]> · 2006-04-26 02:45:03 -04:00

This patch addresses a flaw in LSM, where there is no mediation of readv()
and writev() in for 32-bit compatible apps using a 64-bit kernel.

This bug was discovered and fixed initially in the native readv/writev
code [1], but was not fixed in the compat code.  Thanks to Al for spotting
this one.

  [1] http://lwn.net/Articles/154282/

Signed-off-by: James Morris <[email protected]>
Signed-off-by: Al Viro <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
Commit
e7edf9cdeddc0cff125e8e658216efb2ff2b2219
Parents
a090d913

Changes

1 files changed · +4 −0

FileStatusAddDelContent
fs/compat.cmodified+4−0View file

fs/compat.c

View file
diff --git a/fs/compat.c b/fs/compat.c
index 7f8e26e..2e32bd3 100644
--- a/fs/compat.c
+++ b/fs/compat.c
@@ -1217,6 +1217,10 @@ static ssize_t compat_do_readv_writev(int type, struct file *file,
if (ret < 0)
goto out;
+ ret = security_file_permission(file, type == READ ? MAY_READ:MAY_WRITE);
+ if (ret)
+ goto out;
+
fnv = NULL;
if (type == READ) {
fn = file->f_op->read;