From patchwork Wed Feb 19 09:02:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Haass X-Patchwork-Id: 11390771 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A76A1930 for ; Wed, 19 Feb 2020 09:02:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 87CBC24656 for ; Wed, 19 Feb 2020 09:02:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W+MvosDD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726480AbgBSJCf (ORCPT ); Wed, 19 Feb 2020 04:02:35 -0500 Received: from mail-vs1-f67.google.com ([209.85.217.67]:41403 "EHLO mail-vs1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726260AbgBSJCf (ORCPT ); Wed, 19 Feb 2020 04:02:35 -0500 Received: by mail-vs1-f67.google.com with SMTP id k188so14600110vsc.8; Wed, 19 Feb 2020 01:02:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=TSVyOEZZlUXcItl/vOCqMLuW1ofkxTSLhKQ7okp+WUw=; b=W+MvosDDNezGY0Xz11wcWD5F1iPFX3ljmRkbHSfE1anrFuYDdb5UEvX8Fd8FSEH9fK g8XNmermebanajz8wUzJv6E7+Lpo9m7pUKQ8ZjMH8YxkLRrPGILV6HWQ4eHw5XDZ53IT JtSiHbAegJIwYSLSM1i75JFwskZoZYZmkoHBZr3guFZvzpisQLR5P/3OZjhatToz49LT W008XH5uN98RYQ5w1FVVPIiAj2mk8Kqji8aeT4695uKAsTwWkkJCOIw992VqU97Pyepv JZaJ0Dnq2IVvJ2db4U3xYnlHdTyVasQ1eT9IhbblNbuRuTspOSdoXH7PKohvp1PxIh0S FggA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=TSVyOEZZlUXcItl/vOCqMLuW1ofkxTSLhKQ7okp+WUw=; b=TlmEhK8ARvxQkU8jlX5bg7aNkDbWxL8i/WnNwIFGPnh9Ib+TD7y4dsaKre2HRsHSkV V7+V+exlO+8l9wXqaKTpWC2HaXLWnqUSJ99gI/lnMcGsd4esdyX7qhE6w+LG06Llh7Pa xJ/C3rmCgEACwpdDS8K1bLfDCCOIO8psOn8Z9NdbQFzhyS3BnTlfvmFES2exo44yb6+x cHH0KxP57XLuJLiW77fcwPCv3UcXXXUXTooMN3pbPL+39NZoQkfcj91BGbXina/FpZ38 iavDo8OMjhh/+rJdxK6zJNAqUm1C1HFAILdpfVQyJ24S3H6t+DFjlURbjKHdmeyf1vom GukA== X-Gm-Message-State: APjAAAUP+NucwGvTHrsMpGC4Ubmc6J8JFKXDwmB30EyRVrvESFjVeuK+ zcGUmP/J4ON01HMxKQmF42nYF4rQ4lFstlbf3uk= X-Google-Smtp-Source: APXvYqyYPlXGS2nEIB0nWEpd2b1ixbT/+c7Z/cOCKib+7XtifVu0NFO4zmvfJR/Et/9/RC0y/ZQ/vXXzv9FEqzt3KWQ= X-Received: by 2002:a67:eac5:: with SMTP id s5mr13315040vso.148.1582102954243; Wed, 19 Feb 2020 01:02:34 -0800 (PST) MIME-Version: 1.0 From: Martin Haass Date: Wed, 19 Feb 2020 10:02:17 +0100 Message-ID: Subject: [PATCH] module support: during lockdown, log name of unsigned module To: Jessica Yu Cc: linux-kernel@vger.kernel.org, linux-security-module@vger.kernel.org, linux-modules@vger.kernel.org Sender: owner-linux-modules@vger.kernel.org Precedence: bulk List-ID: during lockdown loading of unsigned modules is restricted to signed modules only. The old error message does not show which module misses the signature, making it very difficult for a user to determine which module is at fault. This patch adds a line to the logs which additionally contains the module name that caused the error message. The old message cannot be replaced as it is generated by lockdown_is_locked_down --- kernel/module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) * removed is no longer the module that was signed @@ -2843,7 +2844,12 @@ static int module_sig_check(struct load_info *info, int flags) return -EKEYREJECTED; } - return security_locked_down(LOCKDOWN_MODULE_SIGNATURE); + is_locked = security_locked_down(LOCKDOWN_MODULE_SIGNATURE); + if (is_locked == -EPERM) { + pr_notice("Lockdown: %s: rejected module '%s' cause: %s", + current->comm, info->name, reason); + } + return is_locked; /* All other errors are fatal, including nomem, unparseable * signatures and signature check failures - even if signatures diff --git a/kernel/module.c b/kernel/module.c index 33569a01d6e..6dcb28139a0 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -2807,7 +2807,8 @@ static int module_sig_check(struct load_info *info, int flags) const unsigned long markerlen = sizeof(MODULE_SIG_STRING) - 1; const char *reason; const void *mod = info->hdr; - + int is_locked = -EPERM; + /* * Require flags == 0, as a module with version information