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>
Tue, 25 Nov 2014 09:08:34 +0000 (10:08 +0100)
commitbc71ad29132e6774789de28eda50693be0beeef0
tree06334ee51c527792d0278020d0a39f372c402eb6
parentf57b7f5bb1c2d7d1fa93a807f3290eae2514ab3f
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