Skip to content

Commit

Permalink
lockdown: Print current->comm in restriction messages
Browse files Browse the repository at this point in the history
Print the content of current->comm in messages generated by lockdown to
indicate a restriction that was hit.  This makes it a bit easier to find
out what caused the message.

The message now patterned something like:

        Lockdown: <comm>: <what> is restricted; see man kernel_lockdown.7

Signed-off-by: David Howells <[email protected]>
Signed-off-by: Matthew Garrett <[email protected]>
Reviewed-by: Kees Cook <[email protected]>
Signed-off-by: James Morris <[email protected]>
  • Loading branch information
Matthew Garrett authored and James Morris committed Aug 20, 2019
1 parent 1957a85 commit b602614
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 3 additions & 2 deletions fs/proc/kcore.c
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,12 @@ static int open_kcore(struct inode *inode, struct file *filp)
{
int ret = security_locked_down(LOCKDOWN_KCORE);

if (ret)
return ret;
if (!capable(CAP_SYS_RAWIO))
return -EPERM;

if (ret)
return ret;

filp->private_data = kmalloc(PAGE_SIZE, GFP_KERNEL);
if (!filp->private_data)
return -ENOMEM;
Expand Down
8 changes: 6 additions & 2 deletions security/lockdown/lockdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ early_param("lockdown", lockdown_param);
*/
static int lockdown_is_locked_down(enum lockdown_reason what)
{
if (WARN(what >= LOCKDOWN_CONFIDENTIALITY_MAX,
"Invalid lockdown reason"))
return -EPERM;

if (kernel_locked_down >= what) {
if (lockdown_reasons[what])
pr_notice("Lockdown: %s is restricted; see man kernel_lockdown.7\n",
lockdown_reasons[what]);
pr_notice("Lockdown: %s: %s is restricted; see man kernel_lockdown.7\n",
current->comm, lockdown_reasons[what]);
return -EPERM;
}

Expand Down

0 comments on commit b602614

Please sign in to comment.