Smack: handle zero-length security labels without panic
authorKonstantin Khlebnikov <k.khlebnikov@samsung.com>
Thu, 7 Aug 2014 16:52:43 +0000 (20:52 +0400)
committerStephane Desneux <stephane.desneux@open.eurogiciel.org>
Thu, 18 Sep 2014 11:02:54 +0000 (13:02 +0200)
commitae5c52ea68b54756c3211e983ada23169b300474
tree7a9369b81c51df42e558c66aa6b112143dd6e3d1
parent6bbeb11e8fc578a098283670213c890407429588
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: I931735ccfaea4d8d2f0a98eacf8467f0a8359bc6
Signed-off-by: Konstantin Khlebnikov <k.khlebnikov@samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
security/smack/smack_lsm.c
security/smack/smackfs.c