From: Chris Wright <chrisw@sous-sol.org>
To: Bojan Smojver <bojan@rexursive.com>
Cc: Chris Wright <chrisw@sous-sol.org>,
Dave Jones <davej@codemonkey.org.uk>,
Andrew Morgan <morgan@kernel.org>,
Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: capget() overflows buffers.
Date: Thu, 22 May 2008 19:06:38 -0700 [thread overview]
Message-ID: <20080523020638.GF30402@sequoia.sous-sol.org> (raw)
In-Reply-To: <1211505622.20341.6.camel@shrek.rexursive.com>
* Bojan Smojver (bojan@rexursive.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.
next prev parent reply other threads:[~2008-05-23 2:07 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-05-22 14:04 Dave Jones
2008-05-22 17:58 ` Chris Wright
2008-05-22 20:53 ` Chris Wright
2008-05-22 22:52 ` Andrew G. Morgan
2008-05-22 23:37 ` Chris Wright
2008-05-23 7:09 ` Andrew G. Morgan
2008-05-23 15:57 ` Chris Wright
2008-05-24 6:25 ` Andrew G. Morgan
2008-05-24 8:07 ` Chris Wright
2008-05-27 1:17 ` [PATCH] security: was "Re: capget() overflows buffers." Andrew G. Morgan
2008-05-27 21:42 ` Chris Wright
2008-05-28 3:33 ` Andrew Morton
2008-05-23 18:26 ` capget() overflows buffers Chris Wright
2008-05-24 0:02 ` Andrew G. Morgan
2008-05-24 1:09 ` Chris Wright
2008-05-24 4:40 ` Andrew G. Morgan
2008-05-24 8:17 ` Chris Wright
2008-05-23 1:20 ` Bojan Smojver
2008-05-23 2:06 ` Chris Wright [this message]
2008-05-23 4:01 ` Bojan Smojver
2008-05-22 21:20 ` Bojan Smojver
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20080523020638.GF30402@sequoia.sous-sol.org \
--to=chrisw@sous-sol.org \
--cc=bojan@rexursive.com \
--cc=davej@codemonkey.org.uk \
--cc=linux-kernel@vger.kernel.org \
--cc=morgan@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome