tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: suprious reboot on netbsd-6:i386 with PAE

Hi Emanuel,

sorry for not being helpful with the other problems, but

Unfortunately using a -current kernel is not an option just right now,
because of kernel bugs. For a reason I have not yet tracked down, dovecot
is broken (IPC between (pop|imap)-login and auth process is screwed),  and
sshd randomly cuts connexions because of an invalid HMAC. If the two problems
rings a bell for someone, I am interested.

In case you are using dovecot2, try the attached patch.

The problem is  a change in the semantics of local domain
socket addresses. Previously, they had a fixed size, and the
path name contained within the address was therefor normally
'\0'-terminated. Now the address is the common socket address
part plus the pathname, where the terminating '\0' is _not_
part of the address. When the kernel copies out some local
domain part, the user has to supply the terminator, if it wants
to use the path as some ordinary string, e.g. in strlen.

I haven't made up my mind on how to really fix this, but I
tend to include the terminating '\0' within the address.

Note that there are even programs within our own
distribution which trigger core dumps due to this change
(at least kdump does).

--                         Wolfgang Solfrank
--- src/lib/net.c.orig  2013-11-24 16:45:57.000000000 +0100
+++ src/lib/net.c       2013-11-24 16:53:55.000000000 +0100
@@ -28,7 +28,10 @@
 union sockaddr_union_unix {
        struct sockaddr sa;
-       struct sockaddr_un un;
+       struct {
+               struct sockaddr_un un;
+               char terminator;
+       } _un;
 #ifdef HAVE_IPV6
@@ -280,8 +283,8 @@
        int fd, ret;
        memset(&sa, 0, sizeof(sa));
-       sa.un.sun_family = AF_UNIX;
-       if (i_strocpy(sa.un.sun_path, path, sizeof(sa.un.sun_path)) < 0) {
+       sa._un.un.sun_family = AF_UNIX;
+       if (i_strocpy(sa._un.un.sun_path, path, sizeof(sa._un.un.sun_path)) < 
0) {
                /* too long path */
                errno = ENAMETOOLONG;
@@ -744,13 +747,14 @@
        union sockaddr_union_unix so;
        socklen_t addrlen = sizeof(so);
+       memset(&so, 0, sizeof so);
        if (getsockname(fd, &, &addrlen) < 0)
                return -1;
-       if (so.un.sun_family != AF_UNIX) {
+       if (so._un.un.sun_family != AF_UNIX) {
                errno = ENOTSOCK;
                return -1;
-       *name_r = t_strdup(so.un.sun_path);
+       *name_r = t_strdup(so._un.un.sun_path);
        return 0;

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature

Home | Main Index | Thread Index | Old Index