Received: by 10.192.165.148 with SMTP id m20csp204228imm; Thu, 3 May 2018 18:12:13 -0700 (PDT) X-Google-Smtp-Source: AB8JxZrgNzQ8oZ8cJr9/51jat3d3SA2d/dFQNDMVmf22A7d+uB9alnUafOLO1oD/YAeMnd6Rnv45 X-Received: by 2002:a63:7150:: with SMTP id b16-v6mr20779494pgn.326.1525396333274; Thu, 03 May 2018 18:12:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525396333; cv=none; d=google.com; s=arc-20160816; b=MJLkbFgkKKv+LMM7zeQ543qbQtI+xME+sQ/4TExg8D/HWW2f7sepPNSBCJE445uzCM gybmRMLl05+gFKynsYFRDrMREKxb7iCZqBRTfQTzKQQt1xCRj+xMFakXXS2LlUrpXKot ZIewYMMuF/FsUMxipRgp4uCX58V7C/GLxbPSHTOJkWTB9Pul+2/vn50hkTPCzAcTTKFx oZE5WPHJZdSaSFix20Qb5BoYeuRCDy8rI9UFol/igLLWlGu2ggZ38BEgwSBgCBNETzVf GJ3xfgBOWKDYe3Z6zYZI8pUmLqXBLIVKvJKsLiE9+eBkFnj8/jvweC1xNxN30lWbRjLJ DIqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=C9vxt5pR1Ri3Jd7TuAhEfKk7J8/t2xMJrs9p9GntqCw=; b=eZ4Bw1YBX9RAnRX5SgQS5u9sF5WiPoOPZFvcjjOsIplyaVAy4oBYP424bTqLfWcp/i Pq/4pyCs1cFHNmfkZAoPb5Tlvtm52ZBpYR2ZJ3MY2mqAMogr0wK6NsWWcgblmkHYKwgO V2DpGpK3u0nNZxL9eyVyTjUsDiZhC9xplcrF9FOZd3vKVEyXWwQA6gPomrjccBHQfnSY iH5nXto7xM+893WMccFy7/bdtSe5lvXe431s/Jxh17EWaOsyB5RrZ97sx2bQtDg/TDiw YvBrayb8WDD1NSev5fJ8lSQUFwf68AUhC84XuQxwagsXQwgHtwRJMdzgODqg33pnr7xo o71Q== 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 p3si14173601pff.356.2018.05.03.18.11.59; Thu, 03 May 2018 18:12:13 -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 S1751324AbeEDBKM (ORCPT + 99 others); Thu, 3 May 2018 21:10:12 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:52092 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751190AbeEDBKK (ORCPT ); Thu, 3 May 2018 21:10:10 -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 1fEPDi-0008Hm-5R; Fri, 04 May 2018 01:09:10 +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 0/4] Better integrate seccomp logging and auditing Date: Fri, 4 May 2018 01:08:11 +0000 Message-Id: <1525396095-27737-1-git-send-email-tyhicks@canonical.com> X-Mailer: git-send-email 2.7.4 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Seccomp received improved logging controls in v4.14. Applications can opt into logging of "handled" actions (SECCOMP_RET_TRAP, SECCOMP_RET_TRACE, SECCOMP_RET_ERRNO) using the SECCOMP_FILTER_FLAG_LOG bit when loading filters. They can also debug filter matching with the new SECCOMP_RET_LOG action. Administrators can prevent specific actions from being logged using the kernel.seccomp.actions_logged sysctl. However, one corner case intentionally wasn't addressed in those v4.14 changes. When a process is being inspected by the audit subsystem, seccomp's decision making for logging ignores the new controls and unconditionally logs every action taken except for SECCOMP_RET_ALLOW. This isn't particularly useful since many existing applications don't intend to log handled actions due to them occurring very frequently. This amount of logging fills the audit logs without providing many benefits now that application authors have fine grained controls at their disposal. This patch set aligns the seccomp logging behavior for both audited and non-audited processes. It also emits an audit record, if auditing is enabled, when the kernel.seccomp.actions_logged sysctl is written to so that there's a paper trail when entire actions are quieted. Changes in v3: * Patch 3 - Never drop a field when emitting the audit record - Use the value "?" for the actions field when an error occurred while writing to the sysctl - Use the value "?" for the actions and/or old-actions fields when a failure to translate actions to names - Use the value "(none)" for the actions and/or old-actions fields when no actions are specified + This is possible when writing an empty string to the sysctl - Update the commit message to note the new values and give an example of when an empty string is written * Patch 4 - Adjust the control flow of seccomp_log() to exit early if nothing should be logged Changes in v2: * Patch 2 - New patch, allowing for a configurable separator between action names * Patch 3 - The value of the actions field in the audit record now uses a comma instead of a space - The value of the actions field in the audit record is no longer enclosed in quotes - audit_log_start() is called with the current processes' audit_context in audit_seccomp_actions_logged() - audit_seccomp_actions_logged() no longer records the pid, uid, auid, tty, ses, task context, comm, or executable path - The new and old value of seccomp_actions_logged is recorded in the AUDIT_CONFIG_CHANGE record - The value of the "res" field in the CONFIG_CHANGE audit record is corrected (1 indicates success, 0 failure) - Updated patch 3's commit message to reflect the updated audit record format in the examples * Patch 4 - A function comment for audit_seccomp() was added to explain, among other things, that event filtering is performed in seccomp_log() Tyler