Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp3354297ybl; Mon, 19 Aug 2019 17:20:57 -0700 (PDT) X-Google-Smtp-Source: APXvYqw4hYkb4gnb9kTssfkcnCUhPB0izmq0m1vtPdTiMna/6Kzrcy/VOVoPq2t2TPB75sHp4pyN X-Received: by 2002:a17:902:f01:: with SMTP id 1mr24516232ply.337.1566260457776; Mon, 19 Aug 2019 17:20:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566260457; cv=none; d=google.com; s=arc-20160816; b=uI0yvFe1mqNxRDOPsOP8Vrayz32z9DbrUKqAm8ka6798bxJIPwDPCXIBQ75ItNDtYW fXnPhCa8rtFQqN0+RiqR7OQfU2l39QnPWemtD07koLzC2wDxA2CGoUhGnVLwkd0gPqkg aBs4CutzFrukL+NH8rakWaiH+FoTpAIs1V+tseQL3EbPsgzhztkSfsUJHwdGUYmBzEav /J6Q9IoP0vxMNna1dAhrSRYR55PHmEjfMpy41+whY0QF+Ywgzrjjbet/2vKr+w0cAOfU U2J7Ox3Drm4blsSmXbdtewpt6THoPCqVLW6nTrMWU7RXW3n869SgSqa2TxcH0X9UeHOO rbzw== 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=B4yWHzIV2L8DYHsuCwQr8Jl+t6iWEiT99YB+g+PxVJ0=; b=BYvoqF0DqLSCzegb5cGY4osSobG5i8oLilNKKNT24Um4XSnPIVuqYrTxvgABchWcrV 2YTCFtS34FYsjH+TynPqcK1wzGvZxkw+G7UuoRrHrid+GMG3Jt0JZ1xJuZ5CSL41UTlC omwNQEGr2/AQzJlU0kRjNSEVAT9SfvNYwbZ8spMn8MPqlpA4eSo4YxfVgStxm+719d/G Ww7zwRc0D0eK4ofvFIa9bUvsOqiCPum7WfpAHuPh3GWHzKdPS8/xckg6Auhl6i2+fdBI YmKNy2ECA7g9QDTKLagtN9GPi2I9mtJ0I09Fzup9/rMNZpG9je71nA7TVwNahRp61997 Dnvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=YkyEhMJN; 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 c130si11800216pfc.103.2019.08.19.17.20.43; Mon, 19 Aug 2019 17:20:57 -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=YkyEhMJN; 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 S1728783AbfHTATc (ORCPT + 99 others); Mon, 19 Aug 2019 20:19:32 -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-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