* [PATCH] security: tomoyo: fix error return code of tomoyo_update_domain()
@ 2021-03-06 13:03 Jia-Ju Bai
2021-03-06 13:37 ` Tetsuo Handa
0 siblings, 1 reply; 2+ messages in thread
From: Jia-Ju Bai @ 2021-03-06 13:03 UTC (permalink / raw)
To: takedakn, penguin-kernel, jmorris, serge
Cc: linux-security-module, linux-kernel, Jia-Ju Bai
When mutex_lock_interruptible() fails, the error return code of
tomoyo_update_domain() is not properly assigned.
To fix this bug, error is assigned with the return value of
mutex_lock_interruptible(), and then error is checked.
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
---
security/tomoyo/domain.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/security/tomoyo/domain.c b/security/tomoyo/domain.c
index 98d985895ec8..7b9f9664dbe3 100644
--- a/security/tomoyo/domain.c
+++ b/security/tomoyo/domain.c
@@ -118,7 +118,8 @@ int tomoyo_update_domain(struct tomoyo_acl_info *new_entry, const int size,
->perm == 1 << TOMOYO_TYPE_EXECUTE))
goto out;
}
- if (mutex_lock_interruptible(&tomoyo_policy_lock))
+ error = mutex_lock_interruptible(&tomoyo_policy_lock);
+ if (error)
goto out;
list_for_each_entry_rcu(entry, list, list,
srcu_read_lock_held(&tomoyo_ss)) {
--
2.17.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] security: tomoyo: fix error return code of tomoyo_update_domain()
2021-03-06 13:03 [PATCH] security: tomoyo: fix error return code of tomoyo_update_domain() Jia-Ju Bai
@ 2021-03-06 13:37 ` Tetsuo Handa
0 siblings, 0 replies; 2+ messages in thread
From: Tetsuo Handa @ 2021-03-06 13:37 UTC (permalink / raw)
To: Jia-Ju Bai; +Cc: linux-security-module, linux-kernel, jmorris, serge
On 2021/03/06 22:03, Jia-Ju Bai wrote:
> When mutex_lock_interruptible() fails, the error return code of
> tomoyo_update_domain() is not properly assigned.
> To fix this bug, error is assigned with the return value of
> mutex_lock_interruptible(), and then error is checked.
Thanks for a patch, but this patch is wrong.
Since the variable "error" is initialized as
int error = is_delete ? -ENOENT : -ENOMEM;
at the beginning of this function, unconditionally overwriting
this variable with the return code of mutex_lock_interruptible() breaks
if (error && !is_delete) {
}
block of this function.
And the caller does not check if the return code is -EINTR
instead of -ENOENT or -ENOMEM.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2021-03-06 13:39 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-06 13:03 [PATCH] security: tomoyo: fix error return code of tomoyo_update_domain() Jia-Ju Bai
2021-03-06 13:37 ` Tetsuo Handa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).