Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp7402334rwr; Wed, 10 May 2023 07:51:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4+grc6TesmVpiXtLgUgDaAFfwQ6L63Tu8JS9/VVgTYqZ2KdvKxDNHZXNmYxgXJO0PBFhTZ X-Received: by 2002:a05:6a00:14ca:b0:635:7fb2:2ab4 with SMTP id w10-20020a056a0014ca00b006357fb22ab4mr20115710pfu.6.1683730287970; Wed, 10 May 2023 07:51:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683730287; cv=none; d=google.com; s=arc-20160816; b=Ij1xSyMZcB/KhXEVKuyjHy//Owz8fJMrM6UoBEWI0zD8jrof63RYtsbXrynJVjCqKf YzhDluTtgQ7ca9sn0S3VZUGjUgG9oZgzg9oQciQxxaHZa3+tBRE8X/OmCyFfTustEFp6 flWMEegK8EGEtrhMMLqHiEgYsXxh4Il9Q6/PPBnAl/lvaJM2Ykk9WLq6pJMLItqOcNkd fhM3I8rEaCH1chZHtjb58ri9AnAK2bENKM910yD4S+5BYbuYW+JCXhCtmORxTwHaRGr7 X2XJuuYG0AwZPYs8iPi8eTo8h2S5SuhGtvWEkK+svyaX9qwcAGeweA7n2+rIIZzj3bKJ qMmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=HR5CPDmZEI7Pv8f114K49CRYD41GX8zoOB9k16jtY9E=; b=aWvXBW+Qk4PjR/dZDU8c9DzhocztWPcIH5koTR07jbo7Oo+TkzRXMTIg+8t4eQEKqh VcgTvHOWB5v/IG9AkVXR5bKGv3AHjH25WXC+uuDMm/zvB6wty49PpqxdY9E34SrMgXvV 5UzYbUytQmhRUTAetGSskX+mrwcPFuPSAdSuM8LfST7xFKZxoakJQhpl5f31Ykd2UGCR mjR8w2hp5O90m3aVKrc8lEkC0IC1ARujNqi+n/2kPwS6msmzyWX8Y+uY8AMNFg2LdDqe +7jZJJFI16R95mnSpERJmzyzq2QrRFjzVeDvp9sLIAE6HPB1w5wPt5wjcwXWy0uNN5Uo wxFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=WHei+S+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m129-20020a633f87000000b005285958c85bsi3753882pga.807.2023.05.10.07.51.13; Wed, 10 May 2023 07:51:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@gnuweeb.org header.s=default header.b=WHei+S+L; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnuweeb.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237541AbjEJOkW (ORCPT + 99 others); Wed, 10 May 2023 10:40:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43886 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237486AbjEJOkQ (ORCPT ); Wed, 10 May 2023 10:40:16 -0400 Received: from gnuweeb.org (gnuweeb.org [51.81.211.47]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EACEEAD27; Wed, 10 May 2023 07:40:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1683729610; bh=6R/GOaUO5DOD37ZaNkx3J3tRaIamM2Esvxxoksqfu6I=; h=From:To:Cc:Subject:Date; b=WHei+S+Lfmkf9bfkpsuV8oEqW2JkMXQ6HbFnNGe5FvnUI+gGZ9NfxwJ2wMMvYo/Ri 2T7KHmK98Y47VGFZOf7ctun6hCiNeTaB2Hwobwlh3o28vrluOZydEbo09OFabljR4F EQZPzfqiN6lvcx4Xleod/NGkKisg5KthaKTlyZQr0HRLET8sa9LGIs9wY7O2H+Vynv JZRV3ShqfuTTARkl8anYGpdK+Sr3au5JhhG1P9tYmu4RivCa1DQ0fPPcO7dV1daQKN ob7+pkebBvGsZFPFuI/ANdGiAjNXDKkwcr8o/XPHLTTLIib186l0h65E7rdvPEVo/S 6fZjEk+6v1zvA== Received: from integral2.. (unknown [101.128.114.135]) by gnuweeb.org (Postfix) with ESMTPSA id DAC1D245CF0; Wed, 10 May 2023 21:40:07 +0700 (WIB) From: Ammar Faizi To: Jens Axboe Cc: Ammar Faizi , =?UTF-8?q?Barnab=C3=A1s=20P=C5=91cze?= , Michael William Jonathan , Linux Kernel Mailing List , io-uring Mailing List , GNU/Weeb Mailing List Subject: [PATCH liburing v1 0/2] 2 fixes for recv-msgall.c Date: Wed, 10 May 2023 21:39:25 +0700 Message-Id: <20230510143927.123170-1-ammarfaizi2@gnuweeb.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Jens, This is the follow up patchset for the recent issue found in recv-msgall.c. There are two patches in this series. 1. Fix undefined behavior in `recv_prep()`. The lifetime of `struct msghdr msg;` must be long enough until the CQE is generated because the recvmsg operation will write to that storage. I found this test segfault when compiling with -O0 optimization. This is undefined behavior and may behave randomly. Fix this by making the lifetime of `struct msghdr msg;` long enough. 2. Fix invalid mutex usage. Calling pthread_mutex_lock() twice with the same mutex in the same thread without unlocking it first is invalid. The intention behind this pattern was to wait for the recv_fn() thread to be ready. Use the pthread barrier instead. It is more straightforward and correct. Please apply! Signed-off-by: Ammar Faizi --- Ammar Faizi (2): recv-msgall: Fix undefined behavior in `recv_prep()` recv-msgall: Fix invalid mutex usage test/recv-msgall.c | 44 +++++++++++++++++++++----------------------- 1 file changed, 21 insertions(+), 23 deletions(-) base-commit: 4961ac480052089a94978e9f771d513551aff61b -- Ammar Faizi