mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Ingo Oeser <ingo.oeser@informatik.tu-chemnitz.de>
To: Andrew Morton <akpm@digeo.com>
Cc: viro@parcelfarce.linux.theplanet.co.uk, linux-kernel@vger.kernel.org
Subject: Re: must-fix, version 6
Date: Sat, 31 May 2003 13:28:29 +0200	[thread overview]
Message-ID: <20030531132829.N626@nightmaster.csn.tu-chemnitz.de> (raw)
In-Reply-To: <20030530163720.399a8bac.akpm@digeo.com>; from akpm@digeo.com on Fri, May 30, 2003 at 04:37:20PM -0700

Hi Andrew,
hi Al,
hi LKML,

On Fri, May 30, 2003 at 04:37:20PM -0700, Andrew Morton wrote:
> +lib/kobject.c
> +~~~~~~~~~~~~~
> +
> +o kobject refcounting (comments from Al Viro):
> +
> +  _anything_ can grab a temporary reference to kobject.  IOW, if kobject is
> +  embedded into something that could be freed - it _MUST_ have a destructor
> +  and that destructor _MUST_ be the destructor for containing object.
> +
> +  Any violation of the above (and we already have a bunch of those) is a
> +  user-triggerable memory corruption.
> +
> +  We can tolerate it for a while in 2.5 (e.g.  during work on susbsystem we
> +  can decide to switch to that way of handling objects and have subsystem
> +  vulnerable for a while), but all such windows must be closed before 2.6 and
> +  during 2.6 we can't open them at all.
> +

I think a simple variant of this is to extend the kobject
structure with a backlink void* to the container of this object.

That way:
   - we can use kfree() as the default destructor 
   - use special destructors and pass the right object
   - warn and do the most useful thing (a kfree), until all 
     users are converted to either pass kfree or sth. else as an
     constructor.

This solution becomes non-sense, if we T <<< I, where T is the
amount of unique kobject type and I the sum of instances of all
types.

But even then, there can be a transitional model like the above,
but with a "default destructor" needing the container and the
kobject passed, which can later be reduced trivially to just have
the kobject passed and the container being caclulated with
"containerof" in the destructor with knowlegde about the type
where the kobject is in.

The latter solution needs lots of code to be written and is a
huge janitorial work. The backlink solution is much simpler, but
memory consuming.

Comments appreciated.

Regards

Ingo Oeser

  parent reply	other threads:[~2003-05-31 16:11 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-30 23:37 Andrew Morton
2003-05-30 23:38 ` Andrew Morton
2003-05-30 23:39 ` Andrew Morton
2003-05-31  3:28 ` William Lee Irwin III
2003-05-31  9:47 ` Christoph Hellwig
2003-05-31 11:28 ` Ingo Oeser [this message]
2003-06-01  0:10 ` Daniel Phillips
     [not found] <20030530235008$3775@gated-at.bofh.it>
     [not found] ` <20030531095009$09a0@gated-at.bofh.it>
2003-05-31 15:26   ` Arnd Bergmann
2003-05-31 19:31     ` Christoph Hellwig
2003-05-31 22:49       ` Arnd Bergmann
2003-05-31 19:36 Eric Benson

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=20030531132829.N626@nightmaster.csn.tu-chemnitz.de \
    --to=ingo.oeser@informatik.tu-chemnitz.de \
    --cc=akpm@digeo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    /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

all inboxes | Powered by JetHome®