Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp467945pxm; Wed, 23 Feb 2022 04:33:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJz9H4UMgghPGe3jqWsH2FbkPVyp612wUN5vQ6ZYo8n0scIR+SzMiHskv/Hc/VbVX2aEbRMt X-Received: by 2002:a05:6402:278f:b0:410:d242:465e with SMTP id b15-20020a056402278f00b00410d242465emr32064229ede.292.1645619601023; Wed, 23 Feb 2022 04:33:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645619601; cv=none; d=google.com; s=arc-20160816; b=wRzgvZlaRymr+8+jvhaTUEGZ6J9jnun6dWsANeaEwap6uLZXaie0T4iusp5x1SSJlQ zICcD8L3u1DS9WNyUITUqZpVqEGk6Qb1qK0MQ9b5s1iwJGZTlTHF90d7asaLZT2PmlXn VlpWfQs4SUVpJ4+k+BEZz8qlocK738jBa88ebm5sjKN1Ty1t5IvooM+0hR18Emxtm5kz hP2QcpXjfkugOnMxB4iOJi6UYpdRW2glH4rNQpQGf2fSg4N7Sg57ugJrJlaGQN2gNf1o PUpVre+SlqgcEgLhb8Mvy/P6dRsLwCU/1ev654Alni9PH3yzAYTVy/iguIfEJdhluK3j ERWg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from; bh=/rCWuoGl/XoWcomYeVWk+Us26lG2QHNUEVSp9vf8/zM=; b=hqiGwrhtlBjZbUSmqhxKOrXB16xQsA915C4llAY8NcHYQV8SbRJCgc+uNAm13d11Ak quQgoIuGhPqcA7zjzLoUDdr3vk2wYkkH2CwEVPtJyHKQlndIlwqIbfCwcAgRs/K7JerY F/S4BBuJDZDry/6O6gGIPLfxqc5uPWLPnzHxxc9ORF2GIkbr/D1ThEMfy3q8oPTMttth fV42Nuub8yq0/sh+rVgsPczLQZMBT7YEzRIogvAEGfzAt2UMudaMfAmaKVZUOKUIwCzA /lCOWPeymYaSnT+AU00SIPjkR18Oi/wvU+gz8cBUvn1SnaqhCtyhCFrDgehtOg+4l7nk t1kg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n12si9217821eja.800.2022.02.23.04.32.56; Wed, 23 Feb 2022 04:33:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239299AbiBWJgi (ORCPT + 99 others); Wed, 23 Feb 2022 04:36:38 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233895AbiBWJgh (ORCPT ); Wed, 23 Feb 2022 04:36:37 -0500 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C432959390 for ; Wed, 23 Feb 2022 01:36:08 -0800 (PST) Received: from dggeme762-chm.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4K3W8t6JHdzcn4x; Wed, 23 Feb 2022 17:34:54 +0800 (CST) Received: from ubuntu1804.huawei.com (10.67.174.44) by dggeme762-chm.china.huawei.com (10.3.19.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2308.21; Wed, 23 Feb 2022 17:36:06 +0800 From: Gaosheng Cui To: , CC: , , , Subject: [PATCH -next,v2] audit: only print records that will be dropped via printk() Date: Wed, 23 Feb 2022 17:35:59 +0800 Message-ID: <20220223093559.189844-1-cuigaosheng1@huawei.com> X-Mailer: git-send-email 2.30.0 MIME-Version: 1.0 Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=US-ASCII X-Originating-IP: [10.67.174.44] X-ClientProxiedBy: dggems704-chm.china.huawei.com (10.3.19.181) To dggeme762-chm.china.huawei.com (10.3.19.108) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When an admin enables audit at early boot via the "audit=1" kernel command line, netlink send errors seen will cause the audit subsystem to drop some records or return records to the queue. And all records will be printed via printk() in the kauditd_hold_skb(), but actually only the records that will be dropped need to be printed via printk(). Signed-off-by: Gaosheng Cui --- kernel/audit.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 7690c29d4ee4..eb3e44c849be 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -568,10 +568,6 @@ static void kauditd_rehold_skb(struct sk_buff *skb, __always_unused int error) */ static void kauditd_hold_skb(struct sk_buff *skb, int error) { - /* at this point it is uncertain if we will ever send this to auditd so - * try to send the message via printk before we go any further */ - kauditd_printk_skb(skb); - /* can we just silently drop the message? */ if (!audit_default) goto drop; @@ -600,6 +596,11 @@ static void kauditd_hold_skb(struct sk_buff *skb, int error) /* we have no other options - drop the message */ audit_log_lost("kauditd hold queue overflow"); drop: + /* at this point it is uncertain if we will ever send this to auditd so + * try to send the message via printk before we go any further + */ + kauditd_printk_skb(skb); + kfree_skb(skb); } -- 2.30.0