From patchwork Mon May 8 07:58:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13234194 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 0C92FC77B75 for ; Mon, 8 May 2023 07:58:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233630AbjEHH64 (ORCPT ); Mon, 8 May 2023 03:58:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33870 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229999AbjEHH6x (ORCPT ); Mon, 8 May 2023 03:58:53 -0400 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E35B9036; Mon, 8 May 2023 00:58:52 -0700 (PDT) Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3487QqkH011998; Mon, 8 May 2023 00:58:49 -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=c8Z5x9+TFKK1HnH7g4bfDAG41bjVGVVVltgsthZaNT9+6GNDfiN/eeG84j/L80lGitAd gIA7f5ZiD3DBCh8TAlGjdBNm2JaiQZ0axM092kZWrqe4KyX+khugUT3TIF+rT1cDfEVt Vw+PphrtcZPRLv3Pwv8rhpqNrSz7E2HCgus4y9wT86PpT4eW4BrGcVU101rKDcWH38S+ hWCsvrkbzFEIYjwkanqdDj1bucTFA/afMHZT7MWueYL/Dr49T1KuhcWdzeD8Kf2s9BzN y6462MqSFizuGNwrmfED4a3QE7F2h2SxR1IWx666KxGK3TPkldNYCy34ckwHLgfwFnGO sQ== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qdpe43n4a-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 00:58:49 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ANX1N8usmCIzUOlZpL5jCnNRX1n34900FjZEgy0tVA0GRJLw92W3Rsa0VjWZqBq+mQkxj/a2DWrAzrVK0OppPJvbqNY/6+pVCLD6Niz+hsCE9mw230qiIJ6IMInXmEhanNpdNyjB+VVc1PybwEiLZLYU94DmSqk5x5XXgxMosKhu/ZAHh5xKuOFZUqv5elayXeHKd/+2QPAb/JP2tc/OwH1cGsSfDo9JlODDGA3IpiMNzyWfmoG/+/Oo4yBJreZLcRvFPjlPRVLqlo/iH2xi1Galpa9Zc9gJsOOFSaH4s34GTJj+GkJW/wC4H6QBqCscvSBykfUCfvj0Dcn0/WiHww== 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=aeB8elVbC3S/gWAjTAsjZ5AMm8hvI16kx+ajWjynI62J0nJbeoi6UnLmAY9TLR/wBfPbM6OSG9geyE5C1ZaI2br3PK7eSLXDVq6aqO8DgBkbjyF+YJ0sb5fKWzpy1lhaocXfZgW1GO9Oy4amcF2ffrwidWD8dTSdET6nYdpgfDtOh6bIPWDpPztYujL8U4xpsRaOGIE1GMxUdhAMVn33SjfDtr6v5sD7rQLiC+cyr/q08enSICfWJH+MPuu2XPqR0MhQCb0op4jd5uQ4kfExG9ext6vqKCLlHwv61IXQkSyIHQknLESYhTWlBXBJACbnTVI9O3P/wGYPf6YuEuZ+3g== 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=KJamil1AJFUaATJCaDLzjFwyZE8+kvlusv17OW39WtR/cNM/S7hQaPPWpR0PsF96LjqOt72m1dk5F9JCVWHoRY+s6E3ImbFCk3FPNlxYMWyqXZC3FFwTHg5JBvi1TNlGf7Wj01Vvji//eGwTR1eeCBUgQfaC8BR+OxEbz8lJFdulI6xd/Ex0kq9vCmuWKWFPqrT47OcSiemPCwkuqMuDmje4L27NGXznhaOTx3DSigqbzLtQDAbEtP3yVyIIkHm8RwB6/hpvJLf5EsTCoAKPkp+Qa4nbzeZf2ZSG5UsdaIhAba/lUBobgkV0qkdUnpve0zgzTMnaLWso5dsFDaqRtg== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by SN4PR0201MB8821.namprd02.prod.outlook.com (2603:10b6:806:201::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 07:58:46 +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.6363.032; Mon, 8 May 2023 07:58:46 +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 1/4] audit: refactor queue full checks Date: Mon, 8 May 2023 07:58:09 +0000 Message-Id: <20230508075812.76077-2-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> References: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: BYAPR08CA0070.namprd08.prod.outlook.com (2603:10b6:a03:117::47) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|SN4PR0201MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: 73e9b20c-5ea1-4916-f7a2-08db4f9a0d05 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: o3XCBNnrheKatITZaBPX6jkuml0Xl2YRwbA/AjS/1ZI9e70TiXGmyjCcmUNAz/nu1WZnslYmc/cNexe1BnT7AsS+YUo+lmCieEkvnckdtROtZXVUY0TlUe6Yb94XR/IjW/4x5C1nJzmkLHQkky0SbyysLp5YtHLKVIDc7MMacUZwv6X1X36R8JYuAQVHXIhG1NcCs+xwy5mUgd0PCINuKj5TBmkBWCNqNd/QqYodkel7WnOyhf58/JPrMj3tR2qBJc8Z9+lOfp6FVIGCoY6A575qiJh3gtXYckot0+MvP/UiEAlxSEnEISLxuv16Xwd9eH/euYL8ehpRUDTwv0qJb3OWD4foz482HYv5VqlLOQw+heQ84SeynTwYmV70sZ3Y5nUhAz5OqeDH0K8tEy87x01yjynfgZ7gv11rQxs8QqIcdb4D/PW8pTHyjZYdN5jqzsjCxSNU6UeMPt38j03FpFr0Od2MO0qmMEZNjJp0MKv4dSyl8JDXz0EWS6Hz2HvthFFvLKkjTq8t2JSTCeGACP7Xw+S/tvSg/j+18MmdQnh+yJzOeYsuGYRaXoC11+i7WVtnEiKUZ8/89eQdp1H5hz2CplFlN3NFDtSklYGYoRPZv0riIDFEjqIIpU8Nm+4i 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)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(52116002)(66946007)(66476007)(4326008)(478600001)(316002)(6486002)(86362001)(36756003)(66556008)(83380400001)(107886003)(2616005)(6512007)(6506007)(1076003)(26005)(6666004)(8676002)(8936002)(5660300002)(44832011)(41300700001)(2906002)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: meh14MsGagUsV/DL6yxsq91wtJK5UDbhCVHw9Ns+1DQHrGqVdzWCUBr76gyo+MAscUl22XVcR4I2v6u1uCFeeYiP0uXXKMim/G57EoFwl9NOb5pC94R7dpOzpja3vyRERgqOBe4A+S+/JRjq061C1bZ2llev7P8Q90nJO63Rl1rM0nkmhlwoVcGnwji0y72w3uRAorl7xXKWeoyZjbw/5mEol9PNULzpk3GDS5//HZ9QxF9DLjEZIL9A9Y0rI4bpqGuUmuayNxlcPqXXVj5au+6kTOC2VS/26MBsYffgej89Yi9E5SxLEh8VBXv4lljGG2hrxMYdlxWQ/ck1dCLVZ4nFs+GEVXCjkIP/ls1kvsF7vBaDuE+zGJxDvlczM6BV8w0HFKVaZzfQ9sgDnI7nY4Kk0m90+OH4oipUvtkn+KCK8/K2UsjXQQDuyu8JYMri9l+0f3ZV0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lLhqGfK/QnKHFLE4pBfxp9y2A74tLzMiO2NfQtwOn1+ynNLqSl3DU75hRnwYl8zTKROCxvQi9bwip6N3MggYwbPOFnGAiE0UwoGdma+Q== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 73e9b20c-5ea1-4916-f7a2-08db4f9a0d05 X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 07:58:46.6945 (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: qVdCVjdWAXl+mQx5KDGMBYOX02g/9vP6PCO4x3SGwpKYqc3ETbUYU/5DKZ7RFABJsrOWqTcOpvt8ywtrixt3ZXZ+RhINH5b5EQj2R1+0q24= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8821 X-Proofpoint-GUID: ozbbm-1Dj_EPgrl8u8CWGgYQAzniaqRD X-Proofpoint-ORIG-GUID: ozbbm-1Dj_EPgrl8u8CWGgYQAzniaqRD 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-08_05,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 Mon May 8 07:58:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13234197 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 0DE76C7EE24 for ; Mon, 8 May 2023 07:59:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233641AbjEHH7A (ORCPT ); Mon, 8 May 2023 03:59:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232861AbjEHH6y (ORCPT ); Mon, 8 May 2023 03:58:54 -0400 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CF8FF93E2; Mon, 8 May 2023 00:58:52 -0700 (PDT) Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3487QqkI011998; Mon, 8 May 2023 00:58:50 -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=jwjuiN6tKGg8BfmFubTD1l47CWirLDMNf1Igp5nlckO/+1X6I0fxqJIclzONcjNpzk5G s/q7Iw/0Nlt5LocmrNXQJsUvgS7YDyQWfSZbNewyjPUHrmTxPxVzJq+SZ2YfYThAhK81 Zhrb8ue7ALCHp4ZOxu+Soz6vIuNNqMEzCTCF3Sn8HFnPjp5A2+RsBZ6QPqhBNHsllGtC EAaG19Ygmr617eCYkn4VeoaKK9v1GiPDUVbm/iusjEcI9UwubNzxA2KYh013Y+l6WLNb f7lo+BuVWRFDWEA3cdH1PJpQss01cB7RfMRU0knFqNcpR3iY93eLi3BhiKRMszxXQEkL Zg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qdpe43n4a-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 00:58:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=O5F6/ZHmIlUXPXJp0/Fd279R/5JHAbwTMnoSgTI2j3IRVlNu8Waac9yPZHtP33SpLCa4e8dJiaU9Bggu/YG9xOe4D+2/3u28yqGvwgHakfWUfn8Y02i42dJV1CIcTL6cbT9BsVy5zZ7OUGJrFXsIc4kCGIxhvfGPwQ8qg7q0poU+LHM5l7mM6nnvZ+i3bQtH5b2BKZPrmXfPw9wOl45dWH5ZGIxeMgdJJVhnIxFwVqBRVl+tQ4Ahf+QZdbvpYXNLpdNcFwurAwC53+kwYN8hB25ZK793slIJxyczeqR+vqY5LcW5uaiPu8wZh2VvUrIvH+YdRAJiqx1BAseAlQbh2w== 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=CML4ENGtPbpT5YGnJ3WO0VvoHx9Ccy604N22HMXCj5KWIobLwKXJLtaBHe07rA9oocsgjKyAHghYBI5Tv4BQE6ev+F00PvPtkcPO6m4FfcKbyDKJHZ9XqQOXd6qOeQnfYNcBqPJsqHVEjAjEg/osF2WR1uXV+Bph3PnSSjXn1E7jEJCvGE845PIjaTx+/DIt3jyyqXJzC9gCiYWvaYjLubHYkDscaoxfZH63gsX0er5Mwl+MpeaguFBD1Yh9aPK81ogFyTkOfZc81c+YGhOW6RpvG9nbRvzZHPxJ8XCZCSqGVmAzhK09+/Tfm/HYILBLlBYzPdGyqr1S48+1fChRRA== 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=n5GOAP8KygGVlUw8XIVI+s0/GgGmgyrv2XyltIlzx5P/gKeRjaqlRcd66XubZDa6IjUu05E9+PkLH/F7KtNbXPWzK3yemnuj/bzfqP6y8pq0C8o5RJnPnszG9oH+fdFN+Cf+dnWgbUcrJsgqFjTz43CXZnbIfGeurV7ebA6IlinCQt5qn3+OgXGvSqjZlxSoFi+LaxQsglNPrgEJTqsLR38k8UzVEnbovUkkiZjCqadvZfz/GcFOZNv+K8j62vqkNZwSv89rHOQ3Hoca2bbY4OnM0OlfALQIBzjw09d8icAwxAodqumKRMX+XorMUAmnnGW+sU/Dx3XghCUB63bjaQ== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by SN4PR0201MB8821.namprd02.prod.outlook.com (2603:10b6:806:201::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 07:58:47 +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.6363.032; Mon, 8 May 2023 07:58:47 +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 2/4] audit: account backlog waiting time in audit_receive() Date: Mon, 8 May 2023 07:58:10 +0000 Message-Id: <20230508075812.76077-3-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> References: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: BYAPR08CA0070.namprd08.prod.outlook.com (2603:10b6:a03:117::47) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|SN4PR0201MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: c9159176-2009-43cf-8a1f-08db4f9a0d7f 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: MFmlwuywKGZtW8lcoQEm8JpVZot24fJmiaiiEGUJYwlnO3I/PcKQ2L3UpJyMBHPfiI1oSQGeSu1r4ozLu6krj94PtmnWvw03mzAV5rcyMVVb5Ek64hy9gjbC/e9iB5qjrj+Drl7cOX327BqPhKQHHiO4/RPv2BPqIiPGJcs6xRx3N10mGexjxuZNBHAbfWjxNesDJ5VYvVjtoV04Wx407BqSHOuHSmooD9A+pryIVeXpzuznFoKP0a7jCEjAD/W6KCGibuM9EAI20fwXMxYA1dP7RvK5hc6KgK8dBohgAG8kF0ue+0pStoNoGkH5dr7vXnlE761yMdksoNsytoL0nVRBKGzOc3TM3F8WxyxP5HMSohU2cV8ukB+dGnghuTgrujRdh+19fWoZPawVHxG23MYU9uFpnSFH+0eer1v0C1Mc4tYgSavs+OCt+gpX2J0r78/nYGvYk1lx0gigw5Gq/sUXiOY9cjE5+YSQgul2BvrpbpAUL5D2r7dA13VIPjG8PKAD7pmolOl7eEz12je6DFBPrRkvZmd1Tbe3Vi+w6j31iTZgmrWS95tX93x32Y/X75NXTuBBHXe1UMOjAbg39/4CP+os3ZGG2fszZ61UK0RfCbL/GchIACWlevVQmg2O 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)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(52116002)(66946007)(66476007)(4326008)(478600001)(316002)(6486002)(86362001)(36756003)(66556008)(83380400001)(107886003)(2616005)(6512007)(6506007)(1076003)(26005)(6666004)(8676002)(8936002)(5660300002)(44832011)(41300700001)(2906002)(15650500001)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 6sIB/pZ9+bdeclGLmt6HpGG0jJ7KI0Q1EOtmLYAe5UtMh//9SCEBEkBjcwLIxeJCr6LHZJs+zypIOjxp/Nh7FfeSFQ5h6fMH2YeznwwcXTbfHFGHBGjtJ+6GIMsDvpiHS7gZE5xiZ2YGDXbBQ8ZOn3OZ09NDP76cZLs9lCWTMexZFRCA18jEPjFnIBRcgyxCOxJ81F3eiSqYYjbXfCjG+slRShAme7ovHOAf85c8nHfmr5oKseECKtmO+oEkcSzHxi5CVTmmqCZnHXobkZExpPhipWkrm/kO/83oWalb0AGnjvfqnkb78GvKb/I86hHZH/SZ+24O+Rmk2SNOJdGPsOS7cFphaJCG8OARrj/RIjqjUt106+0oNZ7BovnG980oFchcH7C4SdkjgarKlm9ppcH8J+gtbn3DIge0QXWP3ATpM68yRs1g/v0trhW8StHizkpDqb3EdeY7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KlOCQ3oHFjhF/PrzUomvoI+KdafhwGTgrLXZr9GL/4nocPaq+17zJTordjtMDUdXiCqoYBD51gAoQ== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c9159176-2009-43cf-8a1f-08db4f9a0d7f X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 07:58:47.4164 (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: BDiYPWApfeGUMbM2FkJN2k+vMd1e74wZLLnMVDXm2FKcoRG2j9FHvVgYM4jGiKFrGRaM6WITfsWF98R1UHhrKhx8zFj9izg6SbUeJacCkNE= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8821 X-Proofpoint-GUID: WmPAuRydJWMT_9fIfcAmCOsX7g-5ZJNA X-Proofpoint-ORIG-GUID: WmPAuRydJWMT_9fIfcAmCOsX7g-5ZJNA 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-08_05,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 Mon May 8 07:58:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eiichi Tsukata X-Patchwork-Id: 13234196 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 8BB55C77B75 for ; Mon, 8 May 2023 07:59:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233638AbjEHH67 (ORCPT ); Mon, 8 May 2023 03:58:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232820AbjEHH6y (ORCPT ); Mon, 8 May 2023 03:58:54 -0400 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1DD349032; Mon, 8 May 2023 00:58:53 -0700 (PDT) Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3487QqkJ011998; Mon, 8 May 2023 00:58:50 -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=cLvvNuzg7jNEPwNenU3editDx5EgSk7G0FY6/WCgQCkGzMnP3jUOp9ShkHQJgJkVDWDi 1WFfY3aHRJuUlgjwEpXq5KWqxM4ErDZ7uA+rDCk6uZfBZ8j1GE4J6SQAhYj63B5NY0Bn s45FgpWFCDezT5+8AnpMlcxUUc1cj4pD3cCKNJeQINL4ZhLbEIzv/1u76vz4Rq2Z5MxH g9PxXmudfM6hs4fsbpVtTHCvt91mI+t1JVo3IdR2VnVhb4gusEdDjQo+x1xxUiIWP7Y0 cEx2IwG5b/N38a+KwY/RVa8kfIAndP9pXcQk2F5dzHh64IKCHL0v/K4vqF2E0B0m8J+o 2w== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qdpe43n4a-4 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 00:58:50 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KejND6DM+9CfB7fzDLjvZFanYgtWCukipCy69HU9HubAcAFLKuSszzLONwqa+B2/Ldcv1it9feyGkxDyy1hUC1p+ca7c3NYmCtu54MpXQpy3AT3RDKbAkue/xM6jVxYoyVDc+ijy2l40GEHbcx6WZwecIOGTUpNVOySTDdX6WGkNtbzF02nFu90vDyq68DeQszRXy+GTJkJjPpQwDfU6G7tq6uwpHGWRFJtVhCp9lsI8rXaLuvFf+MPC+6N1FR3HPhzsKP+5p6O9czmEIRYQasjcJmL5Msvq5WEJThuq4fr6zz1RcDfNpltFMYo3TM8FX0h+H6h5DaljozZejqYKdw== 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=SiYM5ITnTPT7wDwZkuMSuc2yxkd5lwJFlH3vs8NC/MhehoB38QxTMQ/+nJPlPPDdEwGtNc4dqvi36jbcgKw+V56NPFo1a4Dx/jv86zViseQ/N8Mfn7G2TqNIpda7wUsvORkkLphqBEMiKnhf02dqZGsn2sQ/ZGXrANT0Th+cQs/jZKIIUE6ZiivhTSEntXCxWqxBObV72tjEDLGfUfUn7Yi/t5AJsrmXEfTIInCAl1MHm/k8KyNEBn5m2L4kxfgwyfpQoyvRnG73trRqsbktDVfR96CjUEht25I8YRoVwMZywykA1urYRpW1Yaz4GJxYnqTFygjlzNLVnoOvklmUlQ== 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=KJ2DE0w/ZpVjazLgnLMYLygCrseNt7gbH5IdFLHHIC5lfgVsOkKFH+EdJ2XogipXhErZvv7yLoh8eLqc1i2oIBJToF62ryXEtzsV97K+rYxQDnR++umkV9tCa8/EmmEnOn/5VKttt72M4F+G/iBC/dEvpWPbyRZz1pM+TTt1GaJL5CF5/2+5JkuPo366d7s4npHlYAr9hOLa7Ym0CkHAmtv3C10SJUsH5795d4AHYKe1e255t1pi2r7uwZKh4uvvrv8OfzC506vQOKBMu6DoafKLd5H+3awyeF40FDZufj91RwocTrRE9PyEJijMEoTJ/Oy+CyDLlY1N3ZjRtGnkYg== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by SN4PR0201MB8821.namprd02.prod.outlook.com (2603:10b6:806:201::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 07:58:48 +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.6363.032; Mon, 8 May 2023 07:58:48 +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 3/4] audit: convert DECLARE_WAITQUEUE to DEFINE_WAIT Date: Mon, 8 May 2023 07:58:11 +0000 Message-Id: <20230508075812.76077-4-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> References: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: BYAPR08CA0070.namprd08.prod.outlook.com (2603:10b6:a03:117::47) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|SN4PR0201MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: 56e69b35-74e3-4ca7-316b-08db4f9a0ded 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: Zs0t/0FuCF40wN+wHd4Hpj6WJRO1jjJapxBIoNotUS/PXl+scB+DqKs9eciPFTURQWt0aaq+ZW87EmaUaLqCOYMM0Qa8EBinrP07UxnhQk90w6ixwPIfvRCHJXgCelL3iGeRr7kENdIVS0OioiVJcPL3WbFpjakoq6WhfvaXw+FY1uf+WU/afLlMUN3FxlRAtrv/rX5uIfgPfL+Q0g6Tx2qOE1/plllotDsHWMe/ZzV/+MjYHNSA0ZGYwn+EPtKcCRbFHJ8wyo/3T5Vs8UE/XMA3TBm0q4bm9dRgGDVVKrh/8Zcy0vqiIrOUW6DBa+TDVDD6QiSNnoTxcC27esfc3WgdRK7FPiOIJoZe0Bxd7OynXmoP68M45OUAyeXkOlwcuP+Tl//bWpGG8JcOuu0W6LPmASPIFeeqNEXMTQUyJjvLkjsnF6bGHzw5kgwWZNBXHrUusGJqway4G3yN4BtOxr19sdTY8dZ6uNI+HenwiaukenmJiuEfVLfl80+CNdibtBsTuQlCm50vBs3Z79+sn9hmwxT4Bn361GFvsOZ+jKTukqAdKcaXjdk7kKgDYO0HuESWzWFYgoJkNtICOh8I1D3mMkLKQiCjPQyHh0Ic/qmVrSM9gco/9HfC3tVJy+o1 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)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(52116002)(66946007)(66476007)(4326008)(478600001)(316002)(6486002)(86362001)(36756003)(66556008)(83380400001)(107886003)(2616005)(6512007)(6506007)(1076003)(26005)(6666004)(8676002)(8936002)(5660300002)(44832011)(41300700001)(4744005)(2906002)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ikb7DKkH/ItqWdIVAXVIJkF6ZybSo7DPP6bU1tUWdJJs5/Bd9o0QxhR40iutuTtbAjvZ6FsBJ8O6fkgyqW19dTifqEmUcIbKJgZyUz0E4Ja79hfllFxRmyM13YC94TrQE2YJhA/2waXt21PT0BZHG+XuNM4/n/kJbrn+eyeOhl2IKubo6bEBZfPciwBOEy2uAICxEPzhXNrJ+//IbMXzpJqI2DB5FSZh4uilaDUaqCMJRWCXG8JLFXBdPCWswPLbY7aqz3FI1Ak4CTFZh1D8ImkzPDaFMIypA6w7MyfzNybE+kTfY9y1Q8vkt6gjXJhLSgH3+2QUYBgCJnKoOjX0b3+CQDsCgzaCaEoBrHkQju4txECRhQg3etjGct8WHTW04wE14gvdUWlw+NQF6dbBG9HF/aav/o3o2PLeaPZXLWtgzSnr2cEdl3CqTN2o4agb1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8CyeWxAEOwF8a9V6qIZ2aLNbLcv1JIF/YBo8Gi3Er5hZLwxHQ6cqZxQFhJAn4RYbWs0PyEmq/Z9K84hV6DrfykF3Mv1XpHawjkuBL5tQ== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: 56e69b35-74e3-4ca7-316b-08db4f9a0ded X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 07:58:48.2122 (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: /lf+DZPSxpijO0SxjWVD+qmxvLwlbI9paViPNcRrNslPoFH+UUvZBOxRLYeVFzjSm9uibsbYQ3MH6fj9MSkBvpbWiyn4RXwpY29/7Ttj/JY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8821 X-Proofpoint-GUID: 63nG7JlYBN1FXO4qNr2u5BhQ5uTdL_lN X-Proofpoint-ORIG-GUID: 63nG7JlYBN1FXO4qNr2u5BhQ5uTdL_lN 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-08_05,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 Mon May 8 07:58: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: 13234195 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 AC9CDC7EE24 for ; Mon, 8 May 2023 07:58:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233633AbjEHH66 (ORCPT ); Mon, 8 May 2023 03:58:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232973AbjEHH6y (ORCPT ); Mon, 8 May 2023 03:58:54 -0400 Received: from mx0b-002c1b01.pphosted.com (mx0b-002c1b01.pphosted.com [148.163.155.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3CD59ED0; Mon, 8 May 2023 00:58:53 -0700 (PDT) Received: from pps.filterd (m0127844.ppops.net [127.0.0.1]) by mx0b-002c1b01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3487QqkK011998; Mon, 8 May 2023 00:58:51 -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=mQYDo/r38N2alGbaUoz1D7LHoobnVFuxpV8oSRCtwew=; b=I6544JcRxlKmO+y2UzOwEWFans/iymQPHkL15sV8i7mCULVvLYBrLLSovMZfQd+hsR0R FqQkzlghydB9S1QddukkQeRFsSSYw3YqP7K2RnW7WYAfvf9gIfbT3mSUQ67xNLqHVRWR cBwSQXoc2U+I6uv/qH0n8PBo2cSnqDev5mF/2ZzwAR7ieEgZWPiXbZpcC77TY1rUv9ka KitaW+1pRB0xt4NmueZnDQl/oauA4+m8rV5dsEPsMjrD55Bwgg4jmA6V/AbAc/+e2YQC gFuScxgWzF8J0lH1vU1xVS1lv8huTyL9vZEp0gvY2ij5QJEzlh9SPMjOVSEei/jMmtNr jg== Received: from nam11-dm6-obe.outbound.protection.outlook.com (mail-dm6nam11lp2177.outbound.protection.outlook.com [104.47.57.177]) by mx0b-002c1b01.pphosted.com (PPS) with ESMTPS id 3qdpe43n4a-5 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 08 May 2023 00:58:51 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DprMyBLx8gzHFEAn3ET43xdjgxSzFa91xzDv7HcGKOOZcPlsxfbHn76c9bGyKmKg+t/Vh9RbEEkG5Qii2E00nuxsM29TGVeZFS69ARfgoe5rSI8nJYnOMfJruFCbiPvoHwsNc0dKueG6XdNInI3lmifWKfKFcmFgY01mJR1xvWfKB1NKBRlREUIOUMbnRh9v1P95JCW6EzDaG6VOC2rTIsc4ji5R90Sf0qSthTK05KnUpDWqfv2uP5jkWdgR6/8Hf8CNtqn5wY30TimsqVP2iskr7St4mibSURIem2W5vXfuqSrItKpu4292S6LWuu+o9M2NVE8rRCWnbJ5lnVtDWA== 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=mQYDo/r38N2alGbaUoz1D7LHoobnVFuxpV8oSRCtwew=; b=nAyHAghaRXsbuSravVHu5Qxd0T+xCfBftP/y6RRcJnxy3fMVnLAbX246IS5rZvkZzteoX8siSp2GPFGXf/nRewJFbcRP3185WpM5zDh0ggwSqfKO7xCfbXVSlNsRGAr+NkqReAyYkcK820IwyazsOj7QmOm7VLFj0ITzWRl2je1SVdnN4m8znNzFAPfR5Rmw7y7o9/doqUHKyTSbdHxfMpnMhpS0WRM5SqwmITYcxFSgqwekZG6tbadWtwlL/61A/dJJsxl6z8jB3bqV8W9zkBPOvGe4HZdvdBUIkF1ig0Vmyj5IlLvj4byYMTACZMgxpN3wjwicsEmfGRoM8/OxVA== 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=mQYDo/r38N2alGbaUoz1D7LHoobnVFuxpV8oSRCtwew=; b=iTTlZpnK/3tVtTIJGZU1ber3vWuLL8jy9Y3lmfQNK0KEJ7Z4H2DKJl1iF4hLhgOk2D7S56ftAntnf2PwFtk14CVPF3EVQrUxn9mowhFcejZO/LbKzdyen0KTmRPnJxpDc9rM198nc7qBeXchF6DdbJiEkInIBWmC/drWe6nSe3ylro0dAA7c/dAaW855aoEr+pPmGI77ggDVNQwWpm6roQtBt5ga1rNE+4ijMDamVG89c3hQNx3CEkK5dYNMQ4ExcURQzy1/6vapNX2Gs/tBDbEh1/ZDm5/COrQvZPKKayhja5FquI4m29dXbH7mARKoagbD/WKyUR7Xk1RlSlUh9g== Received: from CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) by SN4PR0201MB8821.namprd02.prod.outlook.com (2603:10b6:806:201::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.32; Mon, 8 May 2023 07:58:49 +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.6363.032; Mon, 8 May 2023 07:58:49 +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 4/4] audit: check if queue is full after prepare_to_wait_exclusive() Date: Mon, 8 May 2023 07:58:12 +0000 Message-Id: <20230508075812.76077-5-eiichi.tsukata@nutanix.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> References: <20230508075812.76077-1-eiichi.tsukata@nutanix.com> X-ClientProxiedBy: BYAPR08CA0070.namprd08.prod.outlook.com (2603:10b6:a03:117::47) To CH0PR02MB8041.namprd02.prod.outlook.com (2603:10b6:610:106::10) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CH0PR02MB8041:EE_|SN4PR0201MB8821:EE_ X-MS-Office365-Filtering-Correlation-Id: c065b783-fb21-4a30-8c9f-08db4f9a0e6b 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: KzJGaOu44BMD+u7vi8nkh9C2s3MxPkgBJfNWxKUUjIQIob6bczv0Hi5Eeq/ASuFAjqVVBNEodY1jWz/Pwu9ne7879xtH2wVN52g12n7bPhXKKm9AJLcjz+p+sBL+KkA1XCUoPLOSN2StItvbgvExJKZAlTNk7+OQhXNws/6CX/OcPpqWhGSpUFnBVatpXlDIFLHol/KRICBYI6tFvxKH61W3B0hwMkw699W2g5rIJR0gOX5SKHMQEVg/UvqUj4kPrcyqwLhGsxCgHL6E7y1qJWsq7qIV1khYaRPH9PFpCJCiUMb+ITLZhj8DBQZiRw6FSl25pBys662/GOfGZrswJxIcfsNP1dc2gdas2naU8U2JLxcAd13RLSQUdCZrCz59b8Ra/VuNnKdt9+jdj62WYbHHStiK1ieauML2ZKAsYqkr0ntv1Uv25EzyF68OkctDUbU9jZjzmuxuHXVyURb4oChg1Dv011fze+X/NvF9Q8OgxW4616G0zjGU6RfN4M6St+1yEbnCYLZPyiAhGkfILq2qOj7xnbMqjJDwUi53Oj6J4hhpWpGULO0iKg5X+tCfdAOwgSy4bdh3pSR5/gWEeUH5INg12zEB1bvInS8VIquuW4nDU72fwMqpU1Ecocuo 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)(396003)(366004)(39860400002)(346002)(136003)(376002)(451199021)(52116002)(66946007)(66476007)(4326008)(478600001)(316002)(6486002)(86362001)(36756003)(66556008)(83380400001)(107886003)(2616005)(6512007)(6506007)(1076003)(26005)(6666004)(8676002)(8936002)(5660300002)(44832011)(41300700001)(2906002)(38350700002)(38100700002)(186003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: sAcynbSwzjloeMvpDnQQD+Z0FPTgLlYT8TLX9EN+jmFImh9yW44llFMvL7oVhVcVuuA49FTc9RHPyDtbJByk5zwy5HuCK48M5VwRk9fdxZRN1hjvVvF6HYc6Sl6ZRC6OUjIvK3prNbJam6p8mRj/xCkXEVAnIOUDZ4LVyJ2wQZ98tAa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ln8u2uoKJnOOWBXawu/JYg7AfIDiS5YsECrUwyBbZNg/0j8WnwOVtUP9+VUCM30eS3IScAWzq7I0dQW4R6yT2X6TITZ2n2Ti518wgbD/epYmwQ7Gb8bgssYvp8/bnnS3hr3UAD+XLtlB8/YVmoqoUFAuWjyqKJWKDPztaAv7dlOOpHmn/N9i0lizmbIk8RAgbhWSmbK8NV6GFN58hFAorv7lji0yFgI1NineW/miVS1mhKAMKwvySLuttFSLffZCnRua4xHdpd3No3vTv8Z7uErabhZCQrFnFh5TsF13ChU4FbPsxnI/3MmDEVE5gjSJGnJLk3P9r8Nmj6WVpXd2xgLpARu0AA== X-OriginatorOrg: nutanix.com X-MS-Exchange-CrossTenant-Network-Message-Id: c065b783-fb21-4a30-8c9f-08db4f9a0e6b X-MS-Exchange-CrossTenant-AuthSource: CH0PR02MB8041.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 May 2023 07:58:48.9634 (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: 7TeEP+B5vK+GCXy8VBOibDwyR+R6w7h5FXnp4y8ka61NgFbc5vqwHOyDfIT994nZs7mRodGswe3SqXTka7CjzIRID6TgYvle3xJyoguu7Bk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN4PR0201MB8821 X-Proofpoint-GUID: 3EEqJd7Gllioxahca6z8xvOGDxr5NzE9 X-Proofpoint-ORIG-GUID: 3EEqJd7Gllioxahca6z8xvOGDxr5NzE9 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-08_05,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()) 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 queue full check after prepare_to_wait_exclusive(). Fixes: 7ffb8e317bae ("audit: we don't need to __set_current_state(TASK_RUNNING)") Signed-off-by: Eiichi Tsukata --- kernel/audit.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/kernel/audit.c b/kernel/audit.c index bcbb0ba33c84..d37a3a045230 100644 --- a/kernel/audit.c +++ b/kernel/audit.c @@ -644,8 +644,14 @@ 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); + } finish_wait(&audit_backlog_wait, &wait); return rtime;