pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
[PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size
3+ messages / 2 participants
[nested] [flat]

* [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size
@ 2011-05-22 14:19 Martin Pitt <mpitt@debian.org>
  2011-05-29 18:08 ` Re: [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Martin Pitt @ 2011-05-22 14:19 UTC (permalink / raw)
  To: pgsql-bugs; +Cc: Petr Salinger <Petr.Salinger@seznam.cz>; 612888@bugs.debian.org

Hello PostgreSQL developers,

I got this report in http://bugs.debian.org/612888 about ident failure
on the Debian kFreeBSD kernel on 64 bit. The sizeof(struct cmsgcred)
is 84 on kfrebsd-amd64, there is no reason for padding it  at the end
to 8-byte boundary by kernel. However, the process is blocking on
receiving those extra 4 bytes, which will never come.

Petr Salinger <Petr.Salinger@seznam.cz> sent a straightforward patch
for this, I turned it into a git-formatted patch for your convenience.

Thanks,

Martin

----- Forwarded message from skull <skull@spin.it> -----

Date: Fri, 11 Feb 2011 11:40:27 +0100
From: skull <skull@spin.it>
To: Debian Bug Tracking System <submit@bugs.debian.org>
Subject: Bug#612888: postgresql: access denied as postgres user after default install (kFreeBSD specific)
X-Spam-Status: No, score=0.0 required=4.0 tests=BAYES_50 autolearn=no version=3.2.5
Reply-To: skull <skull@spin.it>, 612888@bugs.debian.org

Package: postgresql
Version: 8.4.7-0squeeze2
Severity: important


After default installation, postgres denies access to postgres user:

root@netmon:~# su - postgres
postgres@netmon:~$ psql template1
psql: FATAL:  Ident authentication failed for user "postgres"

This happens on kFreeBSD flavour only (AFAIK)


-- System Information:
Debian Release: 6.0
  APT prefers squeeze-updates
  APT policy: (500, 'squeeze-updates'), (500, 'stable')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 8.1-1-amd64
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages postgresql depends on:
ii  postgresql-8.4           8.4.7-0squeeze2 object-relational SQL database, ve

postgresql recommends no packages.

postgresql suggests no packages.

-- no debconf information



----- End forwarded message -----

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)

Attachments:

0001-Fix-size-of-struct-cmsgcred.patch (text/x-diff, 1.1K) download From e4630822de32ad24888711ae1699e4fb33086af4 Mon Sep 17 00:00:00 2001 From: Petr Salinger <Petr.Salinger@seznam.cz> Date: Sun, 22 May 2011 15:24:49 +0200 Subject: [PATCH] Fix size of struct cmsgcred The sizeof(struct cmsgcred) is 84 on kfrebsd-amd64, there is no reason for padding it at the end to 8-byte boundary by kernel. However, the process is blocking on receiving those extra 4 bytes, which will never come. This breaks ident authentication on kFreeBSD 64 bit. http://bugs.debian.org/612888 --- src/backend/libpq/auth.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 618f007..865819b 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -1897,7 +1897,7 @@ auth_peer(hbaPort *port) Cred *cred; /* Compute size without padding */ - char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))]; /* for NetBSD */ + char cmsgmem[ALIGN(sizeof(struct cmsghdr)) + sizeof(Cred)]; /* for NetBSD */ /* Point to start of first structure */ struct cmsghdr *cmsg = (struct cmsghdr *) cmsgmem; -- 1.7.5.1
signature.asc (application/pgp-signature, 835B) download ^ permalink raw reply [nested|flat] 3+ messages in thread

* Re: [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size
  2011-05-22 14:19 [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Martin Pitt <mpitt@debian.org>
@ 2011-05-29 18:08 ` Tom Lane <tgl@sss.pgh.pa.us>
  2011-05-29 18:49   ` Re: [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 1 reply; 3+ messages in thread

From: Tom Lane @ 2011-05-29 18:08 UTC (permalink / raw)
  To: Martin Pitt <mpitt@debian.org>; +Cc: pgsql-bugs; Petr Salinger <Petr.Salinger@seznam.cz>; 612888@bugs.debian.org

Martin Pitt <mpitt@debian.org> writes:
>  	/* Compute size without padding */
> -	char		cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))];	/* for NetBSD */
> +	char		cmsgmem[ALIGN(sizeof(struct cmsghdr)) + sizeof(Cred)];	/* for NetBSD */

Hm.  That code's been like that for a very long time (since 2001
according to the git history...).  How much confidence can we have
that this change won't result in breakage on other flavors of *BSD?

(I'm unable to test this myself, not having any platforms on which
this branch of auth_peer gets compiled...)

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size
  2011-05-22 14:19 [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Martin Pitt <mpitt@debian.org>
  2011-05-29 18:08 ` Re: [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Tom Lane <tgl@sss.pgh.pa.us>
@ 2011-05-29 18:49   ` Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2011-05-29 18:49 UTC (permalink / raw)
  To: Martin Pitt <mpitt@debian.org>; +Cc: pgsql-bugs; Petr Salinger <Petr.Salinger@seznam.cz>; 612888@bugs.debian.org

I wrote:
> Martin Pitt <mpitt@debian.org> writes:
>> /* Compute size without padding */
>> -	char		cmsgmem[ALIGN(sizeof(struct cmsghdr)) + ALIGN(sizeof(Cred))];	/* for NetBSD */
>> +	char		cmsgmem[ALIGN(sizeof(struct cmsghdr)) + sizeof(Cred)];	/* for NetBSD */

> Hm.  That code's been like that for a very long time (since 2001
> according to the git history...).  How much confidence can we have
> that this change won't result in breakage on other flavors of *BSD?

BTW, I wonder whether the real bug isn't on the libpq side instead.
I notice that its idea of the cmsgmem size is not like the backend's:

#ifdef HAVE_STRUCT_CMSGCRED
	/* Prevent padding */
	char		cmsgmem[sizeof(struct cmsghdr) + sizeof(struct cmsgcred)];

This corresponds to the original coding in the backend, but not to what
the code looks like now.  The subsequent whacking around of the backend
cmsgmem declaration was documented as fixing problems on NetBSD and then
OpenBSD.  If it's true as per the libpq comment that only FreeBSD needs
the client-side cmsgmem buffer, this might not have gotten retested.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2011-05-29 18:49 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2011-05-22 14:19 [PATCH] ident authentication fails on kFreeBSD/x86-64 due to wrong struct size Martin Pitt <mpitt@debian.org>
2011-05-29 18:08 ` Tom Lane <tgl@sss.pgh.pa.us>
2011-05-29 18:49   ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox