[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20080523020638.GF30402@sequoia.sous-sol.org>
Date: Thu, 22 May 2008 19:06:38 -0700
From: Chris Wright <chrisw@...s-sol.org>
To: Bojan Smojver <bojan@...ursive.com>
Cc: Chris Wright <chrisw@...s-sol.org>,
Dave Jones <davej@...emonkey.org.uk>,
Andrew Morgan <morgan@...nel.org>,
Linux Kernel <linux-kernel@...r.kernel.org>
Subject: Re: capget() overflows buffers.
* Bojan Smojver (bojan@...ursive.com) wrote:
> On Thu, 2008-05-22 at 13:53 -0700, Chris Wright wrote:
>
> > cap_user_header_t head = (cap_user_header_t) xcalloc(1, sizeof(cap_user_header_t));
> > cap_user_data_t cap = (cap_user_data_t) xcalloc(1, sizeof(cap_user_data_t));
>
> BTW, both of the above allocations have been fixed in Squid 2 & 3, as
> they were incorrect. Not sure how that worked before - probably by
> accident.
Heh, indeed ;-)
If you want to fix the problem you're having in squid you've got a few
choices:
1) switch to using the libcap interface, arguably the best sol'n since
you know longer have to directly care about the kernel interface.
only drawback is the additional library dependency.
2) force head->version to the older version, something like:
#ifdef _LINUX_CAPABILITY_VERSION_1
head->version = _LINUX_CAPABILITY_VERSION_1;
#else
head->version = _LINUX_CAPABILITY_VERSION;
#endif
this has the drawback of always using the older 32bit caps, probably
fine here, since you're not using new caps.
3) try to allow for current 64bit caps
#define CAP_TO_INDEX(x) ((x) >> 5)
#define CAP_TO_MASK(x) (1 << ((x) & 31))
#define CAP_ADD(_data, _set, _cap) _data[CAP_TO_INDEX(_cap)]._set |= CAP_TO_MASK(_cap)
cap_user_data_t cap = (cap_user_data_t) xcalloc(_LINUX_CAPABILITY_U32S, sizeof(*cap));
head->version = _LINUX_CAPABILITY_VERSION;
CAP_ADD(cap, effective, CAP_NET_BIND_SERVICE);
etc...
this has the drawback of not being guaranteed to work in the future on
newer kernels and needs ifdefs to work on older kernels, is complicated,
and not worth it.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists