Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp6090929ybh; Wed, 7 Aug 2019 17:11:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqxW5IQ4xxzuqzUZ5mqohk65lkyQOAWvqPWe0hjr30qMXYtC/xFBqbW6/cATmA5z2Z00EPLv X-Received: by 2002:a17:90a:ab0d:: with SMTP id m13mr1005787pjq.84.1565223071643; Wed, 07 Aug 2019 17:11:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565223071; cv=none; d=google.com; s=arc-20160816; b=eu2OoKkL50FRyk6Nq6XtS3qbksikwF0qNmF1QhJvEs/d0r+k9yjMCEBsklaBm6YiYF MAktGaLFb4iKBlzLKGT9FtRSIw8ezCBQlvc2Yo4yiogj9P4itWK96XwDTJ4UsipLQ+uf jVwqwZyEEdfJJZIvMsMjujKry6zn3veoG6cPqp1h+D0kgy0OhCKnX2QzYycjXGELeq4U HqZkjJHivlZCSuAvP3AypwWc45pp+T2pZIctG//6b/SaFT/nn2+UCGF+nUxa4pWmh3u3 vsESY6ggOe1fOcrJfdGwhfPVGpsOFsD952ZgfDq3gQyeyZ4qh2S5KxwBDW3TV7y3mCSZ suJg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:from:subject:references :mime-version:message-id:in-reply-to:date:dkim-signature; bh=QAOtO6nDHkYJ9N49TmHslQT3rCi9zyycpSkmU2B1+ww=; b=s9EqlOBr7qcQD05cNGCi5BLRXmMDs0ywKJzwMyRTRWqy95HNo3ek7hsnPVoLF49rR5 IfRplQwn3FN+8pu1GK2OR3vVWYvN8omT6DXc3kCR38uAsGcXBD/hcPz25R3nGMS/Exr8 iOuslz7kvU5q+06TqJS8pLXQ5EA9ozxRfRYxyeBxMjKSGznkPLIvbowMuILj20jQJdZ+ kj8jvF5DzDL92ny1iZl1Hd8hOVaUbOe15W2TlXqOFWUWDCNn24OyYGjWY1Yl7sEk6fAw zHxb1aQl+8UxtVg/KKPqqyBTuHujarqCjZv6CTfrKoDdPtX6b6Hqin6cxuVnHf/6a7pT 4uOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UNLABroC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j6si54676651pgb.206.2019.08.07.17.10.56; Wed, 07 Aug 2019 17:11:11 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=UNLABroC; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389812AbfHHAIp (ORCPT + 99 others); Wed, 7 Aug 2019 20:08:45 -0400 Received: from mail-vs1-f73.google.com ([209.85.217.73]:37105 "EHLO mail-vs1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389799AbfHHAIl (ORCPT ); Wed, 7 Aug 2019 20:08:41 -0400 Received: by mail-vs1-f73.google.com with SMTP id a23so23649863vsn.4 for ; Wed, 07 Aug 2019 17:08:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=date:in-reply-to:message-id:mime-version:references:subject:from:to :cc; bh=QAOtO6nDHkYJ9N49TmHslQT3rCi9zyycpSkmU2B1+ww=; b=UNLABroCADTP2lRj6WXK9ks7taxeIwX7apuvzgPN+SSwyiYIw9M1JIzQ11nyWkr0nd auaYOQ96K8A0C0wqBYZCk6v/qae3ZfIDiK9ohFw5VtmeInfKk59XHKLlBAt9DK9be9i+ tpzkvCxKDCRl7CLtKUQCWMv7CUS4Bmn8X2YGeTODNSEntx/U2+iFxrdNvFbqFnoA0BSR 6AUjALIVdmgdrJgYCIWuF4TmYaaleMsMU7Ms5sj4SqsBR0z+IlFpl8lnvR704dPIHUIM qqfSk7DFKViWyjwwFsEexIFGPBohDz9s+Vm/G3LYfBQnH9eTHKFqTKOZVSsgutOdjC2R b4Nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=QAOtO6nDHkYJ9N49TmHslQT3rCi9zyycpSkmU2B1+ww=; b=WN5raiDWnqDbDVJxdwborWMWgVNkRyjicaUZuWSC9yLWrP6cTy89W5AfuBrJZsxITB 1nzfPpWyuUO6hcEmVCwJgqDRdFo9SK5u11ltV0UpB57VVMLLEs9Oj9VTHxkZ1VdKvxX4 zh81s57cd2I/Za4lSyJ+Qyuj6+7S7P0PuLC3XebyJxoJcq/UHRb53OsK8TGW6lla+xEv b/YM8v9NWw9yICMY9x3uturE4t8CE32X8675dzmd0j0mGTFVfBnsy1NB9aa4BEYczVG2 gM3Dl7BKt5kwBCt9NQFCC36CpOLBN+aXWUjJPX2BYShAIyPlKAemPcF545mqNX4YpP49 vVLg== X-Gm-Message-State: APjAAAXowqa3cGpXFTUpR/H38Acr25/i47WJ/yQelbWJxlZ1GU4nFgky u34i85aVzN8lCdrNMQCbVU7QpaBih1dMrg/EVCp3VQ== X-Received: by 2002:a1f:2242:: with SMTP id i63mr4639075vki.69.1565222919839; Wed, 07 Aug 2019 17:08:39 -0700 (PDT) Date: Wed, 7 Aug 2019 17:07:21 -0700 In-Reply-To: <20190808000721.124691-1-matthewgarrett@google.com> Message-Id: <20190808000721.124691-30-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190808000721.124691-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V38 29/29] lockdown: Print current->comm in restriction messages From: Matthew Garrett To: jmorris@namei.org Cc: linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org, linux-api@vger.kernel.org, Matthew Garrett , David Howells , Matthew Garrett , Kees Cook Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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: : is restricted; see man kernel_lockdown.7 Signed-off-by: David Howells Signed-off-by: Matthew Garrett Reviewed-by: Kees Cook --- fs/proc/kcore.c | 5 +++-- security/lockdown/lockdown.c | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/fs/proc/kcore.c b/fs/proc/kcore.c index ee2c576cc94e..e2ed8e08cc7a 100644 --- a/fs/proc/kcore.c +++ b/fs/proc/kcore.c @@ -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; diff --git a/security/lockdown/lockdown.c b/security/lockdown/lockdown.c index 173191562047..f6c74cf6a798 100644 --- a/security/lockdown/lockdown.c +++ b/security/lockdown/lockdown.c @@ -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; } -- 2.22.0.770.g0f2c4a37fd-goog