Received: by 10.192.165.148 with SMTP id m20csp203566imm; Thu, 3 May 2018 18:11:04 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQogV28KMndIdcwp+upTLY2ByQX06m7XOXeFvOvgjx+8jC9BnG952fSCY6ntDzTDWePiSZ X-Received: by 2002:a17:902:680c:: with SMTP id h12-v6mr26376525plk.113.1525396264682; Thu, 03 May 2018 18:11:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525396264; cv=none; d=google.com; s=arc-20160816; b=IuahBfQ6fNdVXZfEgdrmMhAy8JiWUE2ic+bcognE5VraQivxDFp5GPoht6c0Nv6ZJe qOF2yYhHSM1KqKI4SBoz17VdmjRAazi8+9WThZJNmJuqcS8/qcveN8M0ZLiWnjwQuylx nPsDwB0S4hSPJl4MQktJCQNKKQWUnsptfvGi7bEiVpquGVof86Hxho+KLbMddLwvyxAm uC7r1SOTsq1bEmKudlPHrJf0yS4LFtlSkDSB6tqn1vOAW/mPpQMcUXyzFRaDQgPnGWRQ vGuE7yg+SRcObO0j/SttJRHXY6PcicnVl0+RQQrp9icLN6Oxcjq6F0HyJZ/nT89f/Dxs ifHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=m6lpYfqgHpK6WbmuTNQVJFRpoFxx0IxBkD45ghTi2dI=; b=POxV/cBWtC+RK9Zk47u8BHzp24d/T2Q4BqyAmof4GVxM6NC3jTaOOWTYzM1di9DNMG aYpG8lYklQz2Parq7un8SYz4Sfd3rdVlsbSImSTHTC9Bx9DI9pnoVdzZNtz4IQPAdE85 3xf4Hx979ps+VNMwGZSV6xkqBgai6HrsYqscK2o4i5NKRRUVe/jAMV4akWNiWu87ZiKj hXAps+fOuBdvnCLZIvys+Chi5XVD+7nyJ+dmWE90SP8qDyGvYwBBIRsNR7HJfDejCp8e 7H/pX+MJD49cZeT6yZZcvPbW/FSOY6I8oIZ3mcgs/glxLBhRuNAFvIQVtcI9jEqvSJX0 Lezw== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 89-v6si14914475plc.444.2018.05.03.18.10.50; Thu, 03 May 2018 18:11:04 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751404AbeEDBKU (ORCPT + 99 others); Thu, 3 May 2018 21:10:20 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52110 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751374AbeEDBKR (ORCPT ); Thu, 3 May 2018 21:10:17 -0400 Received: from 2.general.tyhicks.us.vpn ([10.172.64.53] helo=sec.ubuntu-ci) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.76) (envelope-from ) id 1fEPDw-0008Hm-Px; Fri, 04 May 2018 01:09:25 +0000 From: Tyler Hicks To: linux-kernel@vger.kernel.org Cc: Kees Cook , Andy Lutomirski , Will Drewry , Paul Moore , Eric Paris , Steve Grubb , Jonathan Corbet , linux-audit@redhat.com, linux-security-module@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v3 4/4] seccomp: Don't special case audited processes when logging Date: Fri, 4 May 2018 01:08:15 +0000 Message-Id: <1525396095-27737-5-git-send-email-tyhicks@canonical.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1525396095-27737-1-git-send-email-tyhicks@canonical.com> References: <1525396095-27737-1-git-send-email-tyhicks@canonical.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Seccomp logging for "handled" actions such as RET_TRAP, RET_TRACE, or RET_ERRNO can be very noisy for processes that are being audited. This patch modifies the seccomp logging behavior to treat processes that are being inspected via the audit subsystem the same as processes that aren't under inspection. Handled actions will no longer be logged just because the process is being inspected. Since v4.14, applications have the ability to request logging of handled actions by using the SECCOMP_FILTER_FLAG_LOG flag when loading seccomp filters. With this patch, the logic for deciding if an action will be logged is: if action == RET_ALLOW: do not log else if action not in actions_logged: do not log else if action == RET_KILL: log else if action == RET_LOG: log else if filter-requests-logging: log else: do not log Reported-by: Steve Grubb Signed-off-by: Tyler Hicks --- Documentation/userspace-api/seccomp_filter.rst | 7 ------- include/linux/audit.h | 10 +--------- kernel/auditsc.c | 14 +++++++++++++- kernel/seccomp.c | 17 +++++++---------- 4 files changed, 21 insertions(+), 27 deletions(-) diff --git a/Documentation/userspace-api/seccomp_filter.rst b/Documentation/userspace-api/seccomp_filter.rst index 099c412..82a468b 100644 --- a/Documentation/userspace-api/seccomp_filter.rst +++ b/Documentation/userspace-api/seccomp_filter.rst @@ -207,13 +207,6 @@ directory. Here's a description of each file in that directory: to the file do not need to be in ordered form but reads from the file will be ordered in the same way as the actions_avail sysctl. - It is important to note that the value of ``actions_logged`` does not - prevent certain actions from being logged when the audit subsystem is - configured to audit a task. If the action is not found in - ``actions_logged`` list, the final decision on whether to audit the - action for that task is ultimately left up to the audit subsystem to - decide for all seccomp return values other than ``SECCOMP_RET_ALLOW``. - The ``allow`` string is not accepted in the ``actions_logged`` sysctl as it is not possible to log ``SECCOMP_RET_ALLOW`` actions. Attempting to write ``allow`` to the sysctl will result in an EINVAL being diff --git a/include/linux/audit.h b/include/linux/audit.h index d4e35e7..b639cf1 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -232,7 +232,7 @@ extern void __audit_file(const struct file *); extern void __audit_inode_child(struct inode *parent, const struct dentry *dentry, const unsigned char type); -extern void __audit_seccomp(unsigned long syscall, long signr, int code); +extern void audit_seccomp(unsigned long syscall, long signr, int code); extern void audit_seccomp_actions_logged(const char *names, const char *old_names, int res); extern void __audit_ptrace(struct task_struct *t); @@ -304,12 +304,6 @@ static inline void audit_inode_child(struct inode *parent, } void audit_core_dumps(long signr); -static inline void audit_seccomp(unsigned long syscall, long signr, int code) -{ - if (audit_enabled && unlikely(!audit_dummy_context())) - __audit_seccomp(syscall, signr, code); -} - static inline void audit_ptrace(struct task_struct *t) { if (unlikely(!audit_dummy_context())) @@ -500,8 +494,6 @@ static inline void audit_inode_child(struct inode *parent, { } static inline void audit_core_dumps(long signr) { } -static inline void __audit_seccomp(unsigned long syscall, long signr, int code) -{ } static inline void audit_seccomp(unsigned long syscall, long signr, int code) { } static inline void audit_seccomp_actions_logged(const char *names, diff --git a/kernel/auditsc.c b/kernel/auditsc.c index 5195a29..15c20ba 100644 --- a/kernel/auditsc.c +++ b/kernel/auditsc.c @@ -2464,7 +2464,19 @@ void audit_core_dumps(long signr) audit_log_end(ab); } -void __audit_seccomp(unsigned long syscall, long signr, int code) +/** + * audit_seccomp - record information about a seccomp action + * @syscall: syscall number + * @signr: signal value + * @code: the seccomp action + * + * Record the information associated with a seccomp action. Event filtering for + * seccomp actions that are not to be logged is done in seccomp_log(). + * Therefore, this function forces auditing independent of the audit_enabled + * and dummy context state because seccomp actions should be logged even when + * audit is not in use. + */ +void audit_seccomp(unsigned long syscall, long signr, int code) { struct audit_buffer *ab; diff --git a/kernel/seccomp.c b/kernel/seccomp.c index f5630d1..5386749 100644 --- a/kernel/seccomp.c +++ b/kernel/seccomp.c @@ -584,18 +584,15 @@ static inline void seccomp_log(unsigned long syscall, long signr, u32 action, } /* - * Force an audit message to be emitted when the action is RET_KILL_*, - * RET_LOG, or the FILTER_FLAG_LOG bit was set and the action is - * allowed to be logged by the admin. + * Emit an audit message when the action is RET_KILL_*, RET_LOG, or the + * FILTER_FLAG_LOG bit was set. The admin has the ability to silence + * any action from being logged by removing the action name from the + * seccomp_actions_logged sysctl. */ - if (log) - return __audit_seccomp(syscall, signr, action); + if (!log) + return; - /* - * Let the audit subsystem decide if the action should be audited based - * on whether the current task itself is being audited. - */ - return audit_seccomp(syscall, signr, action); + audit_seccomp(syscall, signr, action); } /* -- 2.7.4