From nobody Fri Jun 09 21:48:43 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 4QdF8D5G4Hz4cXc6 for ; Fri, 9 Jun 2023 21:48:44 +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 4QdF8D28F6z3Lxc for ; Fri, 9 Jun 2023 21:48:44 +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=1686347324; 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; bh=9WoslCvW1aWqih+kZsed9cL3paizbK761K3y1rH7gL0=; b=NlpKxfYh1FK3Jt2t5DO/tXRxYDak8kJPdGfrC90aEta8VmfzNwrCxlywWfCJjAKD8hnDMu 3gPBnHS6HAB2PW/uWUwRq+uIwDe4hJew0ZdKYl134KiwNTjm6w/HYT2/86+BXBFBMfPGKl lEqJ4NjTCp1UO4OnXNgXvsgFwCrH5GX3csx11E9uLXEIpscuH32nF/Kb/0wX8eGvJswO+B rkHjsJWEzeWMHW2DOBhEpGoHc7NxOzrB730dGUkM3oA/sw5/MtYqv3G/8LBz8OteYfwFeD nk80z4SohtxN3GDLfBLLx2GM0W3YCCQl02hElUb6RIzrdBN5N1JLORDIgLtymQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1686347324; a=rsa-sha256; cv=none; b=g3Nn16QMms32cx8dNbyKeLXeoJiheD7xPPIbrdRk1ViGmpWSM1dBI4s6qDA30k+L/znt2q 4NU9EO1UHMupmP14mXYeIx3sGawMeQ4afL41Cniqucu+aqkxEjI2EzIZFZgSSKZDKpXtd0 Mrunr1ob6R8xXLQkTvBw0NAZe/sZ5hDRTiR2OR1IRIfeToiYqUAZyDzcXSOZcP2CigNb/m xu8Pf5oXd3Z/iFJ6UggkwBHhnh++RLZv/sWy4DVXksZht26HIDDEHQO273zZx052ESx54N KK5XXKz7DSPAph4cgnWwLI0eLi+yTkq1TuBmG5xkaoN9Tst4UQfjU6sIoJj1FA== 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 4QdF8D17K9zrVs for ; Fri, 9 Jun 2023 21:48:44 +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 359LmiVk001542 for ; Fri, 9 Jun 2023 21:48:44 GMT (envelope-from bugzilla-noreply@freebsd.org) Received: (from www@localhost) by kenobi.freebsd.org (8.15.2/8.15.2/Submit) id 359Lmi7d001541 for bugs@FreeBSD.org; Fri, 9 Jun 2023 21:48:44 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 271925] chflags(1) fails to remove uarch flag with hardlinked files Date: Fri, 09 Jun 2023 21:48:43 +0000 X-Bugzilla-Reason: AssignedTo X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: Base System X-Bugzilla-Component: bin X-Bugzilla-Version: CURRENT X-Bugzilla-Keywords: X-Bugzilla-Severity: Affects Only Me X-Bugzilla-Who: jamie@catflap.org X-Bugzilla-Status: New X-Bugzilla-Resolution: X-Bugzilla-Priority: --- X-Bugzilla-Assigned-To: bugs@FreeBSD.org X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version rep_platform op_sys bug_status bug_severity priority component assigned_to reporter attachments.created Message-ID: 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 X-ThisMailContainsUnwantedMimeParts: N https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D271925 Bug ID: 271925 Summary: chflags(1) fails to remove uarch flag with hardlinked files Product: Base System Version: CURRENT Hardware: Any OS: Any Status: New Severity: Affects Only Me Priority: --- Component: bin Assignee: bugs@FreeBSD.org Reporter: jamie@catflap.org Created attachment 242705 --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=3D242705&action= =3Dedit terminal output demonstrating the problem Using chflags to remove "uarch" on more than one file at a time (but when that file count is an even number) when the files are hardlinked (have the same inode) and on ZFS doesn't work. This becomes more problematic when using "find... -exec chflags nouarch {} = +" or "chmod -R". The problrem occurs because if chflags(2) resets uarch on a file which doesn't already have uarch set, then the very update causes uarch to be set. To mitigate that, chflags(1) does a stat of the file, and will only attempt to remove the flag if it actually exists. The problem here is that the stat operation is done on all files before the chflag(2) operation is then applied to all files. Apart from the fact this introduces generally a race condition, it means in this specific case that the flag is removed, and then added again. (A sort of race against itself that it always loses!) The stat(2) and chflags(2) should be as close together as possible, to keep the operation as atomic as possible. If that is unacceptable due to inefficiencies, chflags(1) should at least ignore files that it stats which have the same inode as another file previously stat(2)'ed A demonstration, along with a ktrace of the offending part of the code is attached. Cheers, Jamie --=20 You are receiving this mail because: You are the assignee for the bug.=