Smack: handle zero-length security labels without panic 51/36351/1
authorKonstantin Khlebnikov <k.khlebnikov@samsung.com>
Thu, 7 Aug 2014 16:52:43 +0000 (20:52 +0400)
committerRafal Krypa <r.krypa@samsung.com>
Thu, 5 Mar 2015 12:05:36 +0000 (13:05 +0100)
commitb70fdbd2530dd18e1334ab06b0ab9fefc268a724
tree76dd8682a161f00b2c64bf927d9a420b1b7ceab1
parentfa4c8ed36189c95e2c4c79e08833b9262725e378
Smack: handle zero-length security labels without panic

Zero-length security labels are invalid but kernel should handle them.

This patch fixes kernel panic after setting zero-length security labels:

And after writing zero-length string into smackfs files syslog and onlycp:

The problem is caused by brain-damaged logic in function smk_parse_smack()
which takes pointer to buffer and its length but if length below or equal zero
it thinks that the buffer is zero-terminated. Unfortunately callers of this
function are widely used and proper fix requires serious refactoring.

Change-Id: Icf462c7ac2464d86093fa42a0ed012281b952571
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
security/smack/smack_lsm.c
security/smack/smackfs.c