Received: by 10.213.65.16 with SMTP id m16csp194264imf; Sun, 11 Mar 2018 23:38:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELvM46WPueyj0N7W57sefLJgDpm7au96kljemSi8ZT2mT1NFEthlNgU8l898CBWIVtlumzmM X-Received: by 2002:a17:902:744b:: with SMTP id e11-v6mr4277956plt.351.1520836722081; Sun, 11 Mar 2018 23:38:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1520836722; cv=none; d=google.com; s=arc-20160816; b=nRIermG9tRg2hmGrNT04WfoAbfAoGUN+JOSyUuv4chkevtsS3dc6fsx50sHiGRLDu2 0X+72TagF+RwggC1L9q73+x1zeG1eppHFNV0rKgydYoOFColgB2zyZgzJ/jINLDJBAFT nwrS9x1M2LVHzfVqH6Z+SoKYkFSpmdpSqkua0A0PpzJj1cafrbmhF/80VAecKtnTj18E qm9MxFvXsO250TNPXZDSyj+zNtGyvh8d1mrwhtAORnbjT+HRMFTVzu69xRF9PhqW2Df0 p2Wf+lgtAeqM5Mp7CD67nZnRhTqBlxTbrV973yMYT1l8z/JqltL2UCJb1s4/pDmUa+u9 2Z3Q== 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:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=qAJHWGoHp4llYpkBsMWpqNP1FkYWb64r097o8PDxBDo=; b=grTtlqtKu/oB11JDowFxRsLV6prC+9vP2g37EGmKeLWe2vTdvpTs8ejaFfLoZ9AV0r 3WkB8HpdpUkRZSpwAhdDIG+cwfRpiKuv6SyYrZQnt0LiZzmEEjshxifJoXTlg2mfUJWm RC2QKABj51PkkGpqKNkS9KHD/XpP05d7BuYr/f2LR19V6VF0po3qg6Ygx92tQduKq+RG nTA6IyngzURFAK+Xi0XIHm6ZNvuMoExXPuB54idDkdle8K+W1MB2bD5RoOj6d26o8V0x KAXzB8yWYiAaMOzs4Be1AGkbSmBi989Pb5Pn+fCo3I2dZ4eKucaGoN0/b/nbk5See+Ca HKmA== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t9si5199782pfh.101.2018.03.11.23.38.27; Sun, 11 Mar 2018 23:38:42 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751971AbeCLGgc (ORCPT + 99 others); Mon, 12 Mar 2018 02:36:32 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:53732 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750752AbeCLGgb (ORCPT ); Mon, 12 Mar 2018 02:36:31 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B06498182D16; Mon, 12 Mar 2018 06:36:30 +0000 (UTC) Received: from madcap2.tricolour.ca (ovpn-112-12.rdu2.redhat.com [10.10.112.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 323771C717; Mon, 12 Mar 2018 06:36:29 +0000 (UTC) From: Richard Guy Briggs To: Linux-Audit Mailing List , LKML Cc: Eric Paris , Paul Moore , Steve Grubb , Kees Cook , Richard Guy Briggs Subject: [PATCH ghak21 V2 2/4] audit: link denied should not directly generate PATH record Date: Mon, 12 Mar 2018 02:31:18 -0400 Message-Id: <9ed76ccb239078ad5a2808d23c7b7f1738b0b2b8.1520835596.git.rgb@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 06:36:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.8]); Mon, 12 Mar 2018 06:36:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'rgb@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Audit link denied events generate duplicate PATH records which disagree in different ways from symlink and hardlink denials. audit_log_link_denied() should not directly generate PATH records. While we're at it, remove the now useless struct path argument. See: https://github.com/linux-audit/audit-kernel/issues/21 Signed-off-by: Richard Guy Briggs --- fs/namei.c | 2 +- include/linux/audit.h | 6 ++---- kernel/audit.c | 17 ++--------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/fs/namei.c b/fs/namei.c index 9cc91fb..50d2533 100644 --- a/fs/namei.c +++ b/fs/namei.c @@ -1011,7 +1011,7 @@ static int may_linkat(struct path *link) if (safe_hardlink_source(inode) || inode_owner_or_capable(inode)) return 0; - audit_log_link_denied("linkat", link); + audit_log_link_denied("linkat"); return -EPERM; } diff --git a/include/linux/audit.h b/include/linux/audit.h index af410d9..75d5b03 100644 --- a/include/linux/audit.h +++ b/include/linux/audit.h @@ -146,8 +146,7 @@ extern void audit_log_d_path(struct audit_buffer *ab, const struct path *path); extern void audit_log_key(struct audit_buffer *ab, char *key); -extern void audit_log_link_denied(const char *operation, - const struct path *link); +extern void audit_log_link_denied(const char *operation); extern void audit_log_lost(const char *message); extern int audit_log_task_context(struct audit_buffer *ab); @@ -194,8 +193,7 @@ static inline void audit_log_d_path(struct audit_buffer *ab, { } static inline void audit_log_key(struct audit_buffer *ab, char *key) { } -static inline void audit_log_link_denied(const char *string, - const struct path *link) +static inline void audit_log_link_denied(const char *string) { } static inline int audit_log_task_context(struct audit_buffer *ab) { diff --git a/kernel/audit.c b/kernel/audit.c index 7026d69..e54deaf 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -2301,36 +2301,23 @@ void audit_log_task_info(struct audit_buffer *ab, struct task_struct *tsk) /** * audit_log_link_denied - report a link restriction denial * @operation: specific link operation - * @link: the path that triggered the restriction */ -void audit_log_link_denied(const char *operation, const struct path *link) +void audit_log_link_denied(const char *operation) { struct audit_buffer *ab; - struct audit_names *name; if (!audit_enabled || audit_dummy_context()) return; - name = kzalloc(sizeof(*name), GFP_NOFS); - if (!name) - return; - /* Generate AUDIT_ANOM_LINK with subject, operation, outcome. */ ab = audit_log_start(current->audit_context, GFP_KERNEL, AUDIT_ANOM_LINK); if (!ab) - goto out; + return; audit_log_format(ab, "op=%s", operation); audit_log_task_info(ab, current); audit_log_format(ab, " res=0"); audit_log_end(ab); - - /* Generate AUDIT_PATH record with object. */ - name->type = AUDIT_TYPE_NORMAL; - audit_copy_inode(name, link->dentry, d_backing_inode(link->dentry)); - audit_log_name(current->audit_context, name, link, 0, NULL); -out: - kfree(name); } /** -- 1.8.3.1