Received: by 2002:a05:6a10:6006:0:0:0:0 with SMTP id w6csp695923pxa; Thu, 27 Aug 2020 13:13:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwK7STYWlJXPIId1l+TmEwLkz2BUg4FaYjfG/ROm/gW1vwhhJTT1VEjK1AvkGfN/+tCUHJ1 X-Received: by 2002:a05:6402:2062:: with SMTP id bd2mr22353113edb.101.1598559218289; Thu, 27 Aug 2020 13:13:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598559218; cv=none; d=google.com; s=arc-20160816; b=g3BvZHAoudckUAaQaOmi6hNlNqpAyc8U/pDY0Xar7aXx2Jl8F6o0n1DVg2d5T1rFTF L28SZqHd20UA8GZm1GIZG/Xr5YZUtKBiSXDlGZPpNkWiX/oRgj/wJ0Xjvf7690RzY19f c9n0RS/Hgjbi31FA6hDtiMICtxuCA/ufuTahRUIgZtqIamjPN7OeAZ54g0pNUVkVSHRM TrFyhJzItPxMnvzjRhy+kCGn61iVkCzLoPNWIpNrrxem7TLMfa2rAGB8bHWx0VEm1kqM 7wu1vH2noQExC79hBMzJLwfYTLyAqbR0iER3jRXpBbGHbd+56Iw8Yq/o4NROy6DmvSEG GrRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=p+NhuGqZ1s2YOIDcL/NLneD1sSa9p1wUOJUKqaMqRkw=; b=C46r4SoOq9W8i0Mbz8HcEqkaGG4gvSm0N3EY2FMsQhky4se76zGgLSzsCWOW3MiZha qqdmpugR4sdZfYPJLBLcGNDqYtC1R973pWt8w6p+2H9pN/70qmRpfdc384JkvmDEeY64 jAuqLuQ7Qn1o5ktCFYDZ/Qle5wh9VCC4PsFjjlKCQwBaTMTDiPgWFCjDHarqcWzyvPhF jL/wQnR1+OXKqaWI5mufnDesPM4kW7tAmnJBhW6YjPzkcKEjLIUIhcKcXKV6kKT1kcuH e7NIeC+8BtpUf1MlCTqhul8kC2pWx7OiIup46g34LosAoDUwyv3nFEKoPfd11QvgckTA B43w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="Md/xHyaG"; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l7si2379445edv.354.2020.08.27.13.13.15; Thu, 27 Aug 2020 13:13:38 -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=@paul-moore-com.20150623.gappssmtp.com header.s=20150623 header.b="Md/xHyaG"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727024AbgH0UKr (ORCPT + 99 others); Thu, 27 Aug 2020 16:10:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55112 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726321AbgH0UKp (ORCPT ); Thu, 27 Aug 2020 16:10:45 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 789D4C06121B for ; Thu, 27 Aug 2020 13:10:45 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id l23so6006469edv.11 for ; Thu, 27 Aug 2020 13:10:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=paul-moore-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=p+NhuGqZ1s2YOIDcL/NLneD1sSa9p1wUOJUKqaMqRkw=; b=Md/xHyaGoYRdh+UNIrfduX3a2nUDPbw1zFgSowMyJTCFVTN1fTpyRBimXcJichIHef Jo0srQdtzmRNP+gsin5OTAz8TQtg3zpd1S50BCMb7vaCV+vm3L7n39g1+UF4hkspZhM6 DmT+eDm2ALzIDH9aA6TtStWercvL3mLFc9ebukS+Gv+ohl+3/12AAD8neUeekyHQQ+0S k/0Z8wxUyqtAuGCo0zVxoY3bqYvIy8RdYG36Oe/CxDqQHjsjCk52SpCtHlPpX8gF+XoN aF3pI9+MypDBQ5ubIuGAP9jpr4vTAgne9KefuEJ/CP8PmL8AgXvH+hsYnL105GPvFEqD hUOA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=p+NhuGqZ1s2YOIDcL/NLneD1sSa9p1wUOJUKqaMqRkw=; b=B1cC70+6pD/mQp493ZkFvTrhLXRMjnXl2feQPzfEgsz1x+2QGhKNbmSxA2vsqFGlBf JSwK+l0By0SMpnN3YXtUM1+gM5QchjGTZ29ZOuhERlCv/AwmjO1VoCDfLWGELo4U2kQM YRz+IBWkkAXzj84aJVpyEw7nlFyFhu5KGy/FQb3qvEO6uEbrSpFMQn+uH+19D/kgLYkD cL37wvANez0sYCp/xno4xFBmCT0MxQhZ4pn9hZzkIK98Rmmd82aV8ir/Jt1rQYRQKf4M qdMA4OzUUcyk/j/BYkPD/I0DWzJPLMbv005Y86PK+ALE6JG0h7exxP8twBv+/5eUWElZ CwEw== X-Gm-Message-State: AOAM533cqK52jikpT1QoPsv7gljjZVk6dKAd2zZBd9O5RnIV6Lyes3IT agn8K9ZTUf6UIIRjEc4/2TohOaYRrIyR1O8EVUW5 X-Received: by 2002:aa7:c6ca:: with SMTP id b10mr13274121eds.269.1598559044015; Thu, 27 Aug 2020 13:10:44 -0700 (PDT) MIME-Version: 1.0 References: <20200827163712.106303-1-alex.dewar90@gmail.com> <20200827170634.wogybzcxux7sgefb@medion> <20200827172006.gudui4alfbbf2a2p@medion> In-Reply-To: <20200827172006.gudui4alfbbf2a2p@medion> From: Paul Moore Date: Thu, 27 Aug 2020 16:10:32 -0400 Message-ID: Subject: Re: [PATCH RFC] netlabel: remove unused param from audit_log_format() To: Alex Dewar Cc: "David S. Miller" , Jakub Kicinski , netdev@vger.kernel.org, linux-security-module@vger.kernel.org, linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Aug 27, 2020 at 1:20 PM Alex Dewar wrote: > On Thu, Aug 27, 2020 at 06:06:34PM +0100, Alex Dewar wrote: > > On Thu, Aug 27, 2020 at 01:00:58PM -0400, Paul Moore wrote: > > > On Thu, Aug 27, 2020 at 12:39 PM Alex Dewar wrote: > > > > > > > > Commit d3b990b7f327 ("netlabel: fix problems with mapping removal") > > > > added a check to return an error if ret_val != 0, before ret_val is > > > > later used in a log message. Now it will unconditionally print "... > > > > res=0". So don't print res anymore. > > > > > > > > Addresses-Coverity: ("Dead code") > > > > Fixes: d3b990b7f327 ("netlabel: fix problems with mapping removal") > > > > Signed-off-by: Alex Dewar > > > > --- > > > > > > > > I wasn't sure whether it was intended that something other than ret_val > > > > be printed in the log, so that's why I'm sending this as an RFC. > > > > > > It's intentional for a couple of reasons: > > > > > > * The people who care about audit logs like to see success/fail (e.g. > > > "res=X") for audit events/records, so printing this out gives them the > > > warm fuzzies. > > > > > > * For a lot of awful reasons that I won't bore you with, we really > > > don't want to add/remove fields in the middle of an audit record so we > > > pretty much need to keep the "res=0" there even if it seems a bit > > > redundant. > > > > > > So NACK from me, but thanks for paying attention just the same :) > > > > Would you rather just have an explicit "res=0" in there, without looking > > at ret_val? The thing is that ret_val will *always* be zero at this point in > > the code, because, if not, the function will already have returned. > > That's why Coverity flagged it up as a redundant check. > > Sorry, I meant "res=1". The code will always print res=1, because > ret_val is always 0. That's okay, I can't tell you how many times I've made that mistake with "res=" :) Anyway, yes at that point ret_val should always be 0, and "res=X" should always be "res=1", so if you wanted to change it to a fixed value so you could get rid of the ternary statement that would be okay. > > > > net/netlabel/netlabel_domainhash.c | 5 ++--- > > > > 1 file changed, 2 insertions(+), 3 deletions(-) > > > > > > > > diff --git a/net/netlabel/netlabel_domainhash.c b/net/netlabel/netlabel_domainhash.c > > > > index f73a8382c275..526762b2f3a9 100644 > > > > --- a/net/netlabel/netlabel_domainhash.c > > > > +++ b/net/netlabel/netlabel_domainhash.c > > > > @@ -612,9 +612,8 @@ int netlbl_domhsh_remove_entry(struct netlbl_dom_map *entry, > > > > audit_buf = netlbl_audit_start_common(AUDIT_MAC_MAP_DEL, audit_info); > > > > if (audit_buf != NULL) { > > > > audit_log_format(audit_buf, > > > > - " nlbl_domain=%s res=%u", > > > > - entry->domain ? entry->domain : "(default)", > > > > - ret_val == 0 ? 1 : 0); > > > > + " nlbl_domain=%s", > > > > + entry->domain ? entry->domain : "(default)"); > > > > audit_log_end(audit_buf); > > > > } > > > > -- paul moore www.paul-moore.com