[BUG] IMAP hibernation fails on FreeBSD 15.x with "Invalid peer_dev_major value"

Jordan Ostrev via dovecot <[email protected]> Wed, 24 Jun 2026 21:34:40 +0300
Newsgroups gmane.mail.imap.dovecot
Message-ID <[email protected]>
--===============8344339775269812365==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_E758610E-73E7-4AE4-9AAA-3A16EA01F079"


--Apple-Mail=_E758610E-73E7-4AE4-9AAA-3A16EA01F079
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

Hi,
IMAP hibernation compiles and attempts to run on FreeBSD 15.x (tested =
with Dovecot 2.4.4 and FreeBSD 15.1), but fails at runtime with:
plain

imap-hibernate: Error: conn unix:imap-hibernate (uid=3D125): Failed to =
parse client input: Invalid peer_dev_major value: 18446744073709551615
Jun 24 21:27:08 classic dovecot[36888]: imap-hibernate: Error: conn =
unix:imap-hibernate (uid=3D125): Failed to parse client input: Invalid =
peer_dev_major value: 18446744073709551615
Jun 24 21:27:08 classic dovecot[36888]: =
imap([email protected])<37120><ExaV/gNVAdt/AAAB>: Error: Couldn't =
hibernate imap client: /var/run/dovecot/imap-hibernate returned failure: =
Failed to parse client input: Invalid peer_dev_major value: =
18446744073709551615
Root cause:
In src/imap/imap-client-hibernate.c, the code serializes peer_dev_major =
and peer_dev_minor using major() and minor() macros:
c

str_printfa(cmd, =
"\tpeer_dev_major=3D%lu\tpeer_dev_minor=3D%lu\tpeer_ino=3D%llu",
            (unsigned long)major(peer_st.st_dev),
            (unsigned long)minor(peer_st.st_dev),
            (unsigned long long)peer_st.st_ino);
On FreeBSD, major() and minor() can return UINT64_MAX =
(18446744073709551615) for file descriptors that are not block/character =
devices (such as sockets on tmpfs/devfs). This value exceeds UINT_MAX =
and cannot be parsed by str_to_uint() in imap-master-client.c.
Historical context:
This was discussed on the Dovecot mailing list in July 2019 (thread: =
"Hibernation errors") but apparently never resolved upstream. The same =
failure mode persists in Dovecot 2.4.4.
Impact:
IMAP hibernation is effectively non-functional on FreeBSD 15.x
Processes remain running indefinitely instead of being hibernated
Documentation note:
The Dovecot 2.4 documentation states that hibernation "is not supported =
on kqueue based systems currently, such as FreeBSD." However, the code =
still compiles and attempts to run, producing these errors rather than =
being disabled at compile time or gracefully skipped at runtime.
Would it make sense to either:
Disable hibernation at compile time for kqueue systems, or
Add validation for major()/minor() return values before serialization?
Thanks,
Jordan=

--Apple-Mail=_E758610E-73E7-4AE4-9AAA-3A16EA01F079
Content-Transfer-Encoding: 7bit
MIME-Version: 1.0
Content-Type: text/plain; charset="us-ascii"

   Hi,
   IMAP hibernation compiles and attempts to run on FreeBSD 15.x (tested with
   Dovecot 2.4.4 and FreeBSD 15.1), but fails at runtime with:
   plain

 imap-hibernate: Error: conn unix:imap-hibernate (uid=125): Failed to parse client input: Invalid peer_dev_major value: 18446744073709551615

 Jun 24 21:27:08 classic dovecot[36888]: imap-hibernate: Error: conn unix:imap-hibernate (uid=125): Failed to parse client input: Invalid peer_dev_major value: 18446744073709551615
 Jun 24 21:27:08 classic dovecot[36888]: imap([email protected])<37120><ExaV/gNVAdt/AAAB>: Error: Couldn't hibernate imap client: /var/run/dovecot/imap-hibernate returned failure: Failed to parse client input: Invalid peer_dev_major value: 18446744073709551615

   Root cause:
   In src/imap/imap-client-hibernate.c, the code serializes peer_dev_major
   and peer_dev_minor using major() and minor() macros:
   c

 str_printfa(cmd, "\tpeer_dev_major=%lu\tpeer_dev_minor=%lu\tpeer_ino=%llu",
             (unsigned long)major(peer_st.st_dev),
             (unsigned long)minor(peer_st.st_dev),
             (unsigned long long)peer_st.st_ino);

   On FreeBSD, major() and minor() can return UINT64_MAX
   (18446744073709551615) for file descriptors that are not block/character
   devices (such as sockets on tmpfs/devfs). This value exceeds UINT_MAX and
   cannot be parsed by str_to_uint() in imap-master-client.c.
   Historical context:
   This was discussed on the Dovecot mailing list in July 2019 (thread:
   "Hibernation errors") but apparently never resolved upstream. The same
   failure mode persists in Dovecot 2.4.4.
   Impact:

     o IMAP hibernation is effectively non-functional on FreeBSD 15.x
     o Processes remain running indefinitely instead of being hibernated

   Documentation note:
   The Dovecot 2.4 documentation states that hibernation "is not supported on
   kqueue based systems currently, such as FreeBSD." However, the code still
   compiles and attempts to run, producing these errors rather than being
   disabled at compile time or gracefully skipped at runtime.
   Would it make sense to either:

    1. Disable hibernation at compile time for kqueue systems, or
    2. Add validation for major()/minor() return values before serialization?

   Thanks,
   Jordan

--Apple-Mail=_E758610E-73E7-4AE4-9AAA-3A16EA01F079--

--===============8344339775269812365==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
dovecot mailing list -- [email protected]
To unsubscribe send an email to [email protected]

--===============8344339775269812365==--