Commit f872af75 authored by John Johansen's avatar John Johansen

apparmor: cleanup conditional check for label in label_print

Signed-off-by: default avatarJohn Johansen <john.johansen@canonical.com>
Acked-by: default avatarSeth Arnold <seth.arnold@canonical.com>
parent 2ea3ffb7
...@@ -1450,9 +1450,11 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp) ...@@ -1450,9 +1450,11 @@ bool aa_update_label_name(struct aa_ns *ns, struct aa_label *label, gfp_t gfp)
* cached label name is present and visible * cached label name is present and visible
* @label->hname only exists if label is namespace hierachical * @label->hname only exists if label is namespace hierachical
*/ */
static inline bool use_label_hname(struct aa_ns *ns, struct aa_label *label) static inline bool use_label_hname(struct aa_ns *ns, struct aa_label *label,
int flags)
{ {
if (label->hname && labels_ns(label) == ns) if (label->hname && (!ns || labels_ns(label) == ns) &&
!(flags & ~FLAG_SHOW_MODE))
return true; return true;
return false; return false;
...@@ -1710,10 +1712,8 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns, ...@@ -1710,10 +1712,8 @@ void aa_label_xaudit(struct audit_buffer *ab, struct aa_ns *ns,
AA_BUG(!ab); AA_BUG(!ab);
AA_BUG(!label); AA_BUG(!label);
if (!ns) if (!use_label_hname(ns, label, flags) ||
ns = labels_ns(label); display_mode(ns, label, flags)) {
if (!use_label_hname(ns, label) || display_mode(ns, label, flags)) {
len = aa_label_asxprint(&name, ns, label, flags, gfp); len = aa_label_asxprint(&name, ns, label, flags, gfp);
if (len == -1) { if (len == -1) {
AA_DEBUG("label print error"); AA_DEBUG("label print error");
...@@ -1738,10 +1738,7 @@ void aa_label_seq_xprint(struct seq_file *f, struct aa_ns *ns, ...@@ -1738,10 +1738,7 @@ void aa_label_seq_xprint(struct seq_file *f, struct aa_ns *ns,
AA_BUG(!f); AA_BUG(!f);
AA_BUG(!label); AA_BUG(!label);
if (!ns) if (!use_label_hname(ns, label, flags)) {
ns = labels_ns(label);
if (!use_label_hname(ns, label)) {
char *str; char *str;
int len; int len;
...@@ -1764,10 +1761,7 @@ void aa_label_xprintk(struct aa_ns *ns, struct aa_label *label, int flags, ...@@ -1764,10 +1761,7 @@ void aa_label_xprintk(struct aa_ns *ns, struct aa_label *label, int flags,
{ {
AA_BUG(!label); AA_BUG(!label);
if (!ns) if (!use_label_hname(ns, label, flags)) {
ns = labels_ns(label);
if (!use_label_hname(ns, label)) {
char *str; char *str;
int len; int len;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment