Smack: fix seq operations in smackfs
authorRafal Krypa <r.krypa@samsung.com>
Fri, 15 May 2015 17:43:33 +0000 (19:43 +0200)
committerSeokYeon Hwang <syeon.hwang@samsung.com>
Wed, 24 Jun 2015 02:52:49 +0000 (11:52 +0900)
commit803a7544a7e36b5e4e978cfa005c638ac32f497a
treef8245f083c06b8bb1c253e76f320b7f2ed580e18
parent691201fdcd1480640cf0a75f05a77e000a0c543a
Smack: fix seq operations in smackfs

Use proper RCU functions and read locking in smackfs seq_operations.

Smack gets away with not using proper RCU functions in smackfs, because
it never removes entries from these lists. But now one list will be
needed (with interface in smackfs) that will have both elements added and
removed to it.
This change will also help any future changes implementing removal of
unneeded entries from other Smack lists.

The patch also fixes handling of pos argument in smk_seq_start and
smk_seq_next. This fixes a bug in case when smackfs is read with a small
buffer:

Kernel panic - not syncing: Kernel mode fault at addr 0xfa0000011b
CPU: 0 PID: 1292 Comm: dd Not tainted 4.1.0-rc1-00012-g98179b8 #13
Stack:
 00000003 0000000d 7ff39e48 7f69fd00
 7ff39ce0 601ae4b0 7ff39d50 600e587b
 00000010 6039f690 7f69fd40 00612003
Call Trace:
 [<601ae4b0>] load2_seq_show+0x19/0x1d
 [<600e587b>] seq_read+0x168/0x331
 [<600c5943>] __vfs_read+0x21/0x101
 [<601a595e>] ? security_file_permission+0xf8/0x105
 [<600c5ec6>] ? rw_verify_area+0x86/0xe2
 [<600c5fc3>] vfs_read+0xa1/0x14c
 [<600c68e2>] SyS_read+0x57/0xa0
 [<6001da60>] handle_syscall+0x60/0x80
 [<6003087d>] userspace+0x442/0x548
 [<6001aa77>] ? interrupt_end+0x0/0x80
 [<6001daae>] ? copy_chunk_to_user+0x0/0x2b
 [<6002cb6b>] ? save_registers+0x1f/0x39
 [<60032ef7>] ? arch_prctl+0xf5/0x170
 [<6001a92d>] fork_handler+0x85/0x87

Change-Id: I032c1fc726c0670060d1cf4c419746257159b499
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
(cherry picked from commit f638effaf324d57f37453e421be87e537140e527)
security/smack/smackfs.c