From mboxrd@z Thu Jan 1 00:00:00 1970 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 lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C5B9ACC6B03 for ; Thu, 2 Apr 2026 05:53:54 +0000 (UTC) Received: from boromir.ozlabs.org (localhost [127.0.0.1]) by lists.ozlabs.org (Postfix) with ESMTP id 4fmWJ12sDyz2ySk; Thu, 02 Apr 2026 16:53:53 +1100 (AEDT) Authentication-Results: lists.ozlabs.org; arc=none smtp.remote-ip=115.124.30.110 ARC-Seal: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775109233; cv=none; b=CMWl6aEEW9ag1IBteMDe0kluzoEylKsksOrZiP8khq2mZSZioKdgrK6kFyfdJ+M1L+Yn/GBzcOZt26z6wnfdqgZ06BlpelAvMFhfWz9K8i4TqJ/zzikXQDmxRNH8T6cQ45v+aWaN74IyAfSpqC33b3V2RiyhKnYPxKxJjVNmF8AMb4+XeKparf1ksxE6BBExJbq+b8Di6qIY6gLhV4BgbHfGr0m15R8z65DsS8oq5j9rR4rWh0vRgZbvkc4AHdPXcVjQbmnviNblKmeYEGQrnve22M7L4O+Jmr/yGyX+vkTF4E1ECLeCJavX+AkLT25ZHVP7St4n+t9h02jGOXjpJg== ARC-Message-Signature: i=1; a=rsa-sha256; d=lists.ozlabs.org; s=201707; t=1775109233; c=relaxed/relaxed; bh=6rkHdUDjQ/ndNevG1sZ1Ch+a9cB8pSr8iTDAYn0fTK8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BptZMD2TZcmmrvXrfMKMqHOaJt+MthrPBZE+NsaCxziWGs8/cJKSvm28FrMbkRfLFYXXMZ8Q5bRSFeh53ZHPikBkOplHHruuNkTIWxQaxiMMzUSjk/BS7YY5zCnpxAiz3hUnYwinT8BwMwWYwQV99L5yhsB01/r2/EKnPUDEicVhDq3rse6XJSc9nLOUnTZJnXSFmS9Ef6oCynX0DIXgTPTUGquGwbV9FGTGTxBQ4seBTOCOWQnhHEPmaSrZpomZxH+2tBM7OFcSy6OvKqVZRBYxZvXs/RwFZEzoeG6PORg/jiu/+5c+7f4iUeEcY8AQyJMk6RTWZEkfI1uAJbMhCQ== ARC-Authentication-Results: i=1; lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=SfW3F27t; dkim-atps=neutral; spf=pass (client-ip=115.124.30.110; helo=out30-110.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) smtp.mailfrom=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=linux.alibaba.com Authentication-Results: lists.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=linux.alibaba.com header.i=@linux.alibaba.com header.a=rsa-sha256 header.s=default header.b=SfW3F27t; dkim-atps=neutral Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=linux.alibaba.com (client-ip=115.124.30.110; helo=out30-110.freemail.mail.aliyun.com; envelope-from=hsiangkao@linux.alibaba.com; receiver=lists.ozlabs.org) Received: from out30-110.freemail.mail.aliyun.com (out30-110.freemail.mail.aliyun.com [115.124.30.110]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4fmWHy6yQdz2xm5 for ; Thu, 02 Apr 2026 16:53:48 +1100 (AEDT) DKIM-Signature:v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.alibaba.com; s=default; t=1775109224; h=Message-ID:Date:MIME-Version:Subject:To:From:Content-Type; bh=6rkHdUDjQ/ndNevG1sZ1Ch+a9cB8pSr8iTDAYn0fTK8=; b=SfW3F27t7z6c56fPjNJgcNJ/NeOJGpcfLRS5oF9fbWwOWbRwqqGOUJv4HEDOyzsvbJcLE9xDP+HPzHQllkwt94F7Xq7doqq+HAgBKRe4DBPDdAn3HQeHaslRpCOniJJ77bWpPp0bhZDW05wf6NYSDWif/G4ih+fa4zJlqKjX0j0= X-Alimail-AntiSpam:AC=PASS;BC=-1|-1;BR=01201311R211e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=maildocker-contentspam033045098064;MF=hsiangkao@linux.alibaba.com;NM=1;PH=DS;RN=3;SR=0;TI=SMTPD_---0X0G1dJH_1775109222; Received: from 30.221.132.8(mailfrom:hsiangkao@linux.alibaba.com fp:SMTPD_---0X0G1dJH_1775109222 cluster:ay36) by smtp.aliyun-inc.com; Thu, 02 Apr 2026 13:53:42 +0800 Message-ID: <96bba5e7-936e-45fa-bb01-2fee4dfb843d@linux.alibaba.com> Date: Thu, 2 Apr 2026 13:53:41 +0800 X-Mailing-List: linux-erofs@lists.ozlabs.org List-Id: List-Help: List-Owner: List-Post: List-Subscribe: , , List-Unsubscribe: Precedence: list MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] erofs-utils: lib/diskbuf: fix MT data race in erofs_diskbuf_reserve() To: Utkal Singh , linux-erofs@lists.ozlabs.org Cc: chao@kernel.org References: <20260402050424.24308-1-singhutkal015@gmail.com> From: Gao Xiang In-Reply-To: <20260402050424.24308-1-singhutkal015@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 2026/4/2 13:04, Utkal Singh wrote: > Two threads calling erofs_diskbuf_reserve() concurrently can both > observe strm->locked == false and both advance tailoffset, silently How? > producing an incorrect offset in the output image. Add a > pthread_mutex_t to serialize access. > > The commit path also gains the missing strm->locked = false reset; > without it, locked was set once and never cleared, making the flag > a latch rather than a guard. > > libpthread is already a build requirement (-lpthread in > lib/Makefile.am) and pthread_mutex_t is used identically in > lib/workqueue.c and lib/compress.c, so no build system changes > are required. > > Fixes: 13f7268 ("erofs-utils: lib: introduce multi-threaded I/O framework") > Signed-off-by: Utkal Singh > --- > lib/diskbuf.c | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > > diff --git a/lib/diskbuf.c b/lib/diskbuf.c > index 0bf42da..ccfeaa4 100644 > --- a/lib/diskbuf.c > +++ b/lib/diskbuf.c > @@ -2,6 +2,7 @@ > #include "erofs/diskbuf.h" > #include "erofs/internal.h" > #include "erofs/print.h" > +#include > #include > #include > #include > @@ -15,6 +16,7 @@ static struct erofs_diskbufstrm { > int fd; > unsigned int alignsize; > bool locked; > + pthread_mutex_t lock; Do you ever notice erofs_mutex_t and include/erofs/lock.h? By the way, I sincerely hope you pay less attention of this project since I've told you the reasons in emails before. It won't help with your gsoc proposal. Thanks for your efforts and contributions to the EROFS project. Thanks, Gao Xiang