From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mout.kundenserver.de (mout.kundenserver.de [212.227.126.131]) by sourceware.org (Postfix) with ESMTPS id 350053858D28 for ; Mon, 6 Dec 2021 10:16:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 350053858D28 Authentication-Results: sourceware.org; dmarc=fail (p=none dis=none) header.from=cygwin.com Authentication-Results: sourceware.org; spf=fail smtp.mailfrom=cygwin.com Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue009 [212.227.15.167]) with ESMTPSA (Nemesis) id 1N2V8Z-1mQWYZ2wbX-013tmB for ; Mon, 06 Dec 2021 11:16:32 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 03D23A810BD; Mon, 6 Dec 2021 11:16:31 +0100 (CET) Date: Mon, 6 Dec 2021 11:16:30 +0100 From: Corinna Vinschen To: cygwin@cygwin.com Subject: Re: vboxsharedfs - Too many levels of symbolic links Message-ID: Reply-To: cygwin@cygwin.com Mail-Followup-To: cygwin@cygwin.com References: <20211205115411.1619911cb3e2d23f671912ce@nifty.ne.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20211205115411.1619911cb3e2d23f671912ce@nifty.ne.jp> X-Provags-ID: V03:K1:j/2JTFUeSbhPn4FFdnwU7Pwz4KQ1MohyXptbD/iAq7+iBWim+iE neUd8kdJgIAL+Mis3KEqkW9GuX99bvtwBq8G62vPm+3FeOdHPNi2zM12eX3CQOS15TDozUX zstmvH+ug4qbdjavtK0k85P8utoH83UqJoRJTi58JyuGxwgIKXY3RowbsC3QjBHPRHnEzER PnK2tlAt0YHzap2v2o/cA== X-UI-Out-Filterresults: notjunk:1;V03:K0:a6JH/ToIYXI=:a5lCsSeglWb7lsSegoP4EB GCzYZmhWB032pqsoYREO3TgKQlwKwV77rbNnXH7zVChTZfG3RcKHgPnkfl2swmDSFG0f1zSnB /3ZJqClc0JiZWkNFa9698F8fjJfV7SAscSnIATbx37MoxxArjXeAFj5REoQwcQaMCAWXoV544 GkeeL53o7uxKXpMjfH167ZF39w/vwWKPLWDAt019NuSXVDWh08yOPZUyU5ky33nFQjVZ4+CJ0 9OY62Q+n9s3bMhGG8HZPlBVILb0+w7T+2cJmMSqGu8CxK/pN5cYqdOoxhnvCaQR9/uL44J86E LyohjlkvjtCgu7OsYj39p2MrXFvzJMvctnrw51CroqR0juuMMAUo7RJHvyYyDbjXSQ5XU8FeL GdlbdC8zUoXfl5qo+cWn0VkaTAzbSOcxhk/fPPaLBWG6HANjJxSwl4AfKNwqqIFKxb4Ze5ZEJ 7qxDhM3HeozGiXixCmVvsX9NDsFIhXw79A5UN00IeJWL5uaJvQpj8Dy0fDjEIr6+7UlzxcR8m YnCBfzpmTxUWpOumPGAn8/Df+BT5NTU5Ldj2yQRyO1h7skTBceiSrAPm/Etk5qPyQ5mBN5DQR 0uwtcVxmC4BPVHQ08uM4o9q4/I81r+RZ0Cnc7qY6f5TCgBpE4YQED+xfRZ25cmpq6fHO26uzQ MVOfiFoKQ7xMiM+jZeVDaM5s0Og/qUIPRinL2KtUU7m1NpX5WehhfR5os4A3AGpgHIfqigBGU YqIEuY/mPNh6hm+v X-Spam-Status: No, score=-105.4 required=5.0 tests=BAYES_00, GIT_PATCH_0, GOOD_FROM_CORINNA_CYGWIN, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: cygwin@cygwin.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: General Cygwin discussions and problem reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 10:16:38 -0000 On Dec 5 11:54, Takashi Yano wrote: > On Tue, 30 Nov 2021 19:04:57 +0200 > Oskar Skog wrote: > > vboxsharedfs file systems no longer work. Any attempt to access will > > result in "too many levels of symbolic links". > > > > This only affects the VirtualBox shared folder, the Samba share works > > just fine. > > > > Last time I updated (before today) was sometime before the 10th of > > September. > > > > MSYS2 has the same problem, but no one seems to have reported it to > > Cygwin: > > https://github.com/msys2/msys2-runtime/issues/58 > > > > > > user@DESKTOP-******* ~$ ls /cygdrive/z > > ls: cannot access '/cygdrive/z': Too many levels of symbolic links > > user@DESKTOP-******* ~$ mount > > C:/Cygwin/bin on /usr/bin type ntfs (binary,auto) > > C:/Cygwin/lib on /usr/lib type ntfs (binary,auto) > > C:/Cygwin on / type ntfs (binary,auto) > > C: on /cygdrive/c type ntfs (binary,posix=0,user,noumount,auto) > > D: on /cygdrive/d type iso9660 (binary,posix=0,user,noumount,auto) > > Y: on /cygdrive/y type smbfs (binary,posix=0,user,noumount,auto) > > Z: on /cygdrive/z type vboxsharedfolderfs > > (binary,posix=0,user,noumount,auto) > > user@DESKTOP-******* ~$ uname -a > > CYGWIN_NT-10.0 DESKTOP-* 3.3.2(0.341/5/3) 2021-11-08 16:55 x86_64 Cygwin > > Thanks for the report. > It seems that this happens only in 64bit Windoes10/11. > [...] > I tested with VirtualBox version 6.1.30. Thanks for testing, Takashi! > In 64bit Windows10, for vbox shared path, GetFinalPathNameByHandleW() > returns path with trailing '\'. As a result, RtlEqualUnicodeString() > fails and tries to resolve symlink repeatedly. That sounds like a bug in VirtualBox, but yeah, we should workaround it. > For example, RtlEqualUnicodeString() compares \??\UNC\VBoxSrv\tmp and > \??\UNC\VBoxSrv\tmp\, then it fails. > [...] > + if (wcsstr (fpbuf, L"\\\\?\\UNC\\") == fpbuf) > + goto file_not_symlink; > + Isn't that a bit intrusive? Wouldn't it also fix the issue if we just overwrite a trailing '\\' with '\0', like this? diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index baf04ce89a08..b76e5b0466cf 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -3492,8 +3492,14 @@ restart: { UNICODE_STRING fpath; - RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR)); + /* If incoming path has no trailing backslash, but final path + has one, drop trailing backslash from final path so the + below string comparison has a chance to succeed. */ + if (upath.Buffer[(upath.Length - 1) / sizeof (WCHAR)] != L'\\' + && fpbuf[ret - 1] == L'\\') + fpbuf[--ret] = L'\0'; fpbuf[1] = L'?'; /* \\?\ --> \??\ */ + RtlInitCountedUnicodeString (&fpath, fpbuf, ret * sizeof (WCHAR)); if (!RtlEqualUnicodeString (&upath, &fpath, !!ci_flag)) { issymlink = true; Thanks, Corinna