Skip to content

Commit 7d7473d

Browse files
Tetsuo HandaJames Morris
authored andcommitted
TOMOYO: Return error if fails to delete a domain
Call sequence: tomoyo_write_domain() --> tomoyo_delete_domain() In 'tomoyo_delete_domain', return -EINTR if locking attempt is interrupted by signal. At present it returns success to its caller 'tomoyo_write_domain()' even though domain is not deleted. 'tomoyo_write_domain()' assumes domain is deleted and returns success to its caller. This is wrong behaviour. 'tomoyo_write_domain' should return error from tomoyo_delete_domain() to its caller. Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com> Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: James Morris <james.l.morris@oracle.com>
1 parent b01d3fb commit 7d7473d

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

‎security/tomoyo/common.c‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,7 +1069,7 @@ static int tomoyo_write_task(struct tomoyo_acl_param *param)
10691069
*
10701070
* @domainname: The name of domain.
10711071
*
1072-
* Returns 0.
1072+
* Returns 0 on success, negative value otherwise.
10731073
*
10741074
* Caller holds tomoyo_read_lock().
10751075
*/
@@ -1081,7 +1081,7 @@ static int tomoyo_delete_domain(char *domainname)
10811081
name.name = domainname;
10821082
tomoyo_fill_path_info(&name);
10831083
if (mutex_lock_interruptible(&tomoyo_policy_lock))
1084-
return 0;
1084+
return -EINTR;
10851085
/* Is there an active domain? */
10861086
list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
10871087
/* Never delete tomoyo_kernel_domain */
@@ -1164,15 +1164,16 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
11641164
bool is_select = !is_delete && tomoyo_str_starts(&data, "select ");
11651165
unsigned int profile;
11661166
if (*data == '<') {
1167+
int ret = 0;
11671168
domain = NULL;
11681169
if (is_delete)
1169-
tomoyo_delete_domain(data);
1170+
ret = tomoyo_delete_domain(data);
11701171
else if (is_select)
11711172
domain = tomoyo_find_domain(data);
11721173
else
11731174
domain = tomoyo_assign_domain(data, false);
11741175
head->w.domain = domain;
1175-
return 0;
1176+
return ret;
11761177
}
11771178
if (!domain)
11781179
return -EINVAL;

0 commit comments

Comments
 (0)