Smack: unify all ptrace accesses in the smack 91/31091/1
authorLukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Tue, 11 Mar 2014 16:07:05 +0000 (17:07 +0100)
committerZbigniew Jasinski <z.jasinski@samsung.com>
Fri, 28 Nov 2014 09:35:40 +0000 (10:35 +0100)
commitc6a6778bf7cf17b5c1094d2304c42256e3209b41
tree6e7fbfd4a8881a52de4418d5c533033040761cd8
parent52a45e7150dd3f89afb26dcb05e554cf5557a46f
Smack: unify all ptrace accesses in the smack

The decision whether we can trace a process is made in the following
functions:
smack_ptrace_traceme()
smack_ptrace_access_check()
smack_bprm_set_creds() (in case the proces is traced)

This patch unifies all those decisions by introducing one function that
checks whether ptrace is allowed: smk_ptrace_rule_check().

This makes possible to actually trace with TRACEME where first the
TRACEME itself must be allowed and then exec() on a traced process.

Additional bugs fixed:
- The decision is made according to the mode parameter that is now correctly
  translated from PTRACE_MODE_* to MAY_* instead of being treated 1:1.
  PTRACE_MODE_READ requires MAY_READ.
  PTRACE_MODE_ATTACH requires MAY_READWRITE.
- Add a smack audit log in case of exec() refused by bprm_set_creds().
- Honor the PTRACE_MODE_NOAUDIT flag and don't put smack audit info
  in case this flag is set.

Change-Id: I43d82d480f331e8ef90da7c287b1e414d55ff394
Signed-off-by: Lukasz Pawelczyk <l.pawelczyk@partner.samsung.com>
Signed-off-by: Rafal Krypa <r.krypa@samsung.com>
security/smack/smack_lsm.c