Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1YNShp-0002sg-Q3 for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Feb 2015 20:55:49 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1YNShp-00010D-4m for pgsql-bugs@arkaria.postgresql.org; Mon, 16 Feb 2015 20:55:49 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YNSho-000107-HZ for pgsql-bugs@postgresql.org; Mon, 16 Feb 2015 20:55:48 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.2:DHE_RSA_AES_256_CBC_SHA256:256) (Exim 4.80) (envelope-from ) id 1YNShk-000183-RT for pgsql-bugs@postgresql.org; Mon, 16 Feb 2015 20:55:47 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id t1GKtcKw016514; Mon, 16 Feb 2015 15:55:38 -0500 From: Tom Lane To: Hugo Osvaldo Barrera cc: Heikki Linnakangas , pgsql-bugs@postgresql.org Subject: Re: postgresql-server exiting abnormally after an OS upgrade In-reply-to: <20150216202138.GB20474@athena.barrera.io> References: <20150212224257.GA16161@athena.barrera.io> <54DDFC33.6090703@vmware.com> <20150216202138.GB20474@athena.barrera.io> Comments: In-reply-to Hugo Osvaldo Barrera message dated "Mon, 16 Feb 2015 17:21:38 -0300" Date: Mon, 16 Feb 2015 15:55:38 -0500 Message-ID: <16513.1424120138@sss.pgh.pa.us> X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org Hugo Osvaldo Barrera writes: > On 2015-02-13 15:29, Heikki Linnakangas wrote: >> Can you get a core dump and a stack trace from it? > It certainly took me a bit, but, with some help, I managed to get one: > (gdb) bt > #0 0x0000110a2815b92a in kill () at :2 > #1 0x0000110a28195119 in abort () at /usr/src/lib/libc/stdlib/abort.c:53 > #2 0x0000110a2816a238 in memcpy (dst0=0xfb8d4, src0=0x6, length=0) at /usr/src/lib/libc/string/memcpy.c:65 > #3 0x000011080cf8d1b1 in check_ip (raddr=0x110a899f7918, addr=0x110a899f9058, mask=0x110a899f9158) at hba.c:704 > #4 0x000011080cf90a04 in check_hba (port=0x110a899f7800) at hba.c:1718 Huh. You didn't say whether this is 9.3 or 9.4, but it doesn't matter because that code is the same in both; the crash is happening here: static bool check_ip(SockAddr *raddr, struct sockaddr * addr, struct sockaddr * mask) { ... /* * If we're connected on IPv6 but the file specifies an IPv4 address * to match against, promote the latter to an IPv6 address before * trying to match the client's address. */ struct sockaddr_storage addrcopy, maskcopy; memcpy(&addrcopy, &addr, sizeof(addrcopy)); ---> memcpy(&maskcopy, &mask, sizeof(maskcopy)); Looking at this, the code seems wrong on its face: the memcpy sources should be "addr" and "mask", not "&addr" and "&mask". Apparently, no one has ever used or tested this case since it was put in :-(. I find that a bit astonishing given the steady creep of IPv6 support, but it's hard to see how the code could possibly work correctly as-is. Probably the reason why this was triggered by an OS upgrade is that your system is now choosing to make the DB connection over IPv6 not IPv4. Or maybe it was doing that right along but you now have a memcpy that is doing more checking of its arguments than before (this is evidently an argument sanity check and not a straight SIGSEGV). Anyway you could work around it for now by being sure to list IPv6 equivalent addresses before IPv4 addresses in your pg_hba.conf. We'll fix it properly in the next releases. regards, tom lane -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs