Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1201072 > unrolled thread

[PATCH V6] audit: save signal match info in case entry passed in is the one deleted

Started byRichard Guy Briggs <rgb@redhat.com>
First post2015-08-05 21:30 +0200
Last post2015-08-06 00:00 +0200
Articles 2 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH V6] audit: save signal match info in case entry passed in is the one deleted Richard Guy Briggs <rgb@redhat.com> - 2015-08-05 21:30 +0200
    Re: [PATCH V6] audit: save signal match info in case entry passed in is the one deleted Paul Moore <pmoore@redhat.com> - 2015-08-06 00:00 +0200

#1201072 — [PATCH V6] audit: save signal match info in case entry passed in is the one deleted

FromRichard Guy Briggs <rgb@redhat.com>
Date2015-08-05 21:30 +0200
Subject[PATCH V6] audit: save signal match info in case entry passed in is the one deleted
Message-ID<pUcxY-2g8-13@gated-at.bofh.it>
Move the access to the entry for audit_match_signal() to earlier in the
function in case the entry found is the same one passed in.  This will enable
it to be used by audit_remove_mark_rule().

Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
---
Revision history:
v6:
    Fix a rebase manual merge error that mixed parts of two patches.

v4 -> v5:
    Move mutex_unlock after out label.
    Move list_del group after test for signal to remove temp variable.

---
This patch was split out from the audit by executable path patch set due to the
potential to use it elsewhere.

In particular, some questions came up while assessing the potential for code
reuse:

	Why does audit_remove_parent_watches() not call audit_del_rule() for
	each entry found?
                Is audit_signals not properly decremented?
                Is audit_n_rules not properly decremented?

        Why does kill_rules() not call audit_del_rule() for each entry found?
                Is audit_signals not properly decremented?
                Is audit_n_rules not properly decremented?
 kernel/auditfilter.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
index 4cb9b44..018719a 100644
--- a/kernel/auditfilter.c
+++ b/kernel/auditfilter.c
@@ -953,7 +953,6 @@ static inline int audit_del_rule(struct audit_entry *entry)
 	mutex_lock(&audit_filter_mutex);
 	e = audit_find_rule(entry, &list);
 	if (!e) {
-		mutex_unlock(&audit_filter_mutex);
 		ret = -ENOENT;
 		goto out;
 	}
@@ -964,10 +963,6 @@ static inline int audit_del_rule(struct audit_entry *entry)
 	if (e->rule.tree)
 		audit_remove_tree_rule(&e->rule);
 
-	list_del_rcu(&e->list);
-	list_del(&e->rule.list);
-	call_rcu(&e->rcu, audit_free_rule_rcu);
-
 #ifdef CONFIG_AUDITSYSCALL
 	if (!dont_count)
 		audit_n_rules--;
@@ -975,9 +970,14 @@ static inline int audit_del_rule(struct audit_entry *entry)
 	if (!audit_match_signal(entry))
 		audit_signals--;
 #endif
-	mutex_unlock(&audit_filter_mutex);
+
+	list_del_rcu(&e->list);
+	list_del(&e->rule.list);
+	call_rcu(&e->rcu, audit_free_rule_rcu);
 
 out:
+	mutex_unlock(&audit_filter_mutex);
+
 	if (tree)
 		audit_put_tree(tree);	/* that's the temporary one */
 
-- 
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [next] | [standalone]


#1201207

FromPaul Moore <pmoore@redhat.com>
Date2015-08-06 00:00 +0200
Message-ID<pUeTb-5wN-81@gated-at.bofh.it>
In reply to#1201072
On Wednesday, August 05, 2015 03:23:09 PM Richard Guy Briggs wrote:
> Move the access to the entry for audit_match_signal() to earlier in the
> function in case the entry found is the same one passed in.  This will
> enable it to be used by audit_remove_mark_rule().
> 
> Signed-off-by: Richard Guy Briggs <rgb@redhat.com>
> ---
> Revision history:
> v6:
>     Fix a rebase manual merge error that mixed parts of two patches.
> 
> v4 -> v5:
>     Move mutex_unlock after out label.
>     Move list_del group after test for signal to remove temp variable.
> 
> ---
> This patch was split out from the audit by executable path patch set due to
> the potential to use it elsewhere.
> 
> In particular, some questions came up while assessing the potential for code
> reuse:
> 
> 	Why does audit_remove_parent_watches() not call audit_del_rule() for
> 	each entry found?
>                 Is audit_signals not properly decremented?
>                 Is audit_n_rules not properly decremented?
> 
>         Why does kill_rules() not call audit_del_rule() for each entry
> found? Is audit_signals not properly decremented?
>                 Is audit_n_rules not properly decremented?
>  kernel/auditfilter.c |   12 ++++++------
>  1 files changed, 6 insertions(+), 6 deletions(-)

Much better :)  Applied.

FYI, I did change the subject line as it didn't make sense any more.

> diff --git a/kernel/auditfilter.c b/kernel/auditfilter.c
> index 4cb9b44..018719a 100644
> --- a/kernel/auditfilter.c
> +++ b/kernel/auditfilter.c
> @@ -953,7 +953,6 @@ static inline int audit_del_rule(struct audit_entry
> *entry) mutex_lock(&audit_filter_mutex);
>  	e = audit_find_rule(entry, &list);
>  	if (!e) {
> -		mutex_unlock(&audit_filter_mutex);
>  		ret = -ENOENT;
>  		goto out;
>  	}
> @@ -964,10 +963,6 @@ static inline int audit_del_rule(struct audit_entry
> *entry) if (e->rule.tree)
>  		audit_remove_tree_rule(&e->rule);
> 
> -	list_del_rcu(&e->list);
> -	list_del(&e->rule.list);
> -	call_rcu(&e->rcu, audit_free_rule_rcu);
> -
>  #ifdef CONFIG_AUDITSYSCALL
>  	if (!dont_count)
>  		audit_n_rules--;
> @@ -975,9 +970,14 @@ static inline int audit_del_rule(struct audit_entry
> *entry) if (!audit_match_signal(entry))
>  		audit_signals--;
>  #endif
> -	mutex_unlock(&audit_filter_mutex);
> +
> +	list_del_rcu(&e->list);
> +	list_del(&e->rule.list);
> +	call_rcu(&e->rcu, audit_free_rule_rcu);
> 
>  out:
> +	mutex_unlock(&audit_filter_mutex);
> +
>  	if (tree)
>  		audit_put_tree(tree);	/* that's the temporary one */

-- 
paul moore
security @ redhat

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web