From: JP Abgrall Date: Sun, 11 Sep 2011 19:13:41 +0000 (-0700) Subject: netfilter: xt_qtaguid: warn only once for missing proc qtaguid data X-Git-Tag: firefly_0821_release~7613^2~318 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=ffebb241e1feefa944283399fe361be78b43bdfe;p=firefly-linux-kernel-4.4.55.git netfilter: xt_qtaguid: warn only once for missing proc qtaguid data When a process doesn't have /dev/xt_qtaguid open, only warn once instead of for every ctrl access. Change-Id: I98a462a8731254ddc3bf6d2fefeef9823659b1f0 Signed-off-by: JP Abgrall --- diff --git a/net/netfilter/xt_qtaguid.c b/net/netfilter/xt_qtaguid.c index dff2ff3fd7cc..66eab3a9c4a4 100644 --- a/net/netfilter/xt_qtaguid.c +++ b/net/netfilter/xt_qtaguid.c @@ -1947,8 +1947,15 @@ static int ctrl_cmd_tag(const char *input) spin_lock_bh(&uid_tag_data_tree_lock); pqd_entry = proc_qtu_data_tree_search( &proc_qtu_data_tree, current->tgid); - /* TODO: remove if() test, do BUG_ON() */ - WARN_ON(IS_ERR_OR_NULL(pqd_entry)); + /* + * TODO: remove if, and start failing. + * At first, we want to catch user-space code that is not + * opening the /dev/xt_qtaguid. + */ + WARN_ONCE(IS_ERR_OR_NULL(pqd_entry), + "qtaguid: User space forgot to open /dev/xt_qtaguid? " + "pid=%u tgid=%u uid=%u\n", + current->pid, current->tgid, current_fsuid()); if (!IS_ERR_OR_NULL(pqd_entry)) { list_add(&sock_tag_entry->list, &pqd_entry->sock_tag_list); @@ -2027,8 +2034,15 @@ static int ctrl_cmd_untag(const char *input) spin_lock_bh(&uid_tag_data_tree_lock); pqd_entry = proc_qtu_data_tree_search( &proc_qtu_data_tree, current->tgid); - /* TODO: remove if() test, do BUG_ON() */ - WARN_ON(IS_ERR_OR_NULL(pqd_entry)); + /* + * TODO: remove if, and start failing. + * At first, we want to catch user-space code that is not + * opening the /dev/xt_qtaguid. + */ + WARN_ONCE(IS_ERR_OR_NULL(pqd_entry), + "qtaguid: User space forgot to open /dev/xt_qtaguid? " + "pid=%u tgid=%u uid=%u\n", + current->pid, current->tgid, current_fsuid()); if (!IS_ERR_OR_NULL(pqd_entry)) list_del(&sock_tag_entry->list); spin_unlock_bh(&uid_tag_data_tree_lock);