kernel-hardening.lists.openwall.com archive mirror
 help / color / mirror / Atom feed
* [kernel-hardening] Add overflow protection to kref
@ 2012-02-16 14:02 David Windsor
  2012-02-16 20:45 ` [kernel-hardening] " Kees Cook
  0 siblings, 1 reply; 31+ messages in thread
From: David Windsor @ 2012-02-16 14:02 UTC (permalink / raw)
  To: gregkh, ubuntu-hardened, kernel-hardening

Hi,

We are attempting to add various grsecurity/PAX features to upstream
Ubuntu kernels.

The PAX folks added refcount overflow protection by inserting
architecture-specific code in the increment paths of atomic_t.  For
instance:

static inline void atomic_inc(atomic_t *v)
 {
	asm volatile(LOCK_PREFIX "incl %0\n"

#ifdef CONFIG_PAX_REFCOUNT
		     "jno 0f\n"
		     LOCK_PREFIX "decl %0\n"
		     "int $4\n0:\n"
		     _ASM_EXTABLE(0b, 0b)
#endif

		     : "+m" (v->counter));
}

There are two distinct classes of users we need to consider here:
those who use atomic_t for reference counters and those who use
atomic_t for keeping track of statistics, like performance counters,
etc.; it makes little sense to overflow a performance counter, so we
shouldn't subject those users to the same protections as imposed on
actual reference counters.  The solution implemented by PAX is to
create a family of *_unchecked() functions and to patch
statistics-based users of atomic_t to use this interface.

PAX refcount overflow protection was developed before kref was
created.  I'd like to move overflow protection out of atomic_t and
into kref and gradually migrate atomic_t users to kref, leaving
atomic_t for those users who don't need overflow protection (e.g.
statistics-based counters).

I realize that there are many users of atomic_t needing overflow
protection, but the move to kref seems like the right thing to do in
this case.

Leaving the semantics of overflow detection aside for the moment, what
are everyone's thoughts on adding overflow protection to kref rather
than to atomic_t?

Also, I cherrypicked the refcount protection feature directly from the
PAX patch, with the original atomic_t protections in place, before
considering kref.  If anyone is interested, I can post that patch.

Thanks,
David Windsor

-- 
PGP: 6141 5FFD 11AE 9844 153E  F268 7C98 7268 6B19 6CC9

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

end of thread, other threads:[~2012-02-24 22:14 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-02-16 14:02 [kernel-hardening] Add overflow protection to kref David Windsor
2012-02-16 20:45 ` [kernel-hardening] " Kees Cook
2012-02-17  0:24   ` Greg Kroah-Hartman
2012-02-17  1:06     ` Kees Cook
2012-02-17  1:40       ` Greg KH
2012-02-17  2:11         ` [kernel-hardening] Re: [ubuntu-hardened] " Kees Cook
2012-02-17  2:48           ` David Windsor
2012-02-17  3:32             ` Greg KH
2012-02-17  6:33             ` Alexey Dobriyan
2012-02-17 13:23         ` [kernel-hardening] " pageexec
2012-02-17  7:59     ` Vasiliy Kulikov
2012-02-17 17:53       ` Greg KH
2012-02-17 17:54       ` Greg KH
2012-02-17 19:37         ` Vasiliy Kulikov
2012-02-17 23:39           ` Djalal Harouni
2012-02-18  1:44             ` Roland Dreier
2012-02-18 16:15               ` David Windsor
2012-02-18 16:35                 ` Vasiliy Kulikov
2012-02-18 16:18               ` Greg KH
2012-02-24 17:58                 ` David Windsor
2012-02-24 18:37                   ` Greg KH
2012-02-24 18:52                     ` Kees Cook
2012-02-24 19:05                       ` Nick Bowler
2012-02-24 19:13                         ` Vasiliy Kulikov
2012-02-24 19:35                           ` Nick Bowler
2012-02-24 21:59                           ` PaX Team
2012-02-24 18:58                     ` Vasiliy Kulikov
2012-02-24 19:41                       ` Greg KH
2012-02-24 20:04                         ` Kees Cook
2012-02-24 19:04                     ` David Windsor
2012-02-24 22:14                       ` PaX Team

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).