netlabel: fix a problem when setting bits below the previously lowest bit
authorPaul Moore <pmoore@redhat.com>
Fri, 1 Aug 2014 15:17:03 +0000 (11:17 -0400)
committerBen Hutchings <ben@decadent.org.uk>
Sat, 13 Sep 2014 22:41:42 +0000 (23:41 +0100)
commit33401ce96ad0b9ba39a5aff56ef25c63859f347d
tree6fcba6a98bfebe787192cf0723e3bba302bcfc04
parent908964e5d5b6dd6cfaee838e1bdad0b8f62c7583
netlabel: fix a problem when setting bits below the previously lowest bit

commit 41c3bd2039e0d7b3dc32313141773f20716ec524 upstream.

The NetLabel category (catmap) functions have a problem in that they
assume categories will be set in an increasing manner, e.g. the next
category set will always be larger than the last.  Unfortunately, this
is not a valid assumption and could result in problems when attempting
to set categories less than the startbit in the lowest catmap node.
In some cases kernel panics and other nasties can result.

This patch corrects the problem by checking for this and allocating a
new catmap node instance and placing it at the front of the list.

Reported-by: Christian Evans <frodox@zoho.com>
Signed-off-by: Paul Moore <pmoore@redhat.com>
Tested-by: Casey Schaufler <casey@schaufler-ca.com>
[bwh: Backported to 3.2: adjust filename for SMACK]
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
include/net/netlabel.h
net/ipv4/cipso_ipv4.c
net/netlabel/netlabel_kapi.c
security/smack/smack_lsm.c