<html><head></head><body>Something about this a little bit ominous.<br><br>There's a new type of "architecture" unrolling with a certain flavor, and it is becoming, by and by, irremediably complex. I'm not really sure where the stopping or turning point is, or perhaps there are other "tools" for memory leak detection and static code analysis that could in theory help find bugs like this.<br><br>Assuming the bug is in Dovecot and not in the Linux kernel or the underlying KVM virtualization container.<br><br>I was using a KVM that got hacked, and I'm having better luck with CentOS on OpenVZ at the provider on a very small scale system, but certain critical security bits and pieces are going missing in action.<br><br><div class="gmail_quote">On February 20, 2022 8:39:13 PM AKST, Reuben Farrelly <reuben-dovecot@reub.net> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre dir="auto" class="k9mail">Following up to my original mail:<br><br>On 18/02/2022 3:59 pm, Reuben Farrelly wrote:<br><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Hi,<br><br> I've recently migrated my two VMs across from Linode (who use KVM) <br> onto a local VPS service (which also uses KVM). Since doing so I have <br> started to see some strange problems with Dovecot relating to indexes <br> and replication.<br><br> I have copied the configuration files across from old host to new <br> host. The kernel is the same - as this is Gentoo everything was <br> rebuilt and installed from fresh, but with the same options (use <br> flags). Even the Linux kernel is the same version with the exact same <br> options (as is Dovecot). The filesystem is the same EXT4 with the <br> same options too.<br><br></blockquote>No one responded from here (is anyone helping on this list anymore?) but <br>after many hours I found out the problem was to do with replication on <br>the far end host, and not anything to do with either the new VPS or the <br>existing dovecot or linux config.<br><br>It turns out that if there is an existing Maildir/ in the user's <br>directory on the remote replica, the initial sync from the master <br>fails. It may fail early on in the sync, or at the end of the initial <br>replication but either way it fails and the user ends up with a mailbox <br>in a half sync'd state. Even if the remote Maildir is completely empty <br>as mine were, it fails - it is the mere presence of the Maildir/ <br>directory on the remote breaks the sync. Typically new users have a new <br>and empty Maildir (copied from /etc/skel) so it fails for them by default.<br><br>Once I deleted the Maildir/ from the remote user's home directory and <br>the entire contents of a half replica, then dovecot created a new <br>Maildir and everything was able to sync through on all users to completion.<br><br>To reproduce this: create a new user with an empty (Maildir/new <br>Maildir/cur and Maildir/tmp) and then trigger the sync with debug <br>manually: doveadm -v -D sync -u username -f tcp:imap2.reub.net:4814<br><br>Here - with a completely empty and brand new Maildir/ on both master and <br>remote replica we can see it already fails:<br><br>tornado ~ # doveadm -v -D sync -u testuser -f tcp:imap2.reub.net:4814<br>Debug: Loading modules from directory: /usr/lib64/dovecot/doveadm<br>Debug: Skipping module doveadm_acl_plugin, because dlopen() failed: <br>/usr/lib64/dovecot/doveadm/lib10_doveadm_acl_plugin.so: undefined <br>symbol: acl_user_module (this is usually intentional, so just ignore <br>this message)<br>Debug: Skipping module doveadm_quota_plugin, because dlopen() failed: <br>/usr/lib64/dovecot/doveadm/lib10_doveadm_quota_plugin.so: undefined <br>symbol: quota_user_module (this is usually intentional, so just ignore <br>this message)<br>Debug: Module loaded: <br>/usr/lib64/dovecot/doveadm/lib10_doveadm_sieve_plugin.so<br>Debug: Skipping module doveadm_fts_plugin, because dlopen() failed: <br>/usr/lib64/dovecot/doveadm/lib20_doveadm_fts_plugin.so: undefined <br>symbol: fts_user_get_language_list (this is usually intentional, so just <br>ignore this message)<br>Debug: Skipping module doveadm_mail_crypt_plugin, because dlopen() <br>failed: /usr/lib64/dovecot/doveadm/libdoveadm_mail_crypt_plugin.so: <br>undefined symbol: mail_crypt_box_get_pvt_digests (this is usually <br>intentional, so just ignore this message)<br>Feb 21 16:31:51 Debug: Loading modules from directory: /usr/lib64/dovecot<br>Feb 21 16:31:51 Debug: Module loaded: <br>/usr/lib64/dovecot/lib15_notify_plugin.so<br>Feb 21 16:31:51 Debug: Module loaded: <br>/usr/lib64/dovecot/lib20_replication_plugin.so<br>Feb 21 16:31:51 Debug: Loading modules from directory: <br>/usr/lib64/dovecot/doveadm<br>Feb 21 16:31:51 Debug: Skipping module doveadm_acl_plugin, because <br>dlopen() failed: /usr/lib64/dovecot/doveadm/lib10_doveadm_acl_plugin.so: <br>undefined symbol: acl_user_module (this is usually intentional, so just <br>ignore this message)<br>Feb 21 16:31:51 Debug: Skipping module doveadm_quota_plugin, because <br>dlopen() failed: <br>/usr/lib64/dovecot/doveadm/lib10_doveadm_quota_plugin.so: undefined <br>symbol: quota_user_module (this is usually intentional, so just ignore <br>this message)<br>Feb 21 16:31:51 Debug: Skipping module doveadm_fts_plugin, because <br>dlopen() failed: /usr/lib64/dovecot/doveadm/lib20_doveadm_fts_plugin.so: <br>undefined symbol: fts_user_get_language_list (this is usually <br>intentional, so just ignore this message)<br>Feb 21 16:31:51 Debug: Skipping module doveadm_mail_crypt_plugin, <br>because dlopen() failed: <br>/usr/lib64/dovecot/doveadm/libdoveadm_mail_crypt_plugin.so: undefined <br>symbol: mail_crypt_box_get_pvt_digests (this is usually intentional, so <br>just ignore this message)<br>Feb 21 16:31:51 doveadm(testuser)<11258><>: Debug: auth-master: userdb <br>lookup(testuser): Started userdb lookup<br>Feb 21 16:31:51 doveadm(testuser)<11258><>: Debug: auth-master: conn <br>unix:/run/dovecot/auth-userdb: Connecting<br>Feb 21 16:31:51 doveadm(testuser)<11258><>: Debug: auth-master: conn <br>unix:/run/dovecot/auth-userdb (pid=3070,uid=0): Client connected (fd=9)<br>Feb 21 16:31:51 doveadm(testuser)<11258><>: Debug: auth-master: userdb <br>lookup(testuser): auth USER input: testuser system_groups_user=testuser <br>uid=1006 gid=1006 home=/home/testuser<br>Feb 21 16:31:51 doveadm(testuser)<11258><>: Debug: auth-master: userdb <br>lookup(testuser): Finished userdb lookup (username=testuser <br>system_groups_user=testuser uid=1006 gid=1006 home=/home/testuser)<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>Effective uid=1006, gid=1006, home=/home/testuser<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>Namespace inbox: type=private, prefix=, sep=, inbox=yes, hidden=no, <br>list=yes, subscriptions=yes location=maildir:~/Maildir<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>maildir++: root=/home/testuser/Maildir, index=, indexpvt=, control=, <br>inbox=/home/testuser/Maildir, alt=<br>Feb 21 16:31:51 doveadm(testuser): Debug: brain M: Namespace has <br>location maildir:~/Maildir<br>Feb 21 16:31:51 doveadm(testuser): Debug: Mailbox INBOX: Couldn't open <br>mailbox in list index: Mailbox not found<br>Feb 21 16:31:51 doveadm(testuser): Debug: Mailbox INBOX: Mailbox opened<br>Feb 21 16:31:51 doveadm(testuser): Debug: Namespace : Using permissions <br>from /home/testuser/Maildir: mode=0700 gid=default<br>Feb 21 16:31:51 doveadm(testuser): Debug: Mailbox INBOX: Mailbox opened<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>brain M: Local mailbox tree: INBOX guid=c0e4ea33c7231362fa2b0000ffcd8856 <br>uid_validity=1645421511 uid_next=1 subs=no last_change=0 last_subs=0<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>brain M: Remote mailbox tree: INBOX <br>guid=c04b3636c72313620f770000794c72b2 uid_validity=1645421511 uid_next=1 <br>subs=no last_change=0 last_subs=0<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>brain M: Mailbox INBOX: local=c0e4ea33c7231362fa2b0000ffcd8856/0/1, <br>remote=c04b3636c72313620f770000794c72b2/0/1: GUIDs conflict - will be <br>merged later<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>Mailbox INBOX: Mailbox opened<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>Mailbox INBOX: Mailbox opened<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>Mailbox INBOX: Mailbox opened<br>Feb 21 16:31:51 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: Debug: <br>brain M: Change during sync: Remote lost mailbox GUID <br>c04b3636c72313620f770000794c72b2 (maybe it was just deleted?)<br>Feb 21 16:31:52 doveadm(testuser)<11258><znOmIscjE2L6KwAA/82IVg>: <br>Warning: Mailbox changes caused a desync. You may want to run dsync <br>again: Remote lost mailbox GUID c04b3636c72313620f770000794c72b2 (maybe <br>it was just deleted?)<br>Feb 21 16:31:52 doveadm(11258): Debug: auth-master: conn <br>unix:/run/dovecot/auth-userdb (pid=3070,uid=0): Disconnected: Connection <br>closed (fd=9)<br><br>tornado ~ #<br><br>That message about the Mailbox changing causing a desync is what screws <br>up the client (in this case testuser) if they happen to be connected to <br>the mater at the time of the attempt. That is why client access was <br>impacted as soon as remote replication was enabled.<br><br>If this is run via normal dovecot sync (and not triggered) it results in <br>severe performance problems and disconnections for any clients connected <br>to the master replica pretty much anytime they try and move/delete anything.<br><br>I saw a couple of old posts over the years where other people have found <br>the same thing so I know I'm not the first person to run into this <br>problem and I suspect there are a lot more who have run into this <br>problem but not realised what was going on.<br><br>What do I need to do to get this fixed properly? Bailing out mid way <br>through replicating and disconnecting clients (and not self-healing) <br>surely can't be the intended behaviour so I'd consider this to be a <br>pretty nasty bug.<br><br>Reuben<br><br></pre></blockquote></div><div style='white-space: pre-wrap'><div class='k9mail-signature'>-- <br>Sent from my Android device with K-9 Mail. Please excuse my brevity.</div></div></body></html>