From patchwork Thu May 11 05:21:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13237511 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11AB4C7EE22 for ; Thu, 11 May 2023 05:22:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237035AbjEKFWF (ORCPT ); Thu, 11 May 2023 01:22:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42134 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236300AbjEKFWC (ORCPT ); Thu, 11 May 2023 01:22:02 -0400 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3D944214; Wed, 10 May 2023 22:22:00 -0700 (PDT) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B1GhEF028406; Wed, 10 May 2023 22:21:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=+5ZIFcAXGaOEr6fcSRGPnoy06NRtoIMGpCCS8rABMCY=; b=ejvvIuZhEkdO18E+m6ggy5R9ILH1pMkpOiIAEeRkHQ/8mHCr62lBHr73r2qDX/6WWccV O3pp7hHSA9voWc6WeFtxkTzJYJAJuAPu2VzFxdzTnh+FNqrkOR4IouMA71SJKFRw6eRx MiNu0yD05xcm81Db8OnSHMHwEif4dQzqW6VZ+kbGQSZqZtDA+YDWIWg7gZuaPmB7E+l+ CnUKbXBktPgkvSxY5NEtYzCm+7t/rmfQ8ijLkb4vRcTFu90nAbshLvwRr23jx+vZHvWX o81yjBRnThfzfzJVZnx/kMLxajqbE9LMhsW96WAW4ChrasrbjCfVWb8Q8kVm1Sf4aSjX qQ== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7jvdbvr-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 22:21:57 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=T/+UhGhls0WWKUe9Iq2nw24ka5HVfd7fNWIxrwbWYeb0tWIOYtgbq+uXi8VI4GVM3pU7KTMSKx/zK8sL80hixKK5p/mhFM58C8GqHl6HIsmrp7WNFONmfuIpgItfcCLfMDty7nzy6a3DLpqJH8R+m/YpjyhhPCregQJ611cUHve40tyF3C39gqUv5+vHJqlLAXMO1tZB+WQkJ9juGFxgXDNJLy7Rvj/8Yp/JVZgofeXAqfucbu0pjq4F3AhoMyQGWN/CdpUpI0yxSU3SwfnDlU95mc64YEy1P6+Z1skbgQIrxZJMrZXcEG35OVVzssSGgHk3whreW0ZlCZQVGOm9Vw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+5ZIFcAXGaOEr6fcSRGPnoy06NRtoIMGpCCS8rABMCY=; b=IFUBgvB0uJPrRREB/XzwkFMLXlgBukk7FvIdOIIJz2Hg9+MvmgT22tsRXaxuu2Y7pjZbZ7glGZQtNYL9kUYAW7EyRo1RGAmuqMWzLk+66AbR26118oDhYYzj9K7vYaWvcst3IFdR4SdEVg+/ukr6sCYahEOzbE3rQwRx7yYMDoSbCT25qeGWiX3dP+Y9SaRfmC6mLED4KfNMTtxP1kYB/ESPEeQW5D+hWD0idiCGF8gbTIbitrDjEV0R86Nw5nUr161764ByYyUhnycGEAY4z/34XxaWKFKzJMEldFLqyMIqQdaVwK8LRBwlIN6VU7LaJJOCHcFeRgvBHduRm/KjAg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+5ZIFcAXGaOEr6fcSRGPnoy06NRtoIMGpCCS8rABMCY=; b=sG//+/ajOH2xbwJn34VzRmv9GctNnE3ZleXorCJh9ylNFmX+oHV5f/KXYSzFDfMJ3PgK19alcwV2yptXX7PMvUQipCDDWv2oRlp+SgXvdDSdyjeFk0EHXMQ8JFHfhXKPJ7jWUcQrkucxHnpAF9xt4eWDAflRQXHaeIuwEuH7G7IwzttqcSEbVp91QCV0a2dbPjvRC+MiMwZcGS5ZZA16wEdYf7TS12vzx5pwUGoWC4C/+0fLrcStBfQ5pmRruLbyhOykJQ940DbVqwblhU2VkaXFqrfk/Hc5I8QXOqD2FOWi/EJPwxH5WwgSQnpSJHoex6HtR1aoZe4JWI0JVj42xg== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by LV3PR02MB10006.namprd02.prod.outlook.com (2603:10b6:408:1a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20; Thu, 11 May 2023 05:21:30 +0000 Received: from CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54]) by CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54%2]) with mapi id 15.20.6387.019; Thu, 11 May 2023 05:21:30 +0000 From: Eiichi Tsukata To: paul@paul-moore.com, eparis@redhat.com, linux-kernel@vger.kernel.org, audit@vger.kernel.org Cc: Eiichi Tsukata Subject: [PATCH v2 1/5] audit: refactor queue full checks Date: Thu, 11 May 2023 05:21:12 +0000 Message-Id: <20230511052116.19452-2-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> References: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|LV3PR02MB10006:EE_ X-MS-Office365-Filtering-Correlation-Id: 2c1d83c9-5c6f-4339-00b6-08db51df93c3 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: H3bT0wh7FpAMW/x0PQDB7cDdlQ2XBWe3Y4L9VyIHuQmSBHczP9bTVnNvQqj1Qsyzqcnr6AMj8dZsVWoijC7S7dIpeq5r8k3LsvmorP5yjmfQvYicdmupZjgWsXhfOp823R4zLWxv5u9PNGgNXkKnJENrPRizP3ZvSx/1pZZDu/vKUBV8hrTztTXvPm21R66fSNgBobmIsna195fNHh/8wUCK9EdHNo4LAF80PDi4xyoXvfgYlx+QiP5LkCmoE0RvKRIiXX01Rq2AfgVXd7uQySU/v5n6zOjtZNErg2NzqSo7nv56q5JuPxXX91Bs1ZXzZWWx/32SKYPTgMn2fPyMiLFLYL72zd8Rndvsil3fbIU5RCupxdsSAlEumSpgZcfky6w74VCxUeKdh/ZWcLiOWyBRaMR3wmqYgvMCtoZH2JgwbbnWZATzcBuKRf5MUcw2stet6aGJ2cd/tGpgMevz91GDxHWBzsKpK/y3bZCAoO+XI1c/3aOFsLpH75Hde147awBQkx9wweGd9hiPNwQA5duJOMmKXoBqrdszgrPO1eAgTDMNRjWCDz9yZXRIiT/wyTWMIG54bS5b1yX2mZSL393hnXCgwjQkju/3KRNCJzcjZj7OT32e9Bg9tkGA5Onx X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR02MB8041.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199021)(478600001)(36756003)(86362001)(2906002)(44832011)(5660300002)(2616005)(38100700002)(4326008)(38350700002)(186003)(316002)(6666004)(6486002)(66946007)(66476007)(66556008)(8676002)(83380400001)(107886003)(1076003)(8936002)(26005)(41300700001)(6512007)(6506007)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: LQ8++nP6GG0cDygodwjIlJM/VM1cxWGViAo/A7J4pUxbGGIcGsXJ0WnUAO8I4fN38pGaPDrlApZhtlxCgPpCG6Comp+Fvj8IdZSWZS/aAD0TfMYJuw1jijEi7PVyirb980OwZujQO0j70yhHQolalF1uWBJzutBkbk01HwkH0EvMYXsHAQY1WQ7dKgG40FRqZbJD7A9UuzLaFYwGfxsVDEm8Iz8ZaPjRPEfSJ8qKJrtshy8bgWo7XVAerWFHDxSGXaW+AkJleW3WE4TeojBsJEgVoYY9+r7HAXIfUEm1Ld7yF79zOrgcnKox5HOFW4LGsQvtNU5Xmy94FoEVVeQBozq2W3uNZJDUBJ8eWX3DDENn2OGAm4yiT7BZ+NTNYTQOKA9c/t3hmaJLvpY5nqFrxCuJnteA80NNw7476Fr74rDWcNapy60RrS/Mi2gbi+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BW8vq1v051+u/yDkNpfTbf2YI92JO18M/5pedhVrQEnwTO2GXEqDLpAN/5c9hy3g9AnK3c8AzX3JKuW6cW9Q5vinoRjEIoWkcMLK9HZLoEIGbnSFt6Q== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2c1d83c9-5c6f-4339-00b6-08db51df93c3 X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 05:21:30.3836 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: pCLPAiblMbSN2uaYjKuynnIwHJydmx0CjDyUazIEC1qXYZb+2WZ+mU7SjOdUB2LdPq1v3+Q+pxh6mMP6q31ZQOH8nUDqSwaorWRsUNw/FxE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10006 X-Proofpoint-GUID: EDwqLvLmAYaW5GcQKTFa7kROzcwcwh_e X-Proofpoint-ORIG-GUID: EDwqLvLmAYaW5GcQKTFa7kROzcwcwh_e X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: audit@vger.kernel.org Currently audit queue full checks are done in multiple places. Consolidate them into one audit_queue_full(). Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 9bc0b0301198..c15694e1a76b 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -341,6 +341,12 @@ static inline int audit_rate_check(void) return retval; } +static inline int audit_queue_full(const struct sk_buff_head *queue) +{ + return audit_backlog_limit && + (skb_queue_len(queue) > audit_backlog_limit); +} + /** * audit_log_lost - conditionally log lost audit message event * @message: the message stating reason for lost audit message @@ -579,8 +585,7 @@ static void kauditd_hold_skb(struct sk_buff *skb, int error) * record on the retry queue unless it's full, in which case drop it */ if (error == -EAGAIN) { - if (!audit_backlog_limit || - skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + if (!audit_queue_full(&audit_retry_queue)) { skb_queue_tail(&audit_retry_queue, skb); return; } @@ -589,8 +594,7 @@ static void kauditd_hold_skb(struct sk_buff *skb, int error) } /* if we have room in the hold queue, queue the message */ - if (!audit_backlog_limit || - skb_queue_len(&audit_hold_queue) < audit_backlog_limit) { + if (!audit_queue_full(&audit_hold_queue)) { skb_queue_tail(&audit_hold_queue, skb); return; } @@ -613,8 +617,7 @@ static void kauditd_hold_skb(struct sk_buff *skb, int error) */ static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error) { - if (!audit_backlog_limit || - skb_queue_len(&audit_retry_queue) < audit_backlog_limit) { + if (!audit_queue_full(&audit_retry_queue)) { skb_queue_tail(&audit_retry_queue, skb); return; } @@ -1564,8 +1567,7 @@ static void audit_receive(struct sk_buff *skb) audit_ctl_unlock(); /* can't block with the ctrl lock, so penalize the sender now */ - if (audit_backlog_limit && - (skb_queue_len(&audit_queue) > audit_backlog_limit)) { + if (audit_queue_full(&audit_queue)) { DECLARE_WAITQUEUE(wait, current); /* wake kauditd to try and flush the queue */ @@ -1866,8 +1868,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, if (!(auditd_test_task(current) || audit_ctl_owner_current())) { long stime = audit_backlog_wait_time; - while (audit_backlog_limit && - (skb_queue_len(&audit_queue) > audit_backlog_limit)) { + while (audit_queue_full(&audit_queue)) { /* wake kauditd to try and flush the queue */ wake_up_interruptible(&kauditd_wait); From patchwork Thu May 11 05:21:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13237512 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8DCFDC7EE24 for ; Thu, 11 May 2023 05:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232848AbjEKFWG (ORCPT ); Thu, 11 May 2023 01:22:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42146 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236462AbjEKFWD (ORCPT ); Thu, 11 May 2023 01:22:03 -0400 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E391421A; Wed, 10 May 2023 22:22:01 -0700 (PDT) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B1GhEG028406; Wed, 10 May 2023 22:21:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=+B5ag8dFVtpwN0SZ5SqpLzscY+yNxQ9wFCU0/rDw4tQ=; b=iCMeP4YGIvagnDQxRUTLPhFmH+v5q1JLB3y3z0WbqV4YMbg3RUgH8UGpouYbIot9ubC1 T/zmKbpSDrK6VVGUVSSpW1NeQ3C8dQhFpiyXsLBmcHnGVy6MfckALOvSkyJRjLxiBcpG RzZF6ZwVjJDIiQbbhM+IV5UvQz72Tbpg/Vrdmx7c6TYkb6GJ2LX+NTTzH/QXK9oz7R1A RGaDrQ0sAiU7nlvVl2m4ftRkKbGonABM88GbPUciyeqmtVZ+LKqU+XNa0fwK092XwrLP m4FPH+d5o2Tv7DYb5w5TxW5hsvHuPdys8sCBQiyj6JFiHUk9U1CrUuRAlGfqn+uvsovs zA== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7jvdbvr-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 22:21:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fICjsY42UyToH4dHQ69KH8PW5G25fZlnCDBv1Ne7VnH+6AtuWEDThE+jBzEdk3zEAn7kyMeUoMHUIVQnilNTWhwTlPCZ4lUCDlMiJSXAzBNnanVgBB65WrWn+s6YNPz2PLN+kAXBXAQP+6XtADtljLUvaDiuCllaHOzq0FQ1AL7GAydQiA58rac0Y541vd1Stp/Nq3turHbg+OljFminPwxz+DcGpcvXJmrSmx4/73CnauxK3xL4I4oXUxKQnrTbeVNoSMEuEegRrBGpyCNjUpDFyp19MsFHp6h8GvHbohEF/jVNKxuWi6yfbh9Ywar3/CKZa8hFOtXsbk4a+dnWCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+B5ag8dFVtpwN0SZ5SqpLzscY+yNxQ9wFCU0/rDw4tQ=; b=bJ2Dxy2D0Uiw8mdBy24iRF/+VgcXYBMQUz1dz4YkXOhIEfaLf+gH22YQeuH7DSgPVXRKuoRt93mBzYEoogfNbn5PB4yRAXhxtS+ZLlQ/su6XemlEK5bGLz2EmBZa+KxV3bjzPWy4QrDEPVlxAEbs/fBVX6Pp8rk2NNdln3ofu9vxg8vL0zcElo3IIa3coFJNqnSUpzmQwCvgH2u4JV5rZ8Im5/1j9T1l2Co3wHXFDg13jdmjqGER5EaswafuAdE185+D0Xyl0DHMyWXBOfx86xn5oaHshS4dZ5DlBT+UTs8KCbK4GvvdqJ8/HVtLXB/lAPUTmJ/BDGEo30H57LZ1Yg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+B5ag8dFVtpwN0SZ5SqpLzscY+yNxQ9wFCU0/rDw4tQ=; b=klcv2M70+Ceab5lSntUdjE9MNXyZK6JCRjhQ+9M7PjoWcjU2Fv8g4ROxxUNFcfImZR6to5JPguMQFs4ylbr58KX+no+AUDB0k3nFnECGTHOb/+WZds5SR2EQz9n8effezinkKrWH3K4BmCbT3bNdRS2OWKLNl8mfgv283GxEAE6V+k6LzQ0+Ke2j8OE9Wy4xGo7EZkEdi+ereERdNJB6w7K5tURgGtVARHUJAhhzwjFv25V2y6kswOvqQS9uzfXXwYjHyaRZSxAFEeTgabTR18yWzkdZrPv/azZ/jUnOY2H7KTRGvux4NW4Y5WtWkhzysjPXtvZl6pM3EgQL1TKDMA== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by LV3PR02MB10006.namprd02.prod.outlook.com (2603:10b6:408:1a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20; Thu, 11 May 2023 05:21:31 +0000 Received: from CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54]) by CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54%2]) with mapi id 15.20.6387.019; Thu, 11 May 2023 05:21:31 +0000 From: Eiichi Tsukata To: paul@paul-moore.com, eparis@redhat.com, linux-kernel@vger.kernel.org, audit@vger.kernel.org Cc: Eiichi Tsukata Subject: [PATCH v2 2/5] audit: account backlog waiting time in audit_receive() Date: Thu, 11 May 2023 05:21:13 +0000 Message-Id: <20230511052116.19452-3-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> References: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|LV3PR02MB10006:EE_ X-MS-Office365-Filtering-Correlation-Id: b0fb040b-e18f-4f5e-b9f7-08db51df9443 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jHhWAqgsdm1iD1pBKgzblkcY/wyoBo0BcKhYeV6DElXSWluV+s2d2nGMaOJcypx5ShLVGFOW+KABo9H3LQk8BL39GnhNsa0R5mitqPwRXqyFUN9qvediNBL5AenOrApGPQ2IUY8yGUPuh75RBm22xavL3va3Bvy5ipWuqPWluzMDBuZLSXrmj0rauEl1tzxZlJuYPu/CSyRf1UquXW0BpH2achrszNFY4fFBnWa/VNAnu5aDaUJG46qNCGtpNQNvfhGHt5g8HD0sqYR3YtqG0H5gguXW3JmLahF+jPrDRrbaHpXcEb5sfjo2qnGesufGOElqqzbh2loxCbplI6YXSWsoQAnzaoGOCb0i5WWYdSsbWyLoiXeoeG2ybIhBHoZazo8SD04W3gfj+OzYTYHWWlamcBjGZqp8F2nfAc+iGVTmjhMq0ZGgbGyUVM8pZk8kHW6Bw+ju6MrJ2Yqb/uIJwih5J2kqxMtoar+rdyOWpzE96XjoswyxKo3DUnHmpNjskAJfz0/7mTwa0QzgesI9CBxptny9wvPrLNLjT8CXB45WZCWgsVifkV2kvFXsZuOnxdDJeuRnHqoQOek7XAMMCkWcspcnTZhAcaF6OyozlFu13HaaIvF+m6xMMl4MSn4X X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR02MB8041.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199021)(478600001)(36756003)(86362001)(2906002)(44832011)(15650500001)(5660300002)(2616005)(38100700002)(4326008)(38350700002)(186003)(316002)(6666004)(6486002)(66946007)(66476007)(66556008)(8676002)(83380400001)(107886003)(1076003)(8936002)(26005)(41300700001)(6512007)(6506007)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: f9zUtMU7TvoeP2MDqVUlhFUxFFuYOaHgpIBFNot4p5mWIj3W7rBff5gh+6RBa3YbrY5JdR+2gO5TX9uAQKohhiu0Nn/+vSKBKwkF0w/HsDZHuTqSdBNOjT9R4G5T7IaDf56wh9KVxM+8Hp/FwKtuncGs2aUctJwwwOwFix1wI8s6nCp//WPnreoAYTPU15K9tGy0Etu61kluJGGosaXt+OSeFEEWYappqq2nV8x8Q8M7JhBfoYEqnDvbyIsNe11c5imZT+lJ9ygOxthhfL7mmEKXUNslxxdIkTgc9Dk+8oqtrWtwd9kYmWgN9bZf4ngnwr5hTNC8grvk/Ot7NQ4ASs8UVo4iYpYyoqlEFFdiEhPviM6nIIKarDIRccoQaF2s61dfMSm3B60l6EkGFXQNcQzyee+LwzKP0ZFSM+kvQjUPFJ/S/XDZDAG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LGf8alQ4H8GV2kW2NLBIlo7d+hTMltkcm9WNNfTPyGBf812orw806AdqMQrf5Uk+x/T0Oi3jkdYZHSQ== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: b0fb040b-e18f-4f5e-b9f7-08db51df9443 X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 05:21:31.1900 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 3VpHfzq4k/v3VDCRyg2CsB2lGm6tsYsLOpDPAevlW2KbbFOvxHrJWLLUDpvJfiAfuMWqCJLIpBUSaDUJqDwueAZX7l9uQ/iTnqfDcb3JNac= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10006 X-Proofpoint-GUID: Xiv-k6Pkee_nLSfCgqpf7U8Cq47IRaiv X-Proofpoint-ORIG-GUID: Xiv-k6Pkee_nLSfCgqpf7U8Cq47IRaiv X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: audit@vger.kernel.org Currently backlog waiting time in audit_receive() is not accounted as audit_backlog_wait_time_actual. Accounts it as well. Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index c15694e1a76b..89e119ccda76 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -628,6 +628,29 @@ static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error) kfree_skb(skb); } +/** + * wait_for_kauditd - Wait for kauditd to drain the queue + * @stime: time to sleep + * + * Description: + * Waits for kauditd to drain the queue then adds duration of sleep time to + * audit_backlog_wait_time_actual as cumulative sum. + * Returns remaining time to sleep. + */ +static long wait_for_kauditd(long stime) +{ + long rtime; + DECLARE_WAITQUEUE(wait, current); + + add_wait_queue_exclusive(&audit_backlog_wait, &wait); + set_current_state(TASK_UNINTERRUPTIBLE); + rtime = schedule_timeout(stime); + atomic_add(stime - rtime, &audit_backlog_wait_time_actual); + remove_wait_queue(&audit_backlog_wait, &wait); + + return rtime; +} + /** * auditd_reset - Disconnect the auditd connection * @ac: auditd connection state @@ -1568,15 +1591,9 @@ static void audit_receive(struct sk_buff *skb) /* can't block with the ctrl lock, so penalize the sender now */ if (audit_queue_full(&audit_queue)) { - DECLARE_WAITQUEUE(wait, current); - /* wake kauditd to try and flush the queue */ wake_up_interruptible(&kauditd_wait); - - add_wait_queue_exclusive(&audit_backlog_wait, &wait); - set_current_state(TASK_UNINTERRUPTIBLE); - schedule_timeout(audit_backlog_wait_time); - remove_wait_queue(&audit_backlog_wait, &wait); + wait_for_kauditd(audit_backlog_wait_time); } } @@ -1874,17 +1891,8 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, /* sleep if we are allowed and we haven't exhausted our * backlog wait limit */ - if (gfpflags_allow_blocking(gfp_mask) && (stime > 0)) { - long rtime = stime; - - DECLARE_WAITQUEUE(wait, current); - - add_wait_queue_exclusive(&audit_backlog_wait, - &wait); - set_current_state(TASK_UNINTERRUPTIBLE); - stime = schedule_timeout(rtime); - atomic_add(rtime - stime, &audit_backlog_wait_time_actual); - remove_wait_queue(&audit_backlog_wait, &wait); + if (gfpflags_allow_blocking(gfp_mask) && stime > 0) { + stime = wait_for_kauditd(stime); } else { if (audit_rate_check() && printk_ratelimit()) pr_warn("audit_backlog=%d > audit_backlog_limit=%d\n", From patchwork Thu May 11 05:21:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13237514 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B6E87C77B7C for ; Thu, 11 May 2023 05:22:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237081AbjEKFWJ (ORCPT ); Thu, 11 May 2023 01:22:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42154 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236620AbjEKFWD (ORCPT ); Thu, 11 May 2023 01:22:03 -0400 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BC49444A4; Wed, 10 May 2023 22:22:02 -0700 (PDT) Received: from pps.filterd (m0127843.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B2umdn031008; Wed, 10 May 2023 22:22:00 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=DmrSAZVuHCrey5O9Rq+tNpzQRHC2Zw3e+d3VCs5pbDo=; b=UXcovzx1zUcas7khkACTxdVwQEBMiKFdhaeTztuYJN+PODe04D2wzY4OQ4mkTV1upMwF o+G5miYGNpMAQc1rYdi9nmTU8PUKYi7DrZCUusGrXDvSCeYcpDCNmgits41SJBNCAGba fOzQUZk3bpfPP+fOyGdXqzOhjEumoLU3eAgPUwEjeImlx3Co5uWQB+/L7QCIhLE1k/kg moUAGkGadQvnkQIAOecFQgIenBOhYuMSKmIP5jB+PaWBJvnRmMGXlG15KO1tb/Me60DW pJbjwcX1g7gKlwcd8XPhtDchaN8nV15RUkB6djJFAlUWRSAtGKlWSYF9EQIcCzcNia5s jw== Received: from nam11-bn8-obe.outbound.protection.outlook.com (mail-bn8nam11lp2168.outbound.protection.outlook.com [104.47.58.168]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7tbp81s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 22:22:00 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nM9BzgzsUKygcIm8KhMcvijRFIX+0EOAOzMJhA5k7+lrntBoiqce8usP6bDiJDhkZLZjRE8yEO4xxxxAV+krhlsF/dmaidbsovqR0K3AaWwgV6yhDHuhBBommAuNgVppV3g8m4qHb/fi9aQDs9fu8AKb9kL6n0ipRyuTlfAWphvg0j9O+mPCLgCBpBPYLhiCM6FWQ0S9em/RDprgf2l6lO5q8gJBss+Obcs4tlWlhrLPlUMARiISAB0Yxb/GPjnUvoQ73Js8hmZDnZFzx0L5+FubumJE7hjn48miVoMUOkPPXwMHyqvMrmM2IijMVZSfkWQknCmiNfSyPlRUby+cgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=DmrSAZVuHCrey5O9Rq+tNpzQRHC2Zw3e+d3VCs5pbDo=; b=hJLYGz3KfUiLTWUp79WG+o9S2T2+QgpVOtK5XK1GnmgITu0v5C00KjRU7UUNDnFRIfnAQJXxKTJ1wK1Vo+LpwdA0CrrMTrEM5jkqkmQhYPRA6X6eILzdUNFDQvaS14sIZThaY751kSzUfaxXLiNg6CF7xRDHQg8s4s9MR8Ywug5fZ0B9oOJ91vKbx/m59rEj8F9iLfNBX580nJsvkywqNF7R8pmLyKV8/5FLWKUaJltUzQ3b5LmZqN2fZJhoPnezRfN+bxE+EWPySW7f+MAks4i/jA6TiYUV8yLXWRbSeriC6HOWpfFRz2thSGcru57R6om4cdWtfHIRC48F2mioLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=DmrSAZVuHCrey5O9Rq+tNpzQRHC2Zw3e+d3VCs5pbDo=; b=Rmyty/Ht3+65k2lmubtaA+r5r/Zy8TKHz/lULlrTpjUa/x6Whq6V/E8T5+6WdXe2j0PZTHctJPMZDETni/0XAyjGKx71DFmQGmonbYijvF1W4it5tdN8/Ghg0ePuNUPWS/RI7ucuoGSyESK5Q+Jj5fT3RArYJycqbwWivG7zaqzvfk2xtcp1uP0qPFcK2kFkYsFJKYn7cjXnEuNGvhq505sN+Ab7b5h2lTAb3VKl0rXvXhZRhW3dN1HuqARtL/ItpyGgfcbmUhg51uI06AEeG/CNphfUKX02yMLz1WFXRfCd0F5duuPCGdOso3uAK3eLdki8TaArwpWxOAMkJBfFew== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by LV3PR02MB10006.namprd02.prod.outlook.com (2603:10b6:408:1a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20; Thu, 11 May 2023 05:21:32 +0000 Received: from CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54]) by CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54%2]) with mapi id 15.20.6387.019; Thu, 11 May 2023 05:21:32 +0000 From: Eiichi Tsukata To: paul@paul-moore.com, eparis@redhat.com, linux-kernel@vger.kernel.org, audit@vger.kernel.org Cc: Eiichi Tsukata Subject: [PATCH v2 3/5] audit: convert DECLARE_WAITQUEUE to DEFINE_WAIT Date: Thu, 11 May 2023 05:21:14 +0000 Message-Id: <20230511052116.19452-4-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> References: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|LV3PR02MB10006:EE_ X-MS-Office365-Filtering-Correlation-Id: 224db04e-07b0-4e18-aecf-08db51df94bf x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c1GbmqLwUlEFNoXPwVkFe5w5xSZpAROLt2mbBKvbG/HEO0omDt/r4mx2vmxyIUKy6SWV5U8A2E9bqvGG8vHHUkSP3tKZmxsFdBdIutaUUEkIhEyrofzBDzvS+Kq/QI5oxYVRKj7WNX5KzVTEpvxNJy6PotE8WD0/hBLJd6X7sYlcQ3vWdDC8PVGZjVXwbd7H8kJIhWI5OOMeZOqfCgJVorJPeFJJCXwsSrQQu7/mmWfdgx9GtwrIxKOukbQSL7Q6A27hyPro/IxRZLJY6aGCps8TgzeNAyZP19OMfP9ftAJZgsK+Drlr1Tgu7AY3hZ9+p/Z+GSz0KOCea2gYgbRayYmVD9BE3HXvrq9vfwfDP7gOAxV9LQqom01B73zcidNbWOgqzlmH0RK3bIQqZR44Ir5+sGNOz3KEFCg2BSA1fKlaBegQsv84EycoiUK/Ca8UWQDRcfCHLQOWuOhDB90qzjUaL8+sznFMIkqOunNcoexbIwPkk9sjw8fUhzs9Tx90TH4Wgw8VV9XRO949gx9NCEN9ZA7/bNwue/dQ+OzQy/7+ydZ087cGnmYe1sZM4IORdA4LKETzMt76g50XkM8nUP5G99D3qirvtmfJdPhC4txJLEfHdOU1Tf42xuasrdrR X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR02MB8041.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199021)(478600001)(36756003)(86362001)(2906002)(4744005)(44832011)(5660300002)(2616005)(38100700002)(4326008)(38350700002)(186003)(316002)(6666004)(6486002)(66946007)(66476007)(66556008)(8676002)(83380400001)(107886003)(1076003)(8936002)(26005)(41300700001)(6512007)(6506007)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ts1SZ8ulNxidivU6chHYjUEBGr5jjsmc1a+KwkyQrIMtMHeXt2L4vvAMRTlyKPh3UhLoIWXoFHHnO76D7vX4XiYcVzOcxH6YAi2VtmNS0hsWVjYf0jl7/dQMQe9zP4WJfFlnGeBLe8AOXJsZZUcPK7PXr4uPL5kppW9OYzOMAZVbX2Clsd+Pd4RPZIr5OR0zWUobMWvYKMg4eqj/dyd6q+5pve2pB5/2mnCKzbElRvErOmGgIcVSnVxw43ubzd0cnWwsYxS6aeZFltEMUrbAoiZEU/mb7IKb2TNQv+JuxZkx5EkUMf1jhaF0+DhIlHvo3VgJIijOA1fjaBnfNYxip3bIOsfGbKQ/Z67Pw8sMcACV0OqNx7nvHOihEVK814rwvDbxJ74OKHlX3/KL5t0p4N+5nvW8tVAPk1Dm3JeH6kdTQ32LjPnW7ec1R1y0/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N3xUnGhpYKOckA7vOzdsZ+7Hv5anaSL6SG3+IR22Pv89za5FpiD4wWGvaMcguihooujGl1nZtTNhO2pdAz9hlaFF3VDg== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 224db04e-07b0-4e18-aecf-08db51df94bf X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 05:21:32.0433 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: t8TFZwA0McWm2RO4Ag91R+TNdO5RVMpgBEwP2+5sbzWoZ0Ykfeh461YvkUBGGpd1yeWyRatQ3LWx8CSW1NEQLWWae5Yi4hQonVPf+2CvCEA= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10006 X-Proofpoint-ORIG-GUID: 4cHUNpz9ONHELrYwMCm1rTV5MLw7j-mX X-Proofpoint-GUID: 4cHUNpz9ONHELrYwMCm1rTV5MLw7j-mX X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: audit@vger.kernel.org As there is no need to use DECLARE_WAITQUEUE, use simpler DEFINE_WAIT. Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 89e119ccda76..bcbb0ba33c84 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -640,13 +640,13 @@ static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error) static long wait_for_kauditd(long stime) { long rtime; - DECLARE_WAITQUEUE(wait, current); + DEFINE_WAIT(wait); - add_wait_queue_exclusive(&audit_backlog_wait, &wait); - set_current_state(TASK_UNINTERRUPTIBLE); + prepare_to_wait_exclusive(&audit_backlog_wait, &wait, + TASK_UNINTERRUPTIBLE); rtime = schedule_timeout(stime); atomic_add(stime - rtime, &audit_backlog_wait_time_actual); - remove_wait_queue(&audit_backlog_wait, &wait); + finish_wait(&audit_backlog_wait, &wait); return rtime; } From patchwork Thu May 11 05:21:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13237513 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 010FCC7EE25 for ; Thu, 11 May 2023 05:22:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237068AbjEKFWH (ORCPT ); Thu, 11 May 2023 01:22:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42148 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236549AbjEKFWD (ORCPT ); Thu, 11 May 2023 01:22:03 -0400 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2473448C; Wed, 10 May 2023 22:22:01 -0700 (PDT) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B1GhEH028406; Wed, 10 May 2023 22:21:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=VRhBMDy/VXc3DvVqhsN3q5HlvQZweB84L1nP6EktwNQ=; b=DkI6LVxg+ME5e5jDVx7iWMCJLp974SFwnf6GbXhE8dLdRPyKrU3ALs0+V4SSyOxCQwZ5 q0NEt/rpnEtwG5D26cn0QZXnKFqYglbVy7BPLb0nmz/ZXY1srmgL5lnH0QePuKq7jPE8 PnHdQBC7IpqWqaASaSVXoKAsPoYx8T6Mms7dnm2fRJ+8mQ2X5BI78at1TX/6qJFkWb8S VO4/BVR5NyUqvnbDLtRacdd3NJUPeHj4Sk9iRRvoUYya3he00JkYjSmGxi7+KT1bo7/L c4Opix2SZttrjK+4WpKevbm0U10EP/OT+lKNuNKfIEtJKd6n3fC+YABsJqtiEPerOxlN jQ== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7jvdbvr-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 22:21:58 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HCrSLiv4B/2Gy7p+MGK4BEEFvZfxMiNqDttFgT8eAy6IsNj4qHszqwNmkew3MZX/6SdZdtTXeSZQG+IydlYI+AwNUbtqgvsd/EzCpfl/+OkcRRDqmfzh7zPjS4GoSA3lvzWcX4fXzS2QAjbCO1g2n4gPdP1WlTiDwLSyz8uCc4CThuILYfFBG3TZ8v0Wscq6nzHSCXqwpAkeg+u9jM2+9Xu4wIEeWRZ8uDWPD76FON7E3JDYdYnp8byt0bEINzei5RvZ0B89iGKilMlpjTOC9w8LJmEPVT42FePHWNGRInQ/oPFUFORoEknOtnLroTW6m3nGb0Qeqml4/HnIEZu+RQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=VRhBMDy/VXc3DvVqhsN3q5HlvQZweB84L1nP6EktwNQ=; b=KtVaUA+uZd6bzIV9JrUhFa9b82ny3ZRss9Yyt7u4uyYHN49dE0YGmGBlNMaKWhuU1w7liGhTyNqYbSgn8C0YcF26ejlNOs+5jqX4uZYONALD0TiUsWL//K+kFccjHr2nuThLEWfh1/C0YCppcY+f+QGgAqQfTidTyPYvepweWkU8IgILR2ZSMgScV2VUtb83+IGUObckZxd8+gss9ORSbMLPmvOfOugJnHx9ePzDw9XZB68z8FDZlysaJ6zFnjZZ/1FOKU4KnVZFRyIuYE4bSLK5UZZhKvkD/Ln+fy6HpjatL8ob1AMbRaEewS7IRNzha3C3tsmQ83472FQP9TnXFg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=VRhBMDy/VXc3DvVqhsN3q5HlvQZweB84L1nP6EktwNQ=; b=dkFYcYwyJQmNM73qH97Qbz/LVDJm0YmIC/AXc4cXFtgg2YFIHJdnbraLSlA/r0C7rwsZ53sPbEWl/WuJVDkvcCLMA4Rqau5f+8wzfIQgyt7JhBIgGRhBxhDa10kcegaXnFRdWw6u9bWdBYZ+HwzETyVY5J9zvyY21uUcLbmnBvUQJHQrbIjFr7JFPsOSiJMsyuJ7/2ywVpiicdBaGSpoL9JecdiVBvOGx5QrBJ8jQQhflKjsxICXJdCvCA3uXnOfVLbfc8jpcc/N3atUz7GCTMiy5NzO/kJ6Au/DdpU1t02X1pQ/YZEGagVpY1OJPdBckweOw2112f3Mjx1Vecrslw== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by LV3PR02MB10006.namprd02.prod.outlook.com (2603:10b6:408:1a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20; Thu, 11 May 2023 05:21:33 +0000 Received: from CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54]) by CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54%2]) with mapi id 15.20.6387.019; Thu, 11 May 2023 05:21:33 +0000 From: Eiichi Tsukata To: paul@paul-moore.com, eparis@redhat.com, linux-kernel@vger.kernel.org, audit@vger.kernel.org Cc: Eiichi Tsukata Subject: [PATCH v2 4/5] audit: check if audit_queue is full after prepare_to_wait_exclusive() Date: Thu, 11 May 2023 05:21:15 +0000 Message-Id: <20230511052116.19452-5-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> References: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|LV3PR02MB10006:EE_ X-MS-Office365-Filtering-Correlation-Id: add1c49e-eefd-4d5e-ca57-08db51df9542 x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7Pv9aDHlqvsZUqpm7cRui8VsGtk2g+Sgm3EqEUtfZQLh7ZcvRoGV7UhjQ5PDAPA4l72qkgB7fhORNa/fQqLiccvza10o22M17x5JIakxQXMofi6JOqXNECeUCkADHCEW+1awTqNWSdc4DJPoCoImFv3GFC6PBa2EyxBsSj41dnYLD8BI/5jsKjWr1NF0khobKUSAiNSA+vnGRieGt2dWe5cBFYPSNym3SLzA/0lJj1v5Vj7N7izMtl5+MuzRuF2+vXWrZFztzDELf30g/+lisw7gIYvHCtVA0HuJuv7S0Uw93JMwBzgN3i04aIoKnxQ58A2Ctp6MWyzIeVf/H6g6raLZQ0NgRVGINRgtFPwCjrMHqu1WAvP5S15WWmEfuBeHfva/RF7Dlxb2WMsR2YDmkc7akkiUJouuElkTofDwGOm40+V3W3zhnykHDKRqTTmTNmRKsSFX1Zxlw3bHZvapKRLVt1ERVqKTag3aOAYncC5G8iP2DJnHFwdB6Q7Zb6eSKNzcKDJEsshEqTiN0PXZhbcjRQGvoOXa7WVIEsPdGnpHBxywN+VcXMSlHG0KD1fxRtQyCiZ+eAxX0yBgc8vdKVkquJq+E0xpDPEDkCJKeuj0MqUiZGRzxDZOOFQVCvkq X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR02MB8041.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199021)(478600001)(36756003)(86362001)(2906002)(44832011)(5660300002)(2616005)(38100700002)(4326008)(38350700002)(186003)(316002)(6666004)(6486002)(66946007)(66476007)(66556008)(8676002)(83380400001)(107886003)(1076003)(8936002)(26005)(41300700001)(6512007)(6506007)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mIL9fJ8H/i8dHStcZ5OEcL8D4isQhIZjgv4cvDOVAE4be1/3ot4LSx4Z5wSrK97q5IHoD6IwO67eVVpEwPvOst/aX/saKtK3vrFe7+NYI/mFrKKG62FLFIupr8q0REaIFL24N/ttll4m1TSIv3Ew5uG1T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ZcebyKPIv4u7iOJRVkue3a9ZLPnMPbCF4iRhvwN+RDyQJE4qUlBEZ07QVZyODaGAvNOnuMI11ZbAUuyQUl2RgDEr2zsGflK3C3H1eoWkEWsePBQhDCw/OIi8I2QS9Yq23UxhHlLMJgg/sRSNiepsMhEmM4YY9wlPhsd2eQIFLJsWdhyRXVebdbca4CxsVRO1VR+x1KUtpkXlTFvEeic1udcdP2IJrkuYKsnS71dKhgjEh0isFmu8bVGfPsuzbYvfoVlfOGxmL4rKOO+qRa1WGs/jan07mUCcZqiGBhF3IQrPbshxMLov3Stmkkp1P45t6El6AQEwZehBQ/3ASZMoLa7wEN7yFnVqzEDgSUNEdp/JzI/xkW5ubFUTvkBtJqWA== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: add1c49e-eefd-4d5e-ca57-08db51df9542 X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 05:21:33.3376 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: bOvuKFRb4AuJFMvp3mQc1C2fRpVVzYFcqLB6MGjLbsKzvvibIRzvZ7zp/XhY/UG+Wxgyp22pc7xfEu7BWWo8XSiz1BEOm9FKuvqn3wX4740= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10006 X-Proofpoint-GUID: -nyFYXnQwO9YPhJFLetDbNPUdXKw4I9z X-Proofpoint-ORIG-GUID: -nyFYXnQwO9YPhJFLetDbNPUdXKw4I9z X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: audit@vger.kernel.org Commit 7ffb8e317bae ("audit: we don't need to __set_current_state(TASK_RUNNING)") accidentally moved queue full check before add_wait_queue_exclusive() which introduced the following race: CPU1 CPU2 ======== ======== (in audit_log_start()) (in kauditd_thread()) @audit_queue is full wake_up(&audit_backlog_wait) wait_event_freezable() add_wait_queue_exclusive() ... schedule_timeout() Once this happens, both audit_log_start() and kauditd_thread() can cause deadlock for up to backlog_wait_time waiting for each other. To prevent the race, this patch adds @audit_queue full check after prepare_to_wait_exclusive() and call schedule_timeout() only if the queue is full. Fixes: 7ffb8e317bae ("audit: we don't need to __set_current_state(TASK_RUNNING)") Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index bcbb0ba33c84..6b0cc0459984 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -644,8 +644,16 @@ static long wait_for_kauditd(long stime) prepare_to_wait_exclusive(&audit_backlog_wait, &wait, TASK_UNINTERRUPTIBLE); - rtime = schedule_timeout(stime); - atomic_add(stime - rtime, &audit_backlog_wait_time_actual); + + /* need to check if the queue is full again because kauditd might have + * flushed the queue and went to sleep after prepare_to_wait_exclusive() + */ + if (audit_queue_full(&audit_queue)) { + rtime = schedule_timeout(stime); + atomic_add(stime - rtime, &audit_backlog_wait_time_actual); + } else { + rtime = 0; + } finish_wait(&audit_backlog_wait, &wait); return rtime; From patchwork Thu May 11 05:21:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13237515 X-Patchwork-Delegate: paul@paul-moore.com Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8501C7EE24 for ; Thu, 11 May 2023 05:22:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230004AbjEKFWK (ORCPT ); Thu, 11 May 2023 01:22:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42156 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236759AbjEKFWE (ORCPT ); Thu, 11 May 2023 01:22:04 -0400 Received: from mx0a-002c1b01.pphosted.com (mx0a-002c1b01.pphosted.com [148.163.151.68]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6508C4498; Wed, 10 May 2023 22:22:02 -0700 (PDT) Received: from pps.filterd (m0127840.ppops.net [127.0.0.1]) by mx0a-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34B1GhEI028406; Wed, 10 May 2023 22:21:59 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : content-transfer-encoding : content-type : mime-version; s=proofpoint20171006; bh=qSeiFqRDyvUfOLTBCCuTT01z/WuLi6I2M7nNRspoGMw=; b=dj3J9FvYt4YBA3bi6wyxJD1jOw0z1Mlnz15mSv86nm4x5DnJZDRJGLn2qv5H5zT23QW5 D62Ry/ML3oUrmhKrg8W/Us/9jtcbGcQ66K+SC1ivMQAmQXxuM/Kiu7+jNF6KJxuHyBqG kjDgPXTCkL16xyKuAq+ZpLPjoZ/iKafj+CdXbuYc4PkXkFZcXVkuGi+jOLmAdE/+NUG1 Dj75WkfwsDErg/1EKD1IcfS0dbeacGS6VIscLjKvkuiNnI1bB/Hi5gL0a2VALZNl0v6w 2s604DMA8dzA+OWCTJuu1X8niZIpaj96PJHP4sLS9Pd52UVcc5C9E9HWgHF6o4S9QQ8n uw== Received: from nam11-co1-obe.outbound.protection.outlook.com (mail-co1nam11lp2172.outbound.protection.outlook.com [104.47.56.172]) by mx0a-002c1b01.pphosted.com (PPS) with ESMTPS id 3qf7jvdbvr-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 10 May 2023 22:21:59 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jh8hdmFnev7uDzYMCSKqxTKfDBrkmLqGG/UP+n+ss1xAWQjjw0JD/e2iv+4i/0d5Sc5V19KHh+doRHgOPsC66KJ+8lu4/3DL0K1SEVD8hWBovLnPWb72c5yc4QjHscFk1Y/44JN2S8Ez1gsZj+vDb8f6cH0iG08b9T6eUyvd+9253gyaombMHK+2NZySfEzlm00zcnf7VjkSliU76alT27aWIJFTe1wzH7MTACfTJuWu5s/vU84dhYcdvfFF74reUw750oXpuftaUfYDliao5P1x7r1hUxjLtX6mOYrW8WAs52FqLrn9s+x1xyhxaNrk3u75yDiJ2I1Kys4eb212CQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=qSeiFqRDyvUfOLTBCCuTT01z/WuLi6I2M7nNRspoGMw=; b=k8zhcQd32SpC45ZnWF6K3BjMCLoqTyHgQzwUcJxghH03c3m9U9FPO5KAZ1dCfqYkOHgrRtliLbzp/qx2Lrv19pciojJx+FMfdFevEHJF/q94zVakR4nVv2sEejl8o0zBftEXqSC5savQ+JsDBvs4sWGbzriwvNSmRXjOB50AFZcttXkkqiDN6Y6td5iinyvTspXNmvgIGbGQQ3N9YKVg3QKPpz7iQKcbsTJE5iWswKWbKex2w28IFjCjDKM4hHpN0j6/BZIMlmcg1SAVxyh6actniBFBrxF0qWUwkPK7+BDtMRcnlcYTHI9j2PELtGsH4Pi6Oh6dTKenxOMViIIHOQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nutanix.com; dmarc=pass action=none header.from=nutanix.com; dkim=pass header.d=nutanix.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nutanix.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qSeiFqRDyvUfOLTBCCuTT01z/WuLi6I2M7nNRspoGMw=; b=WNoL8cQhF3aT9aQY9Tg94/DtxamOFlU1hpwaL33ReAfaWQskm7qLuzykk8aEJ2GZulF/GAk8oT3qLfdyI5nrZhvINx6JcPCiJhDlsc6msPYPtGxivmMk4Er40Fcy1tH98wMSQG2jmzzQtk4GMVZD5CDA/sxtyiRLcBV2jURy2jPxMLSQSLKZclKQ/BoeLQtgkjOsys9PIfqtBKfTrzpyi8tbBiOvHmf+MPIfcFV7zxSPclOku+nP4c5RZ6iB1ZCp+eYgfpJN6kypk/005vhPyXUDwcSBjXu/IKqgEGVfLqXMIYQ/VUluI9wlHBTg/w3c78oxlpdV/4vi6Fw2lu/wsw== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by LV3PR02MB10006.namprd02.prod.outlook.com (2603:10b6:408:1a1::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.20; Thu, 11 May 2023 05:21:34 +0000 Received: from CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54]) by CH0PR02MB8041.namprd02.prod.outlook.com ([fe80::e48:dd5d:b7e4:4d54%2]) with mapi id 15.20.6387.019; Thu, 11 May 2023 05:21:34 +0000 From: Eiichi Tsukata To: paul@paul-moore.com, eparis@redhat.com, linux-kernel@vger.kernel.org, audit@vger.kernel.org Cc: Eiichi Tsukata Subject: [PATCH v2 5/5] audit: do not use exclusive wait in audit_receive() Date: Thu, 11 May 2023 05:21:16 +0000 Message-Id: <20230511052116.19452-6-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> References: <20230511052116.19452-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: SJ0PR13CA0074.namprd13.prod.outlook.com (2603:10b6:a03:2c4::19) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|LV3PR02MB10006:EE_ X-MS-Office365-Filtering-Correlation-Id: 5eaa4a92-191d-43f1-6961-08db51df960d x-proofpoint-crosstenant: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cYI9r3aFf63K/gfkzlECBGXbOu4gjaopyBtEXbxRZFqjELKrm0dzt1EyfKC4C0NQTDnr+fKO5CAXV3uAncGbksRFDMEOCOoCmAYdhqBWX7Cj76yY8KozrwGh2k8R2gwyVgSM7x2pZXxxtq95hR9sw35LDIgv4JTHkI95VTHFQOrY1jCW/SQGFGtNYAyz09XyD8JOatO0EDOzgcRxztJFBFTceLgma603cGnVfKW2rrxPF8Qu1reb0oq8D8num24jorSE8VKV3wq9CZRFtUKiEwDx/nfv5I54TubZ9T7yKMJ3Qo/UwwwMpLwpt8BTSSfgDM+hVb9ZSra+VyBnrF9Uowx8rgThqqaIOtcYWOX7aAuxCfQu1Rya7Erisqx9XKo+Os8h/CwtHmWmFBgQp+JNTRCIsrnVCcR1LtxPDFSaWoNfs+aBGkjr2ojwIrngcX87rghLAWAYGGcPz1v25O8SoKzha87YuBvmZ2AcvbkdahTqwGYJGegg6PJ1j6vu/ubcm7ANU8a3u7PPY7/HxJkwo7i/W5ptIrniDglghglPg6XMMb48cyVF3MMIJ6NyWHr56OiqW4jgiw1tWNSBRaQoqb6EmiKEX+slvCaJTyO64mDdzdl6Rs+w5vvy+tG6JDic X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:CH0PR02MB8041.namprd02.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(346002)(396003)(136003)(376002)(366004)(39860400002)(451199021)(478600001)(36756003)(86362001)(2906002)(44832011)(5660300002)(2616005)(38100700002)(4326008)(38350700002)(186003)(316002)(6666004)(6486002)(66946007)(66476007)(66556008)(8676002)(83380400001)(107886003)(1076003)(8936002)(26005)(41300700001)(6512007)(6506007)(52116002);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: cpW0K41iPOvc28Pl8sj9uJb7m/uPqZQj+e1blfUnQU/q1dfXsFDn8WiNYaSp1uvm7KQ4xCGNGvpjW9qytJ9Q831b27pMcH2Fw4HxTWiwjGf+xNbjoiHxWrhrB/YiVGi86loeY32fR2YHeoLw/ywTkYE4KAAJB/md8JlfeVBHx+rzvz9exE9oLtEVsjCcyhOYIFjUNomfHLyrYpZIqHlc7XjdMjuZXQCgcFoaCrJ69VR4+TcnVGt9fiPSm3Vz/ICKek+9ZeQCLOJ+oPKrZSWugmFbCB0JCo1jpPG/bZ71mwtvB5kb5a7nL7PXaKxAtqoID0hFjm3i6jz9GAXqyHbPMHrBqLoSyHGOr4m4y2+E/YmolFsig+WzRPeTCRvm4TFok4U9GFo4lZ+BskJZyGSQlNwzm5FNb4wZL3A0TOP06lixEb2+QVYET2eSBihcTtWVU3xNCynwgR2au27mnugZW53W1A7D0phtxzXsAmFcnfAD34wWCeEoA94qDPwzjSbco0tdb9ugdlr+csBw+G3jpKLaCO6cyitEwxqiQrUKW0Vr9soZ64VESyE6YBEdyHcBtVBKvexB5aM0aLXeJB1bwlENnopoVUDkXTxt0GMUCNfJtWzrDSmni+QSWh3f3r3g56ygI2mWu4Bc+mtLAP1j6nHsikMTDkgHQ8iDaMnZAVLDM/MKyTyXAj53o7r3sU5GtTbXBoowP6JtpHxpPDV03ws4ZYhR1uySxqmMSgLgcd8ilIccKUCZyXz/xaahroVhFmLhZGY22g2a4ThyzgMKEOw9+QMmtdLOAZ+fMPid7DGUYP/vhD2ob1blrrSQKjQapv6ojIc7XQpEFBjhBhOOESgIPQCxbeT27VFmj4S0ZvINmnBlNPLFCERjZQrwjO6NSkcyrrUttUDBHVhl5zLOurX2T52G+DZaXh4sNAzbOBgGD62TDM+rBxiDc9PMNle46NHx4tvVfpaUmB4ExTJgKWF3ubWHO3F/c23UM4W9AZg8W3FWYekJ5aj561ibdbvGJ/Q3pg1V0VJKUyu+kAtts4aa2ZAw+eJuw6NGBEzrfwr8bf2uR1rAmzsEhEfuPSEKVCp3kmUqzYToIEJHG/oNIcSn1Im8snkFg79kaW9dxXm3fEkXN1f1TCiEP683KmTYIzvrYBZnubjA0KKEEZB4iiM3PCZp41X6q0rigEFZA7b4wpzdaigxvs5rFzly7zQVJKOHEhyJReTNQbHrkXSCZCm/1Rd3/iq0cd5MHUCAxZhxU90ugLqkJIJJEzMBKeuQvy/Eh0LAMYXi7wcFOv6dmyZjfupw5wCUm+4F6W4hT42Cyc3OyiSDqekYkgiPz3nYCtWCYdUfYdvyDg3phAqor4LX/5gcU+cj1tBfsGp4LY1UzhMVhb4l+wpuRq875psbFY7QuqA2367EeZVAsR/55jReTjmdBz7OAShLRcGmkSJwgX9OHf8stlH89IuIa1n99pGkwmkRmAM7mGrt3tUhke5UXrGLRvLBdwKcbgIh/tystqz4t+Rudi5FuSTFt50zZDdpziySVL8XMuVF43HPnAXut2xAVMTW3dd9BYOQmmDQ/wUrHQpyacMcwYOjYWaEQvhcie4ddspeCWFvPSMe/A== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5eaa4a92-191d-43f1-6961-08db51df960d X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2023 05:21:34.1358 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bb047546-786f-4de1-bd75-24e5b6f79043 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: NCTZ4iegDJiTDqSnX0M65gybjYL2OmfkDlouUPKsOv6RJbibq2iNJDFcR4ayIbWCVqEbmtR9R0OUV5l2XI3k2+8tcQBuHnhp4u7zZDauWR0= X-MS-Exchange-Transport-CrossTenantHeadersStamped: LV3PR02MB10006 X-Proofpoint-GUID: rQaDxQovDCV8cydJxqN48Bjz3J_66dou X-Proofpoint-ORIG-GUID: rQaDxQovDCV8cydJxqN48Bjz3J_66dou X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-10_04,2023-05-05_01,2023-02-09_01 X-Proofpoint-Spam-Reason: safe Precedence: bulk List-ID: X-Mailing-List: audit@vger.kernel.org kauditd thread issues wake_up() before it goes to sleep. The wake_up() call wakes up only one process as waiter side uses exclusive wait. This can be problematic when there are multiple processes (one is in audit_receive() and others are in audit_log_start()) waiting on audit_backlog_wait queue. For example, if there are two processes waiting: Process (A): in audit_receive() Process (B): in audit_log_start() And (A) is at the head of the wait queue. Then kauditd's wake_up() only wakes up (A) leaving (B) as it is even if @audit_queue is drained. As a result, (B) can be blocked for up to backlog_wait_time. To prevent the issue, use non-exclusive wait in audit_receive() so that kauditd can wake up all waiters in audit_receive(). Fixes: 8f110f530635 ("audit: ensure userspace is penalized the same as the kernel when under pressure") Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index 6b0cc0459984..ef48210343ae 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -631,22 +631,27 @@ static void kauditd_retry_skb(struct sk_buff *skb, __always_unused int error) /** * wait_for_kauditd - Wait for kauditd to drain the queue * @stime: time to sleep + * @exclusive: use exclusive wait if true * * Description: * Waits for kauditd to drain the queue then adds duration of sleep time to * audit_backlog_wait_time_actual as cumulative sum. * Returns remaining time to sleep. */ -static long wait_for_kauditd(long stime) +static long wait_for_kauditd(long stime, bool exclusive) { long rtime; DEFINE_WAIT(wait); - prepare_to_wait_exclusive(&audit_backlog_wait, &wait, - TASK_UNINTERRUPTIBLE); + if (exclusive) + prepare_to_wait_exclusive(&audit_backlog_wait, &wait, + TASK_UNINTERRUPTIBLE); + else + prepare_to_wait(&audit_backlog_wait, &wait, + TASK_UNINTERRUPTIBLE); /* need to check if the queue is full again because kauditd might have - * flushed the queue and went to sleep after prepare_to_wait_exclusive() + * flushed the queue and went to sleep after prepare_to_wait_*() */ if (audit_queue_full(&audit_queue)) { rtime = schedule_timeout(stime); @@ -1601,7 +1606,7 @@ static void audit_receive(struct sk_buff *skb) if (audit_queue_full(&audit_queue)) { /* wake kauditd to try and flush the queue */ wake_up_interruptible(&kauditd_wait); - wait_for_kauditd(audit_backlog_wait_time); + wait_for_kauditd(audit_backlog_wait_time, false); } } @@ -1900,7 +1905,7 @@ struct audit_buffer *audit_log_start(struct audit_context *ctx, gfp_t gfp_mask, /* sleep if we are allowed and we haven't exhausted our * backlog wait limit */ if (gfpflags_allow_blocking(gfp_mask) && stime > 0) { - stime = wait_for_kauditd(stime); + stime = wait_for_kauditd(stime, true); } else { if (audit_rate_check() && printk_ratelimit()) pr_warn("audit_backlog=%d > audit_backlog_limit=%d\n",