<div dir="ltr"><div>I wonder if this patch should be applied or not,to 3.14 kernel (14.04LTS, Trusty)</div><div><div>/kernel-patches/3.6/0006-apparmor-fix-IRQ-stack-overflow-during-free_profile.patch</div></div><div>=================================</div><div>From 663d5bbe6197bf990721c37ec877ea8ba5840202 Mon Sep 17 00:00:00 2001<br></div><div><div>From: John Johansen <<a href="mailto:john.johansen@canonical.com">john.johansen@canonical.com</a>></div><div>Date: Wed, 24 Oct 2012 06:27:32 -0700</div><div>Subject: [PATCH 6/6] apparmor: fix IRQ stack overflow during free_profile</div><div><br></div><div>BugLink: <a href="http://bugs.launchpad.net/bugs/1056078">http://bugs.launchpad.net/bugs/1056078</a></div></div><div>=================================</div><div>It patches to security/apparmor/policy.c free_profile()</div><div>and pointer mismatch in for loop statement in 3.14kernel (Trusty)</div><div>   // for (p = profile->replacedby; p; ) <br></div><div>p points to aa_profile,but profile->replacedby points to different structure which has "kref count" element.</div><div>===============================<br></div><div><div>security/apparmor/include/policy.h</div><div>struct aa_replacedby {</div><div>    struct kref count;</div><div>    struct aa_profile __rcu *profile;</div><div>};</div><div><br></div><div>struct aa_profile {</div><div>    struct aa_policy base;</div><div>    struct kref count;</div><div>    struct rcu_head rcu;</div><div>    struct aa_profile __rcu *parent;</div><div><br></div><div>    struct aa_namespace *ns;</div><div>    struct aa_replacedby *replacedby;</div><div>    const char *rename;</div><div><br></div><div><br></div><div>security/apparmor/policy.c</div><div>void aa_free_profile(struct aa_profile *profile)</div><div>{</div><div><span class="" style="white-space:pre">      </span>struct aa_profile *p;</div><div><br></div><div><br></div><div>/* put the profile reference for replacedby, but not via</div><div>     * put_profile(kref_put).</div><div>     * replacedby can form a long chain that can result in cascading</div><div>     * frees that blows the stack because kref_put makes a nested fn</div><div>     * call (it looks like recursion, with free_profile calling</div><div>     * free_profile) for each profile in the chain lp#1056078.</div><div>     */</div><div>    for (p = profile->replacedby; p; ) {</div><div>        if (atomic_dec_and_test(&p->base.count.refcount)) {</div><div>            /* no more refs on p, grab its replacedby */</div><div>            struct aa_profile *next = p->replacedby;</div></div><div><br></div></div>