From nobody Sun Jul 23 13:32:58 2023 X-Original-To: bugs@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4R843v1GPMz4pNTT for ; Sun, 23 Jul 2023 13:32:59 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4R843t5Svnz3PBT for ; Sun, 23 Jul 2023 13:32:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1690119178; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=cQGAiCEqgLLZ5xdCS86XLzMJLgSewOysGZsEmRoSetM=; b=bbcBjuqiLy5tTSPjrtXRj3eDe0t33Qgx32wht+MHcr25DqTP5362pLZP/iCYBGSa8SBceO ZEuG90vUwzvXysxPKF8JDth3aHVce/XwRZLDubGVLcVJ1q/1oT7wM8S/HBH2Wk2hbG2V9K +S5zK47DHOSLfAfqlXbZmuXJ62lcwXYWayXgMluKrfduWlT++DIYeD6uloc9rzqtJFhnYN ndUm5/V2K2C9V1suzsSORd8TQ3MGtaook6ZUMBRX6+d7XFfSwkvsSoLXnGBTOhzoyJV2kx 4XSEfXZfy+E8pAFPOo+JxsSvD5Wt/3RRV5QBHmbpaJEfDI5BaNyypLt7ftM9XA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1690119178; a=rsa-sha256; cv=none; b=Uwxcf+bsckbhqPnDv7bDCyvtdR8LxO66mO/CvOr6Xqjz+Q27k/SRQ9EjXtYHITqNpIJSiv 6ZRJMV4mxMO9MFY1VI0vbVv2IfWFO6pRF90QaHZaxnOkDBd4llHmGfcL+i7l7qoHYyTJWD Lz+x66KKTfPWwFN0hecjA0bgX/g+Eg/1K/eBjcB0DVJ4U+UKbJNRp4HnhqfgY+PYl31V7a MpiexDr6Fgt8ihqKbTSHCDbj2T8KygMVCfXpslHU5WiSKp82ejBR6kdOLWpBxvHsJd3bn3 ZvX+LtbjgY4Iv0A+g7bO7gnazLJ9kwrMe78IRNGxH8SnNGApCABfVAW+gD7p1A== Received: from kenobi.freebsd.org (kenobi.freebsd.org [IPv6:2610:1c1:1:606c::50:1d]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4R843t4Z13zf5s for ; Sun, 23 Jul 2023 13:32:58 +0000 (UTC) (envelope-from bugzilla-noreply@freebsd.org) Received: from kenobi.freebsd.org ([127.0.1.5]) by kenobi.freebsd.org (8.15.2/8.15.2) with ESMTP id 36NDWwqv092454 for ; Sun, 23 Jul 2023 13:32:58 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 36NDWwLB092453 for bugs@FreeBSD.org; Sun, 23 Jul 2023 13:32:58 GMT (envelope-from bugzilla-noreply@freebsd.org) X-Authentication-Warning: kenobi.freebsd.org: www set sender to bugzilla-noreply@freebsd.org using -f From: bugzilla-noreply@freebsd.org To: bugs@FreeBSD.org Subject: [Bug 272678] VFS: Incorrect data in read from concurrent write Date: Sun, 23 Jul 2023 13:32:58 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: kern X-Bugzilla-Version: 13.2-RELEASE X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Some People X-Bugzilla-Who: andrew@tao11.riddles.org.uk X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: cc Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: https://bugs.freebsd.org/bugzilla/ Auto-Submitted: auto-generated List-Id: Bug reports List-Archive: https://lists.freebsd.org/archives/freebsd-bugs List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-bugs@freebsd.org MIME-Version: 1.0 https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D272678 Andrew "RhodiumToad" Gierth changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |andrew@tao11.riddles.org.uk --- Comment #1 from Andrew "RhodiumToad" Gierth --- I analyzed this one based on discussions on IRC with the original poster (a= nd did the testing on 13.2-stable and 14-current). The short version is that vn_read thinks it can do the VOP_READ_PGCACHE path without doing any locking at all, which violates the consistency expected h= ere (and the OP's test case is taken from an actual application, mariadb). The problem does not normally manifest with non-tmpfs filesystems because those= are using range locks and the vn_io_fault code path (which tmpfs does not use). In more detail: vn_write calls tmpfs_write with the vnode exclusively locked, and on an appending write, tmpfs_write updates the file length before copying in the = new data. vn_read calls tmpfs_read_pgcache without any locking, and that reads the fi= le length (getting the new length). There is a comment here "size cannot become shorter due to rangelock.", which I think is bogus because there is no rangelock in effect at this point; further tests would be needed to verify whether a concurrent truncate could crash it. After getting the length (and= in the race case, that'll be the new length), it copies the data (which is not= yet written in the race case). --=20 You are receiving this mail because: You are the assignee for the bug.=