• Jakob Unterwurzacher's avatar
    pollHack: handle GETATTR · 0b6cbc51
    Jakob Unterwurzacher authored
    When a filesystem is mounted with the default_permissions mount
    option (which you want to do when other users can access the
    mount), the kernel issues extra GETATTR calls to determine access
    rights. The GETATTR was not handled and pollHack failed with
    "numerical result out of range", preventing the mount from succeeding.
    
    Handle GETATTR so mounting with default_permissions works again.
    
    Before:
    
    	$ gocryptfs -fusedebug -extpass "echo test" -ko default_permissions a b
    	Reading password from extpass program "echo", arguments: ["test"]
    	Decrypting master key
    	2020/09/08 19:09:21 rx 2: INIT i0 {7.31 Ra 0x20000 ABORT_ERROR,MAX_PAGES,ATOMIC_O_TRUNC,EXPORT_SUPPORT,READDIRPLUS_AUTO,ASYNC_DIO,NO_OPEN_SUPPORT,PARALLEL_DIROPS,ASYNC_READ,BIG_WRITES,SPLICE_MOVE,WRITEBACK_CACHE,HANDLE_KILLPRIV,NO_OPENDIR_SUPPORT,CACHE_SYMLINKS,EXPLICIT_INVAL_DATA,POSIX_LOCKS,SPLICE_WRITE,SPLICE_READ,IOCTL_DIR,AUTO_INVAL_DATA,READDIRPLUS,DONT_MASK,FLOCK_LOCKS,POSIX_ACL}
    	2020/09/08 19:09:21 tx 2:     OK, {7.28 Ra 0x20000 AUTO_INVAL_DATA,READDIRPLUS,NO_OPEN_SUPPORT,PARALLEL_DIROPS,ASYNC_READ,BIG_WRITES 0/0 Wr 0x20000 Tg 0x0}
    	2020/09/08 19:09:21 rx 4: GETATTR i1 {Fh 0}
    	2020/09/08 19:09:21 tx 4:     OK, {tA=1s {M040755 SZ=80 L=2 1026:1026 B0*4096 i0:1 A 1599584934.254242 M 1599584467.201817 C 1599584467.201817}}
    	2020/09/08 19:09:21 rx 6: GETATTR i1 {Fh 0}
    	2020/09/08 19:09:21 tx 6:     OK, {tA=1s {M040755 SZ=80 L=2 1026:1026 B0*4096 i0:1 A 1599584934.254242 M 1599584467.201817 C 1599584467.201817}}
    	2020/09/08 19:09:21 rx 8: LOOKUP i1 [".go-fuse-epoll-hack"] 20b
    	2020/09/08 19:09:21 tx 8:     OK, {i18446744073709551615 g0 tE=0s tA=0s {M0100644 SZ=0 L=1 0:0 B0*0 i0:18446744073709551615 A 0.000000 M 0.000000 C 0.000000}}
    	2020/09/08 19:09:21 rx 10: LOOKUP i1 [".Trash"] 7b
    	2020/09/08 19:09:21 tx 10:     2=no such file or directory, {i0 g0 tE=1s tA=0s {M00 SZ=0 L=0 0:0 B0*0 i0:0 A 0.000000 M 0.000000 C 0.000000}}
    	2020/09/08 19:09:21 rx 12: GETATTR i18446744073709551615 {Fh 0}
    	2020/09/08 19:09:21 tx 12:     34=numerical result out of range, {tA=0s {M00 SZ=0 L=0 0:0 B0*0 i0:0 A 0.000000 M 0.000000 C 0.000000}}
    	fs.Mount failed: numerical result out of range
    
    After:
    
    	$ gocryptfs -fusedebug -extpass "echo test" -ko default_permissions a b
    	Reading password from extpass program "echo", arguments: ["test"]
    	Decrypting master key
    	2020/09/08 19:21:33 rx 2: INIT i0 {7.31 Ra 0x20000 READDIRPLUS,POSIX_ACL,CACHE_SYMLINKS,SPLICE_WRITE,IOCTL_DIR,AUTO_INVAL_DATA,FLOCK_LOCKS,ASYNC_DIO,HANDLE_KILLPRIV,ABORT_ERROR,ATOMIC_O_TRUNC,BIG_WRITES,DONT_MASK,SPLICE_MOVE,PARALLEL_DIROPS,EXPORT_SUPPORT,SPLICE_READ,READDIRPLUS_AUTO,WRITEBACK_CACHE,NO_OPEN_SUPPORT,ASYNC_READ,POSIX_LOCKS,MAX_PAGES,NO_OPENDIR_SUPPORT,EXPLICIT_INVAL_DATA}
    	2020/09/08 19:21:33 tx 2:     OK, {7.28 Ra 0x20000 NO_OPEN_SUPPORT,ASYNC_READ,AUTO_INVAL_DATA,READDIRPLUS,BIG_WRITES,PARALLEL_DIROPS 0/0 Wr 0x20000 Tg 0x0}
    	2020/09/08 19:21:33 rx 4: GETATTR i1 {Fh 0}
    	2020/09/08 19:21:33 tx 4:     OK, {tA=1s {M040755 SZ=80 L=2 1026:1026 B0*4096 i0:1 A 1599585687.491337 M 1599585688.791343 C 1599585688.791343}}
    	2020/09/08 19:21:33 rx 6: GETATTR i1 {Fh 0}
    	2020/09/08 19:21:33 tx 6:     OK, {tA=1s {M040755 SZ=80 L=2 1026:1026 B0*4096 i0:1 A 1599585687.491337 M 1599585688.791343 C 1599585688.791343}}
    	2020/09/08 19:21:33 rx 8: LOOKUP i1 [".go-fuse-epoll-hack"] 20b
    	2020/09/08 19:21:33 tx 8:     OK, {i18446744073709551615 g0 tE=0s tA=0s {M0100644 SZ=0 L=1 0:0 B0*0 i0:18446744073709551615 A 0.000000 M 0.000000 C 0.000000}}
    	2020/09/08 19:21:33 rx 10: GETATTR i18446744073709551615 {Fh 0}
    	2020/09/08 19:21:33 tx 10:     OK, {tA=0s {M0100644 SZ=0 L=1 0:0 B0*0 i0:18446744073709551615 A 0.000000 M 0.000000 C 0.000000}}
    	2020/09/08 19:21:33 rx 12: OPEN i18446744073709551615 {O_RDONLY,0x8000}
    	2020/09/08 19:21:33 tx 12:     OK, {Fh 18446744073709551615 }
    	2020/09/08 19:21:33 rx 14: POLL i18446744073709551615
    	2020/09/08 19:21:33 tx 14:     38=function not implemented
    	2020/09/08 19:21:33 rx 16: FLUSH i18446744073709551615 {Fh 18446744073709551615}
    	2020/09/08 19:21:33 tx 16:     34=numerical result out of range
    	2020/09/08 19:21:33 rx 18: RELEASE i18446744073709551615 {Fh 18446744073709551615 0x8000  L0}
    	2020/09/08 19:21:33 tx 18:     34=numerical result out of range
    	Filesystem mounted and ready.
    
    Change-Id: Idfaea994ee6a4b8f28acbe8343063f6250cbef35
    0b6cbc51
poll.go 1.06 KB