Netatalk / netatalk

Netatalk is a Free and Open Source AFP fileserver. A *NIX or BSD system running Netatalk is capable of serving many Macintosh clients simultaneously as an AppleShare file server.
https://netatalk.io
GNU General Public License v2.0
310 stars 84 forks source link

Segfault of dbd -c #850

Open UUVE opened 2 months ago

UUVE commented 2 months ago

Description As stated in the title i'm continuing experiencing this behaviour of dbd -c on a afp share. The share was created a long time ago in netatalk v2.x on Debin and successively migrated to netatalk 3.x. On shares created with netatalk 3.x I do not experience this problem.

To Reproduce At this moment I don't know a clear situation that trigger the bug

Expected behavior As the man of dbd states I would expect that the command convert from AppleDouble = v2 to AppleDouble =ea .

Environment

Logs 2024-04-16T17:42:23.323892+02:00 server1 kernel: [419603.410420] dbd[1987870]: segfault at 6e8 ip 00007f2c2405674f sp 00007ffc681b3190 error 4 in libatalk.so.0.0.0[7f2c24051000+39000] likely on CPU 3 (core 3, socket 0) 2024-04-16T17:42:23.323923+02:00 server1 kernel: [419603.410519] Code: 00 4c 8d 0d 63 45 03 00 50 4c 8d 05 b8 44 03 00 eb ad 48 8b 44 24 08 4c 89 ea 4c 89 f6 bf 02 00 00 00 48 8b 40 08 48 8b 40 18 <48> 8b 88 e8 06 00 00 44 8b 80 e0 06 00 00 e8 4e a9 ff ff 85 c0 74

rdmark commented 2 months ago

For starters, can you please fill out the Environment section, so that we know the version and OS you’re running this with.

I can see two ways forward:

  1. Try to reproduce with a canned environment (create a fresh volume with 2.x and then upgrade to 3.x)
  2. Compile dbd with debug symbols and then catch the segfault in the debugger so that we can see the full stack trace

The FAQ has instructions for the latter: https://github.com/Netatalk/netatalk/wiki/Developer-FAQ

UUVE commented 2 months ago

Hi, sorry for the late reply but I haven't had time to deal with the issue lately. I can't follow suggestion 1 for various reasons, the most important of which is the fear of further damaging the shared volume by losing many resource forks still stored in the .AppleDouble folders now mixed with the Apple Double "._<*>" files. However, following suggestion 2 I got the full backtrace of the "dbd -c " crash which I report below. I would also need some clarification regarding the criteria on how "._<*>" files are created with respect to the creation of extended attributes and the size limit that extended attributes have in Linux (it should be 64kb while macos, I believe, has no size practical maximum size, and across multiple folders or files it stores extended attributes that exceed 64 kb). This is also in relation to how these things are currently handled by samba with the vfs vfruit module, in order to obtain two configurations (netatalk and samba) that are as compatible as possible, considering that I also access the shared volumes by Windows via samba (mainly on virtual machines). For now though I would focus on solving this problem. As further information, consider that the file system of shared volumes is zfs.

gdb backtrace

