Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp6610602ybi; Wed, 31 Jul 2019 17:59:49 -0700 (PDT) X-Google-Smtp-Source: APXvYqzZnfOYJ6TPQ+OF7MpsscgyUCoGcJ6dIL2lw6W7Ga85N1/xYOzh5TXJZswzn0bOBHK4S78m X-Received: by 2002:a62:e801:: with SMTP id c1mr50694341pfi.41.1564621189617; Wed, 31 Jul 2019 17:59:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564621189; cv=none; d=google.com; s=arc-20160816; b=GJEjo3HQNGM+2qnSGHtFtVmsaoEAQNI76ckVzbQcgzg/G45TXkAT1psbIrX+3ABUsC WO6EN9kRmBIED6tI8hnZMDgbJZ0hOBg+qvtfa+MTNYVqr38LqA/GQ4rrYj4qL/IQtqip Fo0LySODXrfetxZyfEPnYM9l2fKQEx+BnGLILqwjXI6aJCYgHq0559BVIwpZCgsT+uz5 njadxeQEO2rl1Ffy/nCUTzZIZ30rFhHO2ZL5DXXXzkNH5ASJPIP4TGRHY3kKJ9HvLH8z 1d05NTufvOACV6i9WVaBfSMfdcMYFbB92pMItHqAi86xZ+9IRgDemicR/Z2iI7uN3U/8 gXyA== 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=WSBlXKye8Bmutc5h07+RSha8urE+qFDZSeD+ZZLDfs0q9rrBzKba/WV6ddvP5uq1ot sO95BEYb7kS2o4TDApyaTyGwFvjT5tZlsanTuiCUn8P+oXMqzSPll3DqIzQMRKvNyqfv R0g3PP521S3Y8PaGTr+X4p+ue0z4yfTtbhO6oEqtkCX+qYqYfBEMMGUFZuEX6xN1opK5 Se/HN+AUG0y29+Ib6292SjuDipJr8BW9qWf2nkOvdgelbW5CCgKWrYpMKUWRu8Z2sef2 V9Az89tCekaFg5zLRHL2MTd0kdlMnBq4RG6y7KWhzeQj24xqC32dveaNDJsX5kd1CR8f o2xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="vsBNHav/"; 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 o6si39872993pfb.230.2019.07.31.17.59.34; Wed, 31 Jul 2019 17:59:49 -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="vsBNHav/"; 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 S1731467AbfGaWSB (ORCPT + 99 others); Wed, 31 Jul 2019 18:18:01 -0400 Received: from mail-vs1-f73.google.com ([209.85.217.73]:52555 "EHLO mail-vs1-f73.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731441AbfGaWRl (ORCPT ); Wed, 31 Jul 2019 18:17:41 -0400 Received: by mail-vs1-f73.google.com with SMTP id g189so18238749vsc.19 for ; Wed, 31 Jul 2019 15:17:41 -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=vsBNHav/9gjDzuC/p4k/ehf5+i2a6WpWSYUinwPcIuMUWwom487dxrSyQaeEFjlILD GuWeQYzRIr7AcvrVQ6N9OjJnHtUFW82QbCHblLe/DE5ZDgEbMkl9yz0XaBQlkK3hIrhE CRaE81+xyV8pKZV+03bT3FOuVQrkl25+woHlOuMHJqrrquF/lkqyUH+uVl4t0zaG1fPI pRfyY6anyqwruTQIYELP/0HE2XyrhE4MuNhGIKY4Yp9/6ptTxjVu3BL6dZdyvYJLtW+2 iV2zl7xFM87zPbJFwuFGcMhESUot7F/OBzXyBtK/6fgmn8xSe1xZhY/BGloJWxbrUgS/ jeyA== 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=Vdv/OF1w21zucpUZcEXcc4syPqHcPDsaj3Soy58j9gF+k2aVKNoqekfEPSsdBTL+og MxBp+wZF40+4pbFXdEu31eMNR2/0dlu5pMBDcxcThUaP1jmjs82GFSzzsgyEf5Tz3zbr s3+sNQIvYLJ1QmddpqPYA5L/r2PXUKgkYSCO8tBNvltALAHRi+Ij99kMvh/e+SdZF9+/ h6xy7BeI02zhzthEHHkACIObn3LpAyc6Gad+TrDeNsTP4A1ptp4aL1Pc3dwrDCQjVTQH pgNtqahzdz89Y1jovwVSSwcwiItO+oLUwjciLOfsF6Tb/EjDg8pZX1XmPK4RkDaS0VPs hqLw== X-Gm-Message-State: APjAAAW1zthox033wQ0gVbIEmuIwjJSm4Q1oOoUTYL8Ul8vSo3jdgC86 vQeYnWmYG8cu+M9mxwEch80ThzBBQ6dk2gfWAY0ZjQ== X-Received: by 2002:ac5:c4cc:: with SMTP id a12mr27573495vkl.28.1564611460638; Wed, 31 Jul 2019 15:17:40 -0700 (PDT) Date: Wed, 31 Jul 2019 15:16:17 -0700 In-Reply-To: <20190731221617.234725-1-matthewgarrett@google.com> Message-Id: <20190731221617.234725-30-matthewgarrett@google.com> Mime-Version: 1.0 References: <20190731221617.234725-1-matthewgarrett@google.com> X-Mailer: git-send-email 2.22.0.770.g0f2c4a37fd-goog Subject: [PATCH V37 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