Received: by 2002:a05:6a10:9afc:0:0:0:0 with SMTP id t28csp375741pxm; Wed, 23 Feb 2022 02:17:18 -0800 (PST) X-Google-Smtp-Source: ABdhPJzsHGHM1tcal9K/mvjqwFmtcsedlTU5hng8Dgpx3uhD/xqLzR0K00NaOPKntz1b3QkjZF9i X-Received: by 2002:a17:906:6b8e:b0:6cd:7d22:e5b6 with SMTP id l14-20020a1709066b8e00b006cd7d22e5b6mr23425224ejr.259.1645611438277; Wed, 23 Feb 2022 02:17:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1645611438; cv=none; d=google.com; s=arc-20160816; b=wCauMiENsLsWRef4VSWvnUi+2Oc8QO+XYXftm3eQrUGUMBSjUzXBK4ptAzjDP9N7XU ohtD0e5Hzb49JPiu1TSR8Lj7kESXwsSMP3IVefYtzH58go4ERtW/UIxZY7CyqQ1pvMIe 8a9aZJVq2aLr1dWu6YoH2mGatAbhpAWTwxOpOio9Rc7Q6yLrAJXGw+uxxJaCLXeEoyaR 4lWkvAmXLFp1s1EdRswwSfd7q8wWJnNUjmwFEHrsiVLMKnACKYU8mc8qRMTFLI2+IQ6e M42kcMBrEUEkfON2wvW/178ZzERbbyxKWtkWiLrzWqMWquFrOxiwKlLU4kOBhvOQGjRY B0Ow== 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=YUp/KlfMZgDgQzbhvaNB2qB+ybYcdQG50CU7JHVTG6/lCfU1CuVrb78XnBx9Jf0b4k mJ6RULiXDeGFi/qgyzZSScsQBsX/2g8RzT5nA44qiTaTCFchOlSXQ7CVoKBCYsA0LGyY 9vjbp2VK9gA7T6l42YcGxU5knOLaRNGsdey2DSHshFtFQxP4pQyk9B1bWMB6RPkzuBdn WY2q16caeXFvNm0cU3OgpCsckW+pPgBt0ICLLKBDgmCYQv1SbF1OWcmBYgDqzW+Pcfct h8QxRLkujWi5cTRtZOCWeNkpD1brVmpdbCjaKg0uAP8WGKoeLlx62LMItk74pSSNHvvJ hAGg== 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 n8si13934750edr.233.2022.02.23.02.16.54; Wed, 23 Feb 2022 02:17:18 -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 S239355AbiBWJlr (ORCPT + 99 others); Wed, 23 Feb 2022 04:41:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239330AbiBWJlp (ORCPT ); Wed, 23 Feb 2022 04:41:45 -0500 Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59DF65B8BA for ; Wed, 23 Feb 2022 01:41:18 -0800 (PST) Received: from dggeme762-chm.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4K3WC12n9Tzbbmn; Wed, 23 Feb 2022 17:36:45 +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:41:16 +0800 From: Gaosheng Cui To: , CC: , , , Subject: [PATCH -next] audit: only print records that will be dropped via printk() Date: Wed, 23 Feb 2022 17:41:09 +0800 Message-ID: <20220223094109.192510-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: dggems706-chm.china.huawei.com (10.3.19.183) 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