root@server1.home:~/software/netatalk/netatalk-3.1.18-2_build# gdb --batch -ex 'bt full'  /usr/bin/dbd dbd.coredump
[New LWP 4150738]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `dbd -c /shares/Office/Users'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0  0x00007f5a6d3f274f in ad_conv_v22ea_rf (path=path@entry=0x55807ef724db "server.office-Applications", sp=sp@entry=0x55807d9a17e0 <st>, vol=vol@entry=0x55807ef52d20) at ./libatalk/adouble/ad_conv.c:160
160 ./libatalk/adouble/ad_conv.c: File o directory non esistente.
#0  0x00007f5a6d3f274f in ad_conv_v22ea_rf (path=path@entry=0x55807ef724db "server.office-Applications", sp=sp@entry=0x55807d9a17e0 <st>, vol=vol@entry=0x55807ef52d20) at ./libatalk/adouble/ad_conv.c:160
        ret = 0
        adv2 = {ad_magic = 333319, ad_version = 131072, ad_filler = '\000' <repeats 15 times>, ad_eid = {{ade_off = 0, ade_len = 0}, {ade_off = 0, ade_len = 0}, {ade_off = 741, ade_len = 530}, {ade_off = 182, ade_len = 0}, {ade_off = 437, ade_len = 16}, {ade_off = 0, ade_len = 0}, {ade_off = 0, ade_len = 0}, {ade_off = 0, ade_len = 0}, {ade_off = 637, ade_len = 16}, {ade_off = 653, ade_len = 32}, {ade_off = 0, ade_len = 0}, {ade_off = 705, ade_len = 0}, {ade_off = 0, ade_len = 0}, {ade_off = 693, ade_len = 0}, {ade_off = 689, ade_len = 0}, {ade_off = 685, ade_len = 4}, {ade_off = 713, ade_len = 8}, {ade_off = 721, ade_len = 8}, {ade_off = 729, ade_len = 8}, {ade_off = 737, ade_len = 4}}, ad_data_fork = {adf_fd = -1, adf_syml = 0x0, adf_flags = 0, adf_lock = 0x0, adf_refcount = 0, adf_lockcount = 0, adf_lockmax = 0}, ad_resource_fork = {adf_fd = 12, adf_syml = 0x0, adf_flags = 131074, adf_lock = 0x0, adf_refcount = 1, adf_lockcount = 0, adf_lockmax = 0}, ad_rfp = 0x7fff520ed4d8, ad_mdp = 0x7fff520ed4d8, ad_vers = 131072, ad_adflags = 262, ad_inited = 2907262548, ad_options = 4, ad_refcount = 1, ad_data_refcount = 0, ad_meta_refcount = 1, ad_reso_refcount = 1, ad_rlen = 530, ad_name = 0x0, ad_ops = 0x7f5a6d44b360 <ad_adouble>, ad_open_forks = 0, valid_data_len = 741, ad_data = "\000\005\026\a\000\002", '\000' <repeats 19 times>, "\r\000\000\000\002\000\000\002\345\000\000\002\022\000\000\000\003\000\000\000\266\000\000\000\000\000\000\000\004\000\000\001\265\000\000\000\020\000\000\000\b\000\000\002}\000\000\000\020\000\000\000\t\000\000\002\215\000\000\000 \000\000\000\v\000\000\002\301\000\000\000\000\000\000\000\r\000\000\002\265\000\000\000\000\000\000\000\016\000\000\002\261\000\000\000\000\000\000\000\017\000\000\002\255\000\000\000\004\200DEV\000\000\002\311\000\000\000\b\200INO\000\000\002\321\000\000\000\b\200SYN\000\000\002\331\000\000\000\b\200SV~\000\000\002\341\000\000\000\004", '\000' <repeats 255 times>...}
        adea = {ad_magic = 0, ad_version = 0, ad_filler = '\000' <repeats 15 times>, ad_eid = {{ade_off = 0, ade_len = 0}, {ade_off = 0, ade_len = 0}, {ade_off = 82, ade_len = 0}, {ade_off = 0, ade_len = 0} <repeats 17 times>}, ad_data_fork = {adf_fd = 13, adf_syml = 0x0, adf_flags = 131138, adf_lock = 0x0, adf_refcount = 1, adf_lockcount = 0, adf_lockmax = 0}, ad_resource_fork = {adf_fd = 14, adf_syml = 0x0, adf_flags = 131074, adf_lock = 0x0, adf_refcount = 1, adf_lockcount = 0, adf_lockmax = 0}, ad_rfp = 0x7fff520edae8, ad_mdp = 0x7fff520edab8, ad_vers = 131074, ad_adflags = 1411, ad_inited = 2907262548, ad_options = 4, ad_refcount = 1, ad_data_refcount = 1, ad_meta_refcount = 0, ad_reso_refcount = 1, ad_rlen = 0, ad_name = 0x0, ad_ops = 0x7f5a6d44b320 <ad_adouble_ea>, ad_open_forks = 0, valid_data_len = 0, ad_data = '\000' <repeats 1023 times>}
        cleanup = <optimized out>
#1  0x00007f5a6d3f2aae in ad_conv_v22ea (vol=0x55807ef52d20, sp=0x55807d9a17e0 <st>, path=0x55807ef724db "server.office-Applications") at ./libatalk/adouble/ad_conv.c:187
        ret = 0
        adpath = <optimized out>
        adflags = <optimized out>
        cleanup = <optimized out>
        ret = <optimized out>
        adpath = <optimized out>
        adflags = <optimized out>
        delete = <optimized out>
        cleanup = <optimized out>
#2  ad_convert (path=0x55807ef724db "server.office-Applications", sp=sp@entry=0x55807d9a17e0 <st>, vol=0x55807ef52d20, newpath=newpath@entry=0x7fff520ee698) at ./libatalk/adouble/ad_conv.c:287
        ret = 0
        p = <optimized out>
#3  0x000055807d993778 in check_adfile (fname=fname@entry=0x55807ef724db "server.office-Applications", newname=newname@entry=0x7fff520ee698, st=0x55807d9a17e0 <st>) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:171
        ret = <optimized out>
        adflags = 4
        ad = {ad_magic = 0, ad_version = 0, ad_filler = '\000' <repeats 15 times>, ad_eid = {{ade_off = 0, ade_len = 0} <repeats 20 times>}, ad_data_fork = {adf_fd = -1, adf_syml = 0x0, adf_flags = 131074, adf_lock = 0x0, adf_refcount = 0, adf_lockcount = 0, adf_lockmax = 0}, ad_resource_fork = {adf_fd = -1, adf_syml = 0x0, adf_flags = 0, adf_lock = 0x0, adf_refcount = 0, adf_lockcount = 0, adf_lockmax = 0}, ad_rfp = 0x7fff520ee188, ad_mdp = 0x7fff520ee158, ad_vers = 131074, ad_adflags = 260, ad_inited = 2907262548, ad_options = 4, ad_refcount = 1, ad_data_refcount = 0, ad_meta_refcount = 0, ad_reso_refcount = 0, ad_rlen = 0, ad_name = 0x0, ad_ops = 0x7f5a6d44b320 <ad_adouble_ea>, ad_open_forks = 0, valid_data_len = 0, ad_data = '\000' <repeats 1023 times>}
        adname = <optimized out>
#4  0x000055807d993bd0 in dbd_readdir (volroot=volroot@entry=0, did=did@entry=3878757888) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:759
        statcount = 7104
        t = 1714447096
        name = 0x0
        cwd = <optimized out>
        ret = 0
        adfile_ok = -1
        addir_ok = 0
        cnid = <optimized out>
        name = <optimized out>
        dp = <optimized out>
        ep = 0x55807ef724c8
        st = {st_dev = 48, st_ino = 70536, st_nlink = 1, st_mode = 33188, st_uid = 604, st_gid = 604, __pad0 = 0, st_rdev = 0, st_size = 0, st_blksize = 512, st_blocks = 2, st_atim = {tv_sec = 1378854340, tv_nsec = 0}, st_mtim = {tv_sec = 1111489389, tv_nsec = 0}, st_ctim = {tv_sec = 1714446383, tv_nsec = 560054349}, __glibc_reserved = {0, 0, 0}}
#5  0x000055807d993cf0 in dbd_readdir (volroot=volroot@entry=0, did=did@entry=3526436352) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:793
        statcount = 7104
        t = 1714447096
        name = 0x55807ef6a58b "Recent Servers"
        cwd = 10
        ret = 0
        adfile_ok = <optimized out>
        addir_ok = 0
        cnid = 3878757888
        name = <optimized out>
        dp = <optimized out>
        ep = <optimized out>
        st = {st_dev = 48, st_ino = 70536, st_nlink = 1, st_mode = 33188, st_uid = 604, st_gid = 604, __pad0 = 0, st_rdev = 0, st_size = 0, st_blksize = 512, st_blocks = 2, st_atim = {tv_sec = 1378854340, tv_nsec = 0}, st_mtim = {tv_sec = 1111489389, tv_nsec = 0}, st_ctim = {tv_sec = 1714446383, tv_nsec = 560054349}, __glibc_reserved = {0, 0, 0}}
#6  0x000055807d993cf0 in dbd_readdir (volroot=volroot@entry=0, did=did@entry=3476104704) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:793
        statcount = 7104
        t = 1714447096
        name = 0x55807ef62463 "Library"
        cwd = 8
        ret = 0
        adfile_ok = <optimized out>
        addir_ok = 0
        cnid = 3526436352
        name = <optimized out>
        dp = <optimized out>
        ep = <optimized out>
        st = {st_dev = 48, st_ino = 70536, st_nlink = 1, st_mode = 33188, st_uid = 604, st_gid = 604, __pad0 = 0, st_rdev = 0, st_size = 0, st_blksize = 512, st_blocks = 2, st_atim = {tv_sec = 1378854340, tv_nsec = 0}, st_mtim = {tv_sec = 1111489389, tv_nsec = 0}, st_ctim = {tv_sec = 1714446383, tv_nsec = 560054349}, __glibc_reserved = {0, 0, 0}}
#7  0x000055807d993cf0 in dbd_readdir (volroot=volroot@entry=1, did=did@entry=33554432) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:793
        statcount = 7104
        t = 1714447096
        name = 0x55807ef5a46b "elpaol"
        cwd = 6
        ret = 0
        adfile_ok = <optimized out>
        addir_ok = 0
        cnid = 3476104704
        name = <optimized out>
        dp = <optimized out>
        ep = <optimized out>
        st = {st_dev = 48, st_ino = 70536, st_nlink = 1, st_mode = 33188, st_uid = 604, st_gid = 604, __pad0 = 0, st_rdev = 0, st_size = 0, st_blksize = 512, st_blocks = 2, st_atim = {tv_sec = 1378854340, tv_nsec = 0}, st_mtim = {tv_sec = 1111489389, tv_nsec = 0}, st_ctim = {tv_sec = 1714446383, tv_nsec = 560054349}, __glibc_reserved = {0, 0, 0}}
#8  0x000055807d9945a7 in cmd_dbd_scanvol (vol_in=vol_in@entry=0x55807ef52d20, flags=<optimized out>) at ./etc/cnid_dbd/cmd_dbd_scanvol.c:870
        ret = 0
        st = {st_dev = 48, st_ino = 34, st_nlink = 18, st_mode = 16877, st_uid = 499, st_gid = 50, __pad0 = 0, st_rdev = 0, st_size = 20, st_blksize = 1536, st_blocks = 18, st_atim = {tv_sec = 1714446381, tv_nsec = 540054464}, st_mtim = {tv_sec = 1416830337, tv_nsec = 350648526}, st_ctim = {tv_sec = 1699987450, tv_nsec = 639976011}, __glibc_reserved = {0, 0, 0}}
#9  0x000055807d992a01 in main (argc=<optimized out>, argv=<optimized out>) at ./etc/cnid_dbd/cmd_dbd.c:292
        ret = 0
        dbd_cmd = <optimized out>
        cdir = 3
        obj = {cmdlineconfigfile = 0x0, cmdlineflags = 0, signature = 0x0, dsi = 0x0, options = {connections = 200, tickleval = 30, timeout = 4, flags = 67972, dircachesize = 8192, sleep = 1200, disconnected = 2880, fce_fmodwait = 60, tcp_sndbuf = 524288, tcp_rcvbuf = 524288, passwdbits = 0 '\000', passwdminlen = 0 '\000', server_quantum = 1048576, dsireadbuf = 12, hostname = 0x55807ef39380 "Server_AFP", listen = 0x0, interfaces = 0x0, port = 0x55807ef39120 "548", Cnid_srv = 0x55807ef39200 "localhost", Cnid_port = 0x55807ef39760 "4700", configfile = 0x55807ef385c0 "/etc/netatalk/afp.conf", uampath = 0x55807ef4ee30 "/usr/lib/x86_64-linux-gnu/netatalk/", fqdn = 0x0, sigconffile = 0x55807ef4e190 "/var/lib/netatalk/afp_signature.conf", uuidconf = 0x55807ef4e1c0 "/var/lib/netatalk/afp_voluuid.conf", guest = 0x55807ef38ca0 "nobody", loginmesg = 0x0, keyfile = 0x0, passwdfile = 0x55807ef38be0 "/etc/netatalk/afppasswd", extmapfile = 0x55807ef4fde0 "/etc/netatalk/extmap.conf", uamlist = 0x55807ef4fbf0 "uams_guest.so uams_dhx.so uams_dhx2.so uams_gss.so", signatureopt = 0x55807ef396a0 "", signature = '\000' <repeats 15 times>, k5service = 0x55807ef395e0 "afpserver", k5realm = 0x55807ef39520 "<_removed_>", k5keytab = 0x55807ef4ee60 "KRB5_KTNAME=/etc/netatalk/afpserver.keytab", k5principal_buflen = 0, k5principal = 0x0, unixcodepage = 0x55807ef39cc0 "UTF8", maccodepage = 0x55807ef39a80 "MAC_ROMAN", volcodepage = 0x55807ef39b40 "UTF8", maccharset = CH_MAC, unixcharset = CH_UNIX, umask = 0, save_mask = 0, admingid = 0, force_user = false, force_uid = 0, force_group = false, force_gid = 0, volnamelen = 80, ntdomain = 0x0, ntseparator = 0x0, addomain = 0x0, logconfig = 0x55807ef38d60 "default:note", logfile = 0x0, mimicmodel = 0x55807ef39440 "Macmini", zeroconfname = 0x0, adminauthuser = 0x0, ignored_attr = 0x0, splice_size = 65536, cnid_mysql_host = 0x0, cnid_mysql_user = 0x0, cnid_mysql_pw = 0x0, cnid_mysql_db = 0x0, volfile = {mtime = 1714299784, loaded = 0}, includefile = {mtime = 0, loaded = 0}, sparql_limit = 0}, iniconfig = 0x55807ef4e3d0, username = '\000' <repeats 255 times>, oldtmp = '\000' <repeats 4096 times>, newtmp = '\000' <repeats 4096 times>, uam_cookie = 0x0, sinfo = {sessionkey = 0x0, sessionkey_len = 0, cryptedkey = 0x0, cryptedkey_len = 0, sessiontoken = 0x0, sessiontoken_len = 0, clientid = 0x0, clientid_len = 0}, uid = 0, euid = 0, ipc_fd = 0, groups = 0x0, ngroups = 0, afp_version = 11, cnx_cnt = 0, cnx_max = 0, logout = 0x0, exit = 0x0, reply = 0x0, attention = 0x0, fce_version = 0, fce_ign_names = 0x0, fce_ign_directories = 0x0, fce_notify_script = 0x0, sl_ctx = 0x0}
        vol = 0x55807ef52d20
        volpath = 0x7fff520f16aa "/shares/Office/Users"
        username = <optimized out>
        c = <optimized out>
        cleanup = <optimized out>
UUVE commented 2 months ago

... Sorry, I have closed the issue by mistake

UUVE commented 2 months ago

As additional information: the file that triggers the segfault is in "/shares/Office/Users/\<username_hidden>/Library/Recent Servers" the "._server.office-Application" created is only 82 bytes in size while the corresponding file to be converted in the relevant .AppleDouble directory is about 1.3Kb in size.

root@server1.home:~/software/netatalk/netatalk-3.1.18-2_build# ls -alnhR /shares/Office/Users/<username_hidden>/Library/Recent\ Servers/
'/shares/Office/Users/\<username_hidden\>/Library/Recent Servers/':
totale 535K
drwxr-xr-x  3 604 604    7 30 apr 05.06 .
drwx------ 29 604 604   31 23 nov  2014 ..
drwxr-xr-x  2 604 604    4 28 apr 13.06 .AppleDouble
-rw-------  1   0   0 2,0M 30 apr 05.06 core
-rw-r--r--  1 604 604    0  7 dic  2005 server-Applications
-rw-rw-rw-  1   0   0   82 16 apr 17.22 ._server.office-Applications
-rw-r--r--  1 604 604    0 22 mar  2005 server.office-Applications

'/shares/Office/Users/\<username_hidden\>/Library/Recent Servers/.AppleDouble':
totale 20K
drwxr-xr-x 2 604 604    4 28 apr 13.06 .
drwxr-xr-x 3 604 604    7 30 apr 05.06 ..
-rw-r--r-- 1 604 604 1,3K 23 nov  2014 server-Applications
-rw-r--r-- 1 604 604 1,3K 23 nov  2014 server.office-Applications
root@server1.home:~/software/netatalk/netatalk-3.1.18-2_build#
rdmark commented 3 weeks ago

@UUVE Would you be able to retry this with the recently released v3.2.0?

This release contains two specific patches that address EA metadata handling in libatalk, namely: https://github.com/Netatalk/netatalk/pull/513 and https://github.com/Netatalk/netatalk/pull/575

It should lead to a more graceful outcome when encountering "invalid" types of metadata, and I'm curious how it will look in your case.

UUVE commented 3 weeks ago

@rdmark I hope to find time to recompile the latest version in a debian package this weekend and do some testing. In any case I will report back as soon as possible.

rdmark commented 2 weeks ago

@UUVE In case it helps, we now distribute a build-from-source guide as an appendix to the Netatalk manual. See the Debian section here: https://netatalk.io/3.2/htmldocs/compile#build-debian