From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5FED942DA6 for ; Sat, 15 Jul 2023 00:34:59 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5710F40EE7; Sat, 15 Jul 2023 00:34:59 +0200 (CEST) Received: from mail-wr1-f50.google.com (mail-wr1-f50.google.com [209.85.221.50]) by mails.dpdk.org (Postfix) with ESMTP id A9F2840DFB for ; Sat, 15 Jul 2023 00:34:57 +0200 (CEST) Received: by mail-wr1-f50.google.com with SMTP id ffacd0b85a97d-31454996e06so2447919f8f.2 for ; Fri, 14 Jul 2023 15:34:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1689374097; x=1691966097; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=AcbLdMvit5uKGXyslQfotHqvmMLUM5cZBW0wA91NtnM=; b=Csai/RYbFMmtQ84jXN4kFoThoWlceO8X0XSEy85M7TDyMsvoFKk/L+Y30OtG0OoYlk DrVXIfEALt8REWuDlvhZ/2ErLV6OzguhNaKDH7Us8Vbqjt7OE3YG5oruc69lW336qmiu FTCAXv56KDx2VIStF4AWnrr6CxEsUr3O2WkCg2UCVXunjpmxcKytCR7rhgK16NuZyCco scia+c7bn51MRCuAdo0QIvABuelf7SL7v6259fUfnfS3PtD+q7GDiYe4/KIvBRdN6hmy 80m0MyVSNAWc8QwvPyOebWE1Yjqy8qK+V5wBOm2GV0c3SuFPNfGWT7m6uxRBPJOsCEOy qqqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689374097; x=1691966097; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=AcbLdMvit5uKGXyslQfotHqvmMLUM5cZBW0wA91NtnM=; b=JMdqjhQ8a01tTviV4W59iNO7q1ow9XP8u39rJ/6YLh1nL9ueSKMkCnSvNwlm/Rkfft BwUSeO0sEMtPIen/xDywIiitcRYp13s/S4mAzjHk8L79leYlLV5C7h3reKLitqMdrZKB kset5+IemgojtfxGCFNRc6Ywh/GHr/W88fK1Hl1+/9ARKMaF8ZjDzUOb9RpjCKzMydJn M4dZ+7zTAsPQmlbO3oZrPCuOGY+Oh3pkYmmuW/r0uy2pafUtlB3gm3MxigpW9Y27WqkO JaOkFmBAn4ubklLWHTyqVgC35x8g46cTVU53O7DCehVEnGCe3f2kK60Pof0w0DXS5Il2 e2oA== X-Gm-Message-State: ABy/qLY+D2ayeTrdpjZ990ya4Wuk3L+lYYS1uiB3J0drb/dly6J6jUwK 7HYu8w2IMViCuITOziSVxRdWhEuo+t4e8my5 X-Google-Smtp-Source: APBJJlF4o5C9eLp863GZHTuDMYPU6ZgVXevl8a3kVuS9VJvlDXwK/KNthksiFtoUP1OtEew9Tqlv8g== X-Received: by 2002:a5d:6301:0:b0:313:f548:25b9 with SMTP id i1-20020a5d6301000000b00313f54825b9mr5589627wru.40.1689374097115; Fri, 14 Jul 2023 15:34:57 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id d2-20020adfe842000000b003143c06135bsm11957611wrn.50.2023.07.14.15.34.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 14 Jul 2023 15:34:56 -0700 (PDT) From: luca.boccassi@gmail.com To: Viacheslav Ovsiienko Cc: Chengwen Feng , Anatoly Burakov , dpdk stable Subject: patch 'ipc: fix file descriptor leakage with unhandled messages' has been queued to stable release 20.11.9 Date: Fri, 14 Jul 2023 23:34:30 +0100 Message-Id: <20230714223447.1092828-1-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230628141046.2145871-22-luca.boccassi@gmail.com> References: <20230628141046.2145871-22-luca.boccassi@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Hi, FYI, your patch has been queued to stable release 20.11.9 Note it hasn't been pushed to http://dpdk.org/browse/dpdk-stable yet. It will be pushed if I get no objections before 07/16/23. So please shout if anyone has objections. Also note that after the patch there's a diff of the upstream commit vs the patch applied to the branch. This will indicate if there was any rebasing needed to apply to the stable branch. If there were code changes for rebasing (ie: not only metadata diffs), please double check that the rebase was correctly done. Queued patches are on a temporary branch at: https://github.com/bluca/dpdk-stable This queued commit can be viewed at: https://github.com/bluca/dpdk-stable/commit/52dc01cef84c6609cc7b4e35f97e3d0f3886acc0 Thanks. Luca Boccassi --- >From 52dc01cef84c6609cc7b4e35f97e3d0f3886acc0 Mon Sep 17 00:00:00 2001 From: Viacheslav Ovsiienko Date: Wed, 28 Jun 2023 15:19:38 +0300 Subject: [PATCH] ipc: fix file descriptor leakage with unhandled messages [ upstream commit a64a4564705d18d20d20cfa16c79e795b7bf0f1e ] The sendmsg()/recvmsg() API is used to establish communication between the DPDK processes. The API supposes inter-process file descriptors sending and conversion, the recipient sees the resulting descriptors in the received message - the operating systems creates ones in the right context. The message receiving is performed by EAL in the dedicated thread and it might happen the message is received by EAL and not handled by addressed PMD or application due to some reasons (timeouts, race condition, etc). EAL just dropped unhandled messages causing the file descriptor leakage if these ones were presented in the message. The patch closes the descriptors (if any) in unhandled messages. Fixes: 783b6e54971d ("eal: add synchronous multi-process communication") Signed-off-by: Viacheslav Ovsiienko Acked-by: Chengwen Feng Acked-by: Anatoly Burakov --- lib/librte_eal/common/eal_common_proc.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c index 50f0668148..38a2164f71 100644 --- a/lib/librte_eal/common/eal_common_proc.c +++ b/lib/librte_eal/common/eal_common_proc.c @@ -323,6 +323,15 @@ retry: return msglen; } +static void +cleanup_msg_fds(const struct rte_mp_msg *msg) +{ + int i; + + for (i = 0; i < msg->num_fds; i++) + close(msg->fds[i]); +} + static void process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) { @@ -351,8 +360,10 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) else if (pending_req->type == REQUEST_TYPE_ASYNC) req = async_reply_handle_thread_unsafe( pending_req); - } else + } else { RTE_LOG(ERR, EAL, "Drop mp reply: %s\n", msg->name); + cleanup_msg_fds(msg); + } pthread_mutex_unlock(&pending_requests.lock); if (req != NULL) @@ -382,6 +393,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) RTE_LOG(ERR, EAL, "Cannot find action: %s\n", msg->name); } + cleanup_msg_fds(msg); } else if (action(msg, s->sun_path) < 0) { RTE_LOG(ERR, EAL, "Fail to handle message: %s\n", msg->name); } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-07-14 23:33:08.546242253 +0100 +++ 0001-ipc-fix-file-descriptor-leakage-with-unhandled-messa.patch 2023-07-14 23:33:08.475304887 +0100 @@ -1 +1 @@ -From a64a4564705d18d20d20cfa16c79e795b7bf0f1e Mon Sep 17 00:00:00 2001 +From 52dc01cef84c6609cc7b4e35f97e3d0f3886acc0 Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit a64a4564705d18d20d20cfa16c79e795b7bf0f1e ] + @@ -21 +22,0 @@ -Cc: stable@dpdk.org @@ -27 +28 @@ - lib/eal/common/eal_common_proc.c | 14 +++++++++++++- + lib/librte_eal/common/eal_common_proc.c | 14 +++++++++++++- @@ -30,5 +31,5 @@ -diff --git a/lib/eal/common/eal_common_proc.c b/lib/eal/common/eal_common_proc.c -index 7a038e0a3c..02d4599d67 100644 ---- a/lib/eal/common/eal_common_proc.c -+++ b/lib/eal/common/eal_common_proc.c -@@ -321,6 +321,15 @@ retry: +diff --git a/lib/librte_eal/common/eal_common_proc.c b/lib/librte_eal/common/eal_common_proc.c +index 50f0668148..38a2164f71 100644 +--- a/lib/librte_eal/common/eal_common_proc.c ++++ b/lib/librte_eal/common/eal_common_proc.c +@@ -323,6 +323,15 @@ retry: @@ -50 +51 @@ -@@ -349,8 +358,10 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) +@@ -351,8 +360,10 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) @@ -62 +63 @@ -@@ -380,6 +391,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s) +@@ -382,6 +393,7 @@ process_msg(struct mp_msg_internal *m, struct sockaddr_un *s)