Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp3182171ybt; Mon, 22 Jun 2020 17:38:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7OgvAUvQwb6rpOqipmMRpHvW7WVEwl+WNMGDPSJ19WAMqN/Gy56IqAIxL44vuXrI3L/dZ X-Received: by 2002:a17:907:1190:: with SMTP id uz16mr4321486ejb.385.1592872702454; Mon, 22 Jun 2020 17:38:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592872702; cv=none; d=google.com; s=arc-20160816; b=JjU6vDhCs5WCNRJASK2l/+eMM4r8C5gMrHwieUaJ4JtDC8xZt74GvQwX1/dIWgnuwf tp8x1UfB7kWkZUqL2+lqayElNNo1XJMREQyhUqmopoVW2vF0R7+TLjRuJAwsXBx4JJOB k7AeeCIs1y3zRj0G3VwNHD4sxVlFN4VIqbpghWUHERR5q8j3boRRj42MqmAo0sR5vS78 6mh1z8ZgQwvZp6Gfxi6S6VEYGkPiuaTHLbnA5NY3CYJDuieRlzRDQ2/AizncmHmyx4ku cGwk+dtk7KktHbggdkFafTBa6D21Ja6em1Wbou9gIoAkaZ/6Gm1QEOUFPR/nkLZxtKB+ ZpfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=EIfQa71W+wSH28J/gAtVyVwZP6jN6OZSnsojTGHhpic=; b=M0A8jWIgWeLQYXLSxiwb8wZ5jOkHDwjjNB8g2JLw5e2TOChEhzxkOuVtjF7giq9wAX U3vHagCGW48rpNE0eCVAKXFMrB2b4/GuiAv1vShfxEyTEyQ/mAeAOGgHJRqQcdQJvVmu +W3VcvBvUOwui6es0w0SNTmj4pg8o5dX2vm6/ruU5Fv6/NDHQoFiuY52/hPMZwlwaOMS DvH8aYDe7yo/qlBsN8aabRZBCFb5u/lYyCDy7uT34pevdvdfnBefljyXYOfeMM/rt/oS NFpRmAzlWTj9Wj+VuAtGYEQlX0IY7Kq/tCi448B99EBWvuXA+gRi494KK1Ru8MI0Qr/5 NIag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=p8I54MFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p20si9927043ejg.263.2020.06.22.17.37.59; Mon, 22 Jun 2020 17:38:22 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=p8I54MFO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732003AbgFWAer (ORCPT + 99 others); Mon, 22 Jun 2020 20:34:47 -0400 Received: from linux.microsoft.com ([13.77.154.182]:47544 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732009AbgFWAeY (ORCPT ); Mon, 22 Jun 2020 20:34:24 -0400 Received: from sequoia.work.tihix.com (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 7D5C820B7192; Mon, 22 Jun 2020 17:34:23 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 7D5C820B7192 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1592872464; bh=EIfQa71W+wSH28J/gAtVyVwZP6jN6OZSnsojTGHhpic=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p8I54MFObjdsFyRtrc3RrhsboG9BU+0JnbS0PSdcE++h8wp8dp3T6HijlXsuyxZBq 8rfyjIBvTLiVOWzIgowFzyMGwzxgRMjp5LmX3kY8gg9eizLjx3ZpO8jG3MbVjbw2JM KWFzYLA2SdX0C7IJY+jAwp1aCcSq+jBLch7k/rnM= From: Tyler Hicks To: Mimi Zohar , Dmitry Kasatkin Cc: James Morris , "Serge E . Hallyn" , Lakshmi Ramasubramanian , Prakhar Srivastava , linux-kernel@vger.kernel.org, linux-integrity@vger.kernel.org, linux-security-module@vger.kernel.org Subject: [PATCH 08/12] ima: Shallow copy the args_p member of ima_rule_entry.lsm elements Date: Mon, 22 Jun 2020 19:32:32 -0500 Message-Id: <20200623003236.830149-9-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200623003236.830149-1-tyhicks@linux.microsoft.com> References: <20200623003236.830149-1-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The args_p member is a simple string that is allocated by ima_rule_init(). Shallow copy it like other non-LSM references in ima_rule_entry structs. There are no longer any necessary error path cleanups to do in ima_lsm_copy_rule() so reference ownership from entry to nentry becomes easier. Signed-off-by: Tyler Hicks --- security/integrity/ima/ima_policy.c | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) diff --git a/security/integrity/ima/ima_policy.c b/security/integrity/ima/ima_policy.c index e33347148aa9..e9c7d318fdd4 100644 --- a/security/integrity/ima/ima_policy.c +++ b/security/integrity/ima/ima_policy.c @@ -306,10 +306,8 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) continue; nentry->lsm[i].type = entry->lsm[i].type; - nentry->lsm[i].args_p = kstrdup(entry->lsm[i].args_p, - GFP_KERNEL); - if (!nentry->lsm[i].args_p) - goto out_err; + nentry->lsm[i].args_p = entry->lsm[i].args_p; + entry->lsm[i].args_p = NULL; security_filter_rule_init(nentry->lsm[i].type, Audit_equal, @@ -325,13 +323,6 @@ static struct ima_rule_entry *ima_lsm_copy_rule(struct ima_rule_entry *entry) entry->keyrings = NULL; entry->template = NULL; return nentry; - -out_err: - nentry->fsname = NULL; - nentry->keyrings = NULL; - nentry->template = NULL; - ima_free_rule(nentry); - return NULL; } static int ima_lsm_update_rule(struct ima_rule_entry *entry) -- 2.25.1