* [PATCH] TOMOYO: Return error if fails to delete a domain.
@ 2012-03-16 18:55 santosh nayak
2012-03-18 14:29 ` walter harms
0 siblings, 1 reply; 3+ messages in thread
From: santosh nayak @ 2012-03-16 18:55 UTC (permalink / raw)
To: takedakn
Cc: penguin-kernel, james.l.morris, linux-security-module,
linux-kernel, kernel-janitors, Santosh Nayak
From: Santosh Nayak <santoshprasadnayak@gmail.com>
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 '-EAGAIN' to its caller if
tomoyo_delete_domain() returns -EINTR.
Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
security/tomoyo/common.c | 12 ++++++++----
1 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index c47d3ce..3ee1c3a 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -1081,7 +1081,7 @@ static int tomoyo_delete_domain(char *domainname)
name.name = domainname;
tomoyo_fill_path_info(&name);
if (mutex_lock_interruptible(&tomoyo_policy_lock))
- return 0;
+ return -EINTR;
/* Is there an active domain? */
list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
/* Never delete tomoyo_kernel_domain */
@@ -1163,16 +1163,20 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
const bool is_delete = head->w.is_delete;
bool is_select = !is_delete && tomoyo_str_starts(&data, "select ");
unsigned int profile;
+ int ret = 0;
if (*data == '<') {
domain = NULL;
- if (is_delete)
- tomoyo_delete_domain(data);
+ if (is_delete) {
+ ret = tomoyo_delete_domain(data);
+ if (ret)
+ return -EAGAIN;
+ }
else if (is_select)
domain = tomoyo_find_domain(data);
else
domain = tomoyo_assign_domain(data, false);
head->w.domain = domain;
- return 0;
+ return ret;
}
if (!domain)
return -EINVAL;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] TOMOYO: Return error if fails to delete a domain.
2012-03-16 18:55 [PATCH] TOMOYO: Return error if fails to delete a domain santosh nayak
@ 2012-03-18 14:29 ` walter harms
0 siblings, 0 replies; 3+ messages in thread
From: walter harms @ 2012-03-18 14:29 UTC (permalink / raw)
To: santosh nayak
Cc: takedakn, penguin-kernel, james.l.morris, linux-security-module,
linux-kernel, kernel-janitors
Am 16.03.2012 19:55, schrieb santosh nayak:
> From: Santosh Nayak <santoshprasadnayak@gmail.com>
>
> 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 '-EAGAIN' to its caller if
> tomoyo_delete_domain() returns -EINTR.
>
> Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
> ---
> security/tomoyo/common.c | 12 ++++++++----
> 1 files changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
> index c47d3ce..3ee1c3a 100644
> --- a/security/tomoyo/common.c
> +++ b/security/tomoyo/common.c
> @@ -1081,7 +1081,7 @@ static int tomoyo_delete_domain(char *domainname)
> name.name = domainname;
> tomoyo_fill_path_info(&name);
> if (mutex_lock_interruptible(&tomoyo_policy_lock))
> - return 0;
> + return -EINTR;
> /* Is there an active domain? */
> list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
> /* Never delete tomoyo_kernel_domain */
> @@ -1163,16 +1163,20 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
> const bool is_delete = head->w.is_delete;
> bool is_select = !is_delete && tomoyo_str_starts(&data, "select ");
> unsigned int profile;
> + int ret = 0;
> if (*data == '<') {
> domain = NULL;
> - if (is_delete)
> - tomoyo_delete_domain(data);
> + if (is_delete) {
> + ret = tomoyo_delete_domain(data);
> + if (ret)
> + return -EAGAIN;
> + }
> else if (is_select)
> domain = tomoyo_find_domain(data);
> else
> domain = tomoyo_assign_domain(data, false);
> head->w.domain = domain;
> - return 0;
> + return ret;
hi all,
does domain anything useful here ?
re,
wh
> }
> if (!domain)
> return -EINVAL;
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH] TOMOYO: Return error if fails to delete a domain.
@ 2012-03-18 2:07 santosh nayak
0 siblings, 0 replies; 3+ messages in thread
From: santosh nayak @ 2012-03-18 2:07 UTC (permalink / raw)
To: takedakn
Cc: penguin-kernel, james.l.morris, linux-security-module,
linux-kernel, kernel-janitors, Santosh Nayak
From: Santosh Nayak <santoshprasadnayak@gmail.com>
'tomoyo_write_domain' should return error from tomoyo_delete_domain()
to its caller.
Signed-off-by: Santosh Nayak <santoshprasadnayak@gmail.com>
---
security/tomoyo/common.c | 7 ++++---
1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/security/tomoyo/common.c b/security/tomoyo/common.c
index c47d3ce..d13b9a7 100644
--- a/security/tomoyo/common.c
+++ b/security/tomoyo/common.c
@@ -1081,7 +1081,7 @@ static int tomoyo_delete_domain(char *domainname)
name.name = domainname;
tomoyo_fill_path_info(&name);
if (mutex_lock_interruptible(&tomoyo_policy_lock))
- return 0;
+ return -EINTR;
/* Is there an active domain? */
list_for_each_entry_rcu(domain, &tomoyo_domain_list, list) {
/* Never delete tomoyo_kernel_domain */
@@ -1164,15 +1164,16 @@ static int tomoyo_write_domain(struct tomoyo_io_buffer *head)
bool is_select = !is_delete && tomoyo_str_starts(&data, "select ");
unsigned int profile;
if (*data == '<') {
+ int ret = 0;
domain = NULL;
if (is_delete)
- tomoyo_delete_domain(data);
+ ret = tomoyo_delete_domain(data);
else if (is_select)
domain = tomoyo_find_domain(data);
else
domain = tomoyo_assign_domain(data, false);
head->w.domain = domain;
- return 0;
+ return ret;
}
if (!domain)
return -EINVAL;
--
1.7.4.4
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-03-18 14:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-16 18:55 [PATCH] TOMOYO: Return error if fails to delete a domain santosh nayak
2012-03-18 14:29 ` walter harms
-- strict thread matches above, loose matches on Subject: below --
2012-03-18 2:07 santosh nayak
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox