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 2526242CBC for ; Thu, 15 Jun 2023 03:36:17 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 1DFBC42D4B; Thu, 15 Jun 2023 03:36:17 +0200 (CEST) Received: from mail-wm1-f43.google.com (mail-wm1-f43.google.com [209.85.128.43]) by mails.dpdk.org (Postfix) with ESMTP id C3A2F40DDA for ; Thu, 15 Jun 2023 03:36:15 +0200 (CEST) Received: by mail-wm1-f43.google.com with SMTP id 5b1f17b1804b1-3f8c65020dfso14567615e9.2 for ; Wed, 14 Jun 2023 18:36:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1686792975; x=1689384975; 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=3Vb6RzgPHyDBHJ3uR38JxN4HBQdIlr9BJQ6FkwxxDBk=; b=A4Fo3FUc/YjYKQlwDvjSpZ+dgxzBstmPUVLdXzWSoerFlEB45mSgTG+HESpbUmhfp4 E4szTkSyc0SzdF/+4Xn253YNkBsk/8SdQsuEFm7KrLh3L2T9Lecmrg+5HpU+TAYg4Aci CzExgoJ7CcWRYQkyi0aKE/g9OMCPfuM/z+teLInLeU68dSKpdDm8FcI87Rol3j4LVV3l xCAwGkJdBcAR4J2cNMn/7j3+LCRIfmB9yRRjikXGqt6qR+nbWnOgpOD/8hw81wXJcv+u aihfGjbn3f3eQKSHDFpij+fR8hl9qrFJWNigu8xvUFK5wt+mJaETS3bugUWhDB4wPBtP iCyw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686792975; x=1689384975; 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=3Vb6RzgPHyDBHJ3uR38JxN4HBQdIlr9BJQ6FkwxxDBk=; b=DrmvlDD/gUU8hWphf696D3jporLwmKi+KfZDqfaFhdu8oIQX9739Mjy8l4DttB8ANH BlpOo7pA8tLf08+P+ezDFZ9C8S6Ymbo4864rsesM+lyGHdtawyxKU9gtgXoEravTr6AS Dz58zv+CNl8LkICPXX2eAGKGbMHMLRyZAl3tNNCw7CQaELYHjkd6+PeEZRoe2Z7WC1M2 Q/3R21A/s2pzwfZBfQkH5y8kELHqWUpIjkzk3UQ/yEFds67Hn5y4Q3iSmgYQLMIR6bwQ 9iknyWAbgZWUrdkHnimI8dUHMO5WR0BoggsOd7xzt9l6ysjwsoH7fbeV2unfpnlpOg89 pEmg== X-Gm-Message-State: AC+VfDxaZzIzncwsbB3lty47r+ePw+sQaeVDKftZu9E6YXKPU+3HtWs2 WymSydGY31ZN3n5UDKghnJjo2rcL8WYMjuqA X-Google-Smtp-Source: ACHHUZ5HN/DPH3UYD5hKJh9MGY/pQrlSKMUEt422UneQnZ2hfFWzV4l2HHvp53bWf2+QUiDT42Or3w== X-Received: by 2002:a05:600c:2181:b0:3f7:f446:927 with SMTP id e1-20020a05600c218100b003f7f4460927mr13831344wme.37.1686792975354; Wed, 14 Jun 2023 18:36:15 -0700 (PDT) Received: from localhost ([2a01:4b00:d307:1000:f1d3:eb5e:11f4:a7d9]) by smtp.gmail.com with ESMTPSA id t18-20020adfeb92000000b003093a412310sm19555001wrn.92.2023.06.14.18.36.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 14 Jun 2023 18:36:14 -0700 (PDT) From: luca.boccassi@gmail.com To: Ruifeng Wang Cc: Jia He , Anatoly Burakov , dpdk stable Subject: patch 'test/mbuf: fix crash in a forked process' has been queued to stable release 20.11.9 Date: Thu, 15 Jun 2023 02:32:56 +0100 Message-Id: <20230615013258.1439718-61-luca.boccassi@gmail.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230615013258.1439718-1-luca.boccassi@gmail.com> References: <20230615013258.1439718-1-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 06/17/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/20ca7fc9ed8af54ded8d54163f095d6730624d7e Thanks. Luca Boccassi --- >From 20ca7fc9ed8af54ded8d54163f095d6730624d7e Mon Sep 17 00:00:00 2001 From: Ruifeng Wang Date: Mon, 22 May 2023 14:01:37 +0800 Subject: [PATCH] test/mbuf: fix crash in a forked process [ upstream commit b6c419dde10e9f5dec7a02098c48060a7493420c ] Access of any memory in the hugepage shared file-backed area will trigger an unexpected forked child process segment fault. The root cause is DPDK doesn't support fork model [1] (calling rte_eal_init() before fork()). Forked child process can't be treated as a secondary process. Hence fix it by avoiding fork and doing verification in the main process. [1] https://mails.dpdk.org/archives/dev/2018-July/108106.html Fixes: af75078fece3 ("first public release") Signed-off-by: Jia He Signed-off-by: Ruifeng Wang Acked-by: Anatoly Burakov --- app/test/test_mbuf.c | 49 +++++++++++++------------------------------- 1 file changed, 14 insertions(+), 35 deletions(-) diff --git a/app/test/test_mbuf.c b/app/test/test_mbuf.c index 9f851da162..93736d8148 100644 --- a/app/test/test_mbuf.c +++ b/app/test/test_mbuf.c @@ -1173,37 +1173,16 @@ err: #endif } -#include -#include -#include -#include - -/* use fork() to test mbuf errors panic */ -static int -verify_mbuf_check_panics(struct rte_mbuf *buf) +/* Verify if mbuf can pass the check */ +static bool +mbuf_check_pass(struct rte_mbuf *buf) { - int pid; - int status; + const char *reason; - pid = fork(); + if (rte_mbuf_check(buf, 1, &reason) == 0) + return true; - if (pid == 0) { - struct rlimit rl; - - /* No need to generate a coredump when panicking. */ - rl.rlim_cur = rl.rlim_max = 0; - setrlimit(RLIMIT_CORE, &rl); - rte_mbuf_sanity_check(buf, 1); /* should panic */ - exit(0); /* return normally if it doesn't panic */ - } else if (pid < 0) { - printf("Fork Failed\n"); - return -1; - } - wait(&status); - if(status == 0) - return -1; - - return 0; + return false; } static int @@ -1220,47 +1199,47 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) return -1; printf("Checking good mbuf initially\n"); - if (verify_mbuf_check_panics(buf) != -1) + if (!mbuf_check_pass(buf)) return -1; printf("Now checking for error conditions\n"); - if (verify_mbuf_check_panics(NULL)) { + if (mbuf_check_pass(NULL)) { printf("Error with NULL mbuf test\n"); return -1; } badbuf = *buf; badbuf.pool = NULL; - if (verify_mbuf_check_panics(&badbuf)) { + if (mbuf_check_pass(&badbuf)) { printf("Error with bad-pool mbuf test\n"); return -1; } badbuf = *buf; badbuf.buf_iova = 0; - if (verify_mbuf_check_panics(&badbuf)) { + if (mbuf_check_pass(&badbuf)) { printf("Error with bad-physaddr mbuf test\n"); return -1; } badbuf = *buf; badbuf.buf_addr = NULL; - if (verify_mbuf_check_panics(&badbuf)) { + if (mbuf_check_pass(&badbuf)) { printf("Error with bad-addr mbuf test\n"); return -1; } badbuf = *buf; badbuf.refcnt = 0; - if (verify_mbuf_check_panics(&badbuf)) { + if (mbuf_check_pass(&badbuf)) { printf("Error with bad-refcnt(0) mbuf test\n"); return -1; } badbuf = *buf; badbuf.refcnt = UINT16_MAX; - if (verify_mbuf_check_panics(&badbuf)) { + if (mbuf_check_pass(&badbuf)) { printf("Error with bad-refcnt(MAX) mbuf test\n"); return -1; } -- 2.39.2 --- Diff of the applied patch vs upstream commit (please double-check if non-empty: --- --- - 2023-06-15 01:56:37.759264545 +0100 +++ 0061-test-mbuf-fix-crash-in-a-forked-process.patch 2023-06-15 01:56:34.727544800 +0100 @@ -1 +1 @@ -From b6c419dde10e9f5dec7a02098c48060a7493420c Mon Sep 17 00:00:00 2001 +From 20ca7fc9ed8af54ded8d54163f095d6730624d7e Mon Sep 17 00:00:00 2001 @@ -5,0 +6,2 @@ +[ upstream commit b6c419dde10e9f5dec7a02098c48060a7493420c ] + @@ -16 +17,0 @@ -Cc: stable@dpdk.org @@ -22,2 +23,2 @@ - app/test/test_mbuf.c | 50 +++++++++++++------------------------------- - 1 file changed, 14 insertions(+), 36 deletions(-) + app/test/test_mbuf.c | 49 +++++++++++++------------------------------- + 1 file changed, 14 insertions(+), 35 deletions(-) @@ -26 +27 @@ -index 8d8d3b9386..efac01806b 100644 +index 9f851da162..93736d8148 100644 @@ -29,2 +30,2 @@ -@@ -1167,38 +1167,16 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) - return TEST_SKIPPED; +@@ -1173,37 +1173,16 @@ err: + #endif @@ -32,2 +33 @@ - #else -- + @@ -75 +75 @@ -@@ -1215,19 +1193,19 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) +@@ -1220,47 +1199,47 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) @@ -98,10 +98,8 @@ -@@ -1235,7 +1213,7 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) - if (RTE_IOVA_IN_MBUF) { - badbuf = *buf; - rte_mbuf_iova_set(&badbuf, 0); -- if (verify_mbuf_check_panics(&badbuf)) { -+ if (mbuf_check_pass(&badbuf)) { - printf("Error with bad-physaddr mbuf test\n"); - return -1; - } -@@ -1243,21 +1221,21 @@ test_failing_mbuf_sanity_check(struct rte_mempool *pktmbuf_pool) + + badbuf = *buf; + badbuf.buf_iova = 0; +- if (verify_mbuf_check_panics(&badbuf)) { ++ if (mbuf_check_pass(&badbuf)) { + printf("Error with bad-physaddr mbuf test\n"); + return -1; + }