Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7331859ybc; Thu, 28 Nov 2019 15:28:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzj6W2n8gurOZCTWjKBCEIGQVgopic+76PzQoS0f1q/wPC+ZLWavTnLXF/R0J+t5lZnEFHR X-Received: by 2002:a17:906:4bcb:: with SMTP id x11mr58932963ejv.100.1574983715476; Thu, 28 Nov 2019 15:28:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574983715; cv=none; d=google.com; s=arc-20160816; b=OEYhs/qbYAuQO2Xh96bfuwIJ1deTAQ6TEmufphnstbvvkbJEMikYoNG66QecT90dUN 4D/TN5YoVEBPRJ8quHkww+eq8/e7BgMHQ7NDiLr2KSyl3YjxvFiZT31Y6/3S6Cgeq7vO UGEzbdQTFr0STzKmgXce5LF4Yo5euFETGDD+5Rrd5Z7DYluyzEZARz2QlAlFZs6l/T8q Lb8I4xm4N4UKh1gtQd4EWodOxH+/aW4ZCkPujHdfsFwW0hCuxbD8MAZBAmlUPPQQD4h6 D4mWnB41p2+5bMgD2kzlNLJQKPDcDn70toBaWjC582TbveQwzhuCJaAWsqUmXEQzMrY4 /ICQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=ZbTIuSYahXhs5nHLlIqujeF2zK/uPjIli8qGuvN97jQ=; b=zjbtPtp6ESjSrJKOE+vY9I4WARJCPXap5nzChVD6xo0937uj43iSoYpUqcCiiK9Hab dL8/kSoJsBfyxR29iq3C7wen5BYCFOoNGEMJCLl7nYPYiikVQmKAVjXDQar/umn/TsPp iQcouF0wxC9iPK2b0MevR4opdIa6dqtn02CgzozMgn6qY91cGATjVIHnKDTzndqk9Qsx 7jcD+DR6HICGzyWjDHh+YF3+CwpiTM4nBssVdb40WYcl3gN4Eo+zIjkom7efNJLyaqxs Jyit+Bgq4+EDJnLNJSqI/NF+Rd5VOXN4x4FxTfklePeorVVZRnozz+2w2Uqu18uQvu33 fi9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r13si4442687eju.92.2019.11.28.15.27.58; Thu, 28 Nov 2019 15:28:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbfK1XTx (ORCPT + 99 others); Thu, 28 Nov 2019 18:19:53 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50164 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726582AbfK1XTx (ORCPT ); Thu, 28 Nov 2019 18:19:53 -0500 Received: from callcc.thunk.org (97-71-153.205.biz.bhn.net [97.71.153.205] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id xASNJltA029092 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 28 Nov 2019 18:19:48 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 5487F421A46; Thu, 28 Nov 2019 18:19:47 -0500 (EST) Date: Thu, 28 Nov 2019 18:19:47 -0500 From: "Theodore Y. Ts'o" To: Meng Xu Cc: linux-ext4@vger.kernel.org Subject: Re: potential data race on ext_inode_hdr(inode)->eh_depth, ext_inode_hdr(inode)->eh_max between a creat and unlink syscall Message-ID: <20191128231947.GH22921@mit.edu> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.2 (2019-09-21) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Nov 28, 2019 at 12:03:04PM -0500, Meng Xu wrote: > I notice a potential data race on ext_inode_hdr(inode)->eh_depth, > ext_inode_hdr(inode)->eh_max between a create and unlink syscall. > Following is the trace: > > [Setup] > mkdir("foo", 511) = 0; > open("foo", 65536, 511) = 3; > create("bar", 511) = 4; > symlink("foo", "sym_foo") = 0; > open("sym_foo", 65536, 511) = 5; > > [Thread 1] > create("bar", 438); > > __do_sys_creat > ksys_open > do_filp_open > path_openat > do_last > handle_truncate > do_truncate > notify_change > ext4_setattr > ext4_truncate > ext4_ext_truncate > ext4_ext _remove_space > [WRITE, 2 bytes] ext_inode_hdr(inode)->eh_depth = 0; > [WRITE, 2 bytes] ext_inode_hdr(inode)->eh_max > = cpu_to_le16(ext4_ext_space_root(inode, 0)); > > [Thread 2] > unlink("sym_foo"); > > __do_sys_unlink > do_unlinkat > iput > iput_final > evict > ext4_evict_inode > ext4_orphan_del > ext4_mark_iloc_dirty > ext4_do_update_inode > [READ, 4 bytes] raw_inode->i_block[block] = ei->i_data[block]; > > > I could observe that the order between the READ and WRITE is not > deterministic and I was curious what will happen if the READ takes > place in the middle of the two WRITES? Does it cause any damages or > violations? This makes no sense. The inodes corresponding to "sym_foo" and "bar" are completely differenth. So why would there be a data race? How are you concluding that that there is, in fact, a data race? - Ted