]> git.baikalelectronics.ru Git - kernel.git/commit
apparmor: only get a label reference if the fast path check fails
authorJohn Johansen <john.johansen@canonical.com>
Wed, 18 Dec 2019 19:04:07 +0000 (11:04 -0800)
committerJohn Johansen <john.johansen@canonical.com>
Thu, 2 Jan 2020 13:31:40 +0000 (05:31 -0800)
commitdd1e4f2a37a36022c2ed3ac8cb2259d9e91aed34
treec740dec5f800df330c303db8018620b8bb0371f1
parent3034b5031f5ed0f61d3faf268bbe4f65769b8615
apparmor: only get a label reference if the fast path check fails

The common fast path check can be done under rcu_read_lock() and
doesn't need a reference count on the label. Only take a reference
count if entering the slow path.

Fixes reported hackbench regression
  - sha1 7b789d014684 ("Merge tag 'apparmor-pr-2019-12-03' of
    git://git.kernel.org/pub/scm/linux/kernel/git/jj/linux-apparmor")

  hackbench -l (256000/#grp) -g #grp
   128 groups     19.679 ±0.90%

  - previous sha1 ba1271f3f2fc ("Merge tag 's390-5.5-2' of
    git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux")

  hackbench -l (256000/#grp) -g #grp
   128 groups     3.1689 ±3.04%

Reported-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Vincent Guittot <vincent.guittot@linaro.org>
Tested-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Fixes: 65ef3c11e549 ("apparmor: reduce rcu_read_lock scope for aa_file_perm mediation")
Signed-off-by: John Johansen <john.johansen@canonical.com>
security/apparmor/file.c