2009-09-02 15:40:46

by Mimi Zohar

[permalink] [raw]
Subject: [PATCH 1/1] IMA: open new file for read

When creating a new file, ima_path_check() assumed the new file
was being opened for write. Call ima_path_check() with the
appropriate acc_mode so that the read/write counters are
incremented correctly.

Signed-off-by: Mimi Zohar <[email protected]>
---
fs/namei.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/namei.c b/fs/namei.c
index f3c5b27..ee01308 100644
--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1533,9 +1533,11 @@ int may_open(struct path *path, int acc_mode, int flag)
if (error)
return error;

- error = ima_path_check(path,
- acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC),
+ error = ima_path_check(path, acc_mode ?
+ acc_mode & (MAY_READ | MAY_WRITE | MAY_EXEC) :
+ ACC_MODE(flag) & (MAY_READ | MAY_WRITE),
IMA_COUNT_UPDATE);
+
if (error)
return error;
/*
--
1.6.0.6


2009-09-03 02:20:34

by James Morris

[permalink] [raw]
Subject: Re: [PATCH 1/1] IMA: open new file for read

On Wed, 2 Sep 2009, Mimi Zohar wrote:

> When creating a new file, ima_path_check() assumed the new file
> was being opened for write. Call ima_path_check() with the
> appropriate acc_mode so that the read/write counters are
> incremented correctly.
>
> Signed-off-by: Mimi Zohar <[email protected]>


Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next


--
James Morris
<[email protected]>