Skip to content

Commit

Permalink
TOMOYO: Fix memory leak upon file open.
Browse files Browse the repository at this point in the history
In tomoyo_check_open_permission() since 2.6.36, TOMOYO was by error
recalculating already calculated pathname when checking allow_rewrite
permission. As a result, memory will leak whenever a file is opened for writing
without O_APPEND flag. Also, performance will degrade because TOMOYO is
calculating pathname regardless of profile configuration.
This patch fixes the leak and performance degrade.

Signed-off-by: Tetsuo Handa <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Tetsuo Handa authored and James Morris committed Mar 2, 2011
1 parent 1adace9 commit eae61f3
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions security/tomoyo/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -927,7 +927,7 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
struct path *path, const int flag)
{
const u8 acc_mode = ACC_MODE(flag);
int error = -ENOMEM;
int error = 0;
struct tomoyo_path_info buf;
struct tomoyo_request_info r;
int idx;
Expand All @@ -938,9 +938,6 @@ int tomoyo_check_open_permission(struct tomoyo_domain_info *domain,
buf.name = NULL;
r.mode = TOMOYO_CONFIG_DISABLED;
idx = tomoyo_read_lock();
if (!tomoyo_get_realpath(&buf, path))
goto out;
error = 0;
/*
* If the filename is specified by "deny_rewrite" keyword,
* we need to check "allow_rewrite" permission when the filename is not
Expand Down

0 comments on commit eae61f3

Please sign in to comment.