From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.4 required=3.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT,USER_IN_DEF_DKIM_WL autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 46982C3A5A0 for ; Tue, 20 Aug 2019 00:19:35 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1383E2087E for ; Tue, 20 Aug 2019 00:19:35 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="YkyEhMJN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728782AbfHTATd (ORCPT ); Mon, 19 Aug 2019 20:19:33 -0400 Received: from mail-qk1-f201.google.com ([209.85.222.201]:34765 "EHLO mail-qk1-f201.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729214AbfHTAT0 (ORCPT ); Mon, 19 Aug 2019 20:19:26 -0400 Received: by mail-qk1-f201.google.com with SMTP id s23so5240423qkg.1 for ; Mon, 19 Aug 2019 17:19:25 -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=B4yWHzIV2L8DYHsuCwQr8Jl+t6iWEiT99YB+g+PxVJ0=; b=YkyEhMJNW5K8R8PGvqzm9AWtlOyUSRLd1552j5/1Nm456iPghSLb/0BGVlLwy4pBPB WEtFg0QKJbHgxQihV165tQFP4cdLcCGCJTIDnKhXi0DjmrB10qp+mDKdIh1Nnv94Zsb7 qlxFB+LHHqQWKvWojIwxMD4YQ1VNYJ2V+LG+hgH+B2vlrNowxGZsZlM34gkObf9qdec8 ustXl5GlfBfNUdLqDIj7IuLlXQB1fmBFvWZ69L3+5k4d+Uh0nYFFEkHhgBOeCAtZadAh YDjS5hZrESKmm7hxWkAwusWP1vUf31Hmn3FYxMsM6qYGW1+SjfuNDlzRIo8RcXG9o2qx tSuA== 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=B4yWHzIV2L8DYHsuCwQr8Jl+t6iWEiT99YB+g+PxVJ0=; b=qHyeDFsv4iolMZjp4MaXiK283yxoXiMDh/LOpXnBC6FUl/uVCDAZS1V8ILGP1mn+xr wvNl8qzYjrcBc5pLhtq/f5/PxOzLBl2pvu8aLG+ffYngP5kB0hZdTiZg7S8krw597p1v GVstSeaRQnU3mzLV8g03e/Sv/mlE5Wq0onQ5nIQlznBuaumcAGoUwucGJm0nw443Fyk+ kNmULzAFuKNwbb7UPhXXtIEsDAWpRcoCC0cyGhdKF3aiCgboSEUHEA+2bk+IO6mrPV29 GPZVjGqLTqo1/374mYOGGlfbq2Sgkr00yAE9KFokzqwbs1WPLM/F/2VxgljUkvPuBO1S MABQ== X-Gm-Message-State: APjAAAW1mplZbHj4NijA5xb1FERgHt8bveYacC1JmPa1nQKBpqwuQ5w0 uIcBjJIvuFLR9d32LytzzjNiBRaC3i2/qJIEoB3ToA== X-Google-Smtp-Source: APXvYqwEaH4FBHYim7pgk+R5Iwed9VyMLH25KCU7dENXN+SBUFaYCAKLKWmdC4e7U/qAeMMI0Dc/WvpzBOJkvqdO5dTPTw== X-Received: by 2002:a05:620a:64c:: with SMTP id a12mr23678733qka.391.1566260365395; Mon, 19 Aug 2019 17:19:25 -0700 (PDT) Date: Mon, 19 Aug 2019 17:18:05 -0700 In-Reply-To: <20190820001805.241928-1-matthewgarrett@google.com> Message-Id: <20190820001805.241928-30-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190820001805.241928-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.23.0.rc1.153.gdeed80330f-goog Subject: [PATCH V40 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 Signed-off-by: James Morris --- 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 84df03b1f5a7..0068cec77c05 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.23.0.rc1.153.gdeed80330f-goog