All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff Epler <jepler@unpythonic.net>
To: Muni Sekhar <munisekharrms@gmail.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: kfree a pointer "from the middle" causing protection faults
Date: Wed, 2 Sep 2015 11:09:50 -0500	[thread overview]
Message-ID: <20150902160949.GA82121@unpythonic.net> (raw)
In-Reply-To: <CAHhAz+g7HJX1HAYqyZT9VLV9GerJT7iuiJ=2ahHFLFX-O2ryQA@mail.gmail.com>

On Wed, Sep 02, 2015 at 08:32:15PM +0530, Muni Sekhar wrote:
>  [ Please keep me in CC as I'm not subscribed to the list]
> 
> Hello,
> 
> 
> I am getting protection faults in different kernel modules if I try to
> free a pointer "from the middle" for example, look at the following
> code:
[..]

Most memory allocators require the pointer eventually passed to the
freeing function is the same pointer as the one returned from the
allocating function.  This is true for libc malloc/free, for instance.
As far as I know, it is true for the Linux allocators such as kzalloc.
The bug lies in whatever part of linux makes the invalid kfree call.

I have not found any documentation that kernel kzalloc/kfree allow
passing a pointer "from the middle".  For instance,
    These routines are used to dynamically request pointer-aligned chunks of
    memory, like malloc and free do in userspace
    https://www.kernel.org/doc/htmldocs/kernel-hacking/routines-kmalloc.html

If the faulty code that you allude to is in the Linux source then please
say what it is so that developers can fix it.  If it's an out of source
module or kernel patch then contact the supplier of that code.

Jeff

  reply	other threads:[~2015-09-02 16:10 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-02 15:02 kfree a pointer "from the middle" causing protection faults Muni Sekhar
2015-09-02 16:09 ` Jeff Epler [this message]
2015-09-03  4:24   ` Muni Sekhar
2015-09-02 16:29 ` Dmitry Torokhov

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=20150902160949.GA82121@unpythonic.net \
    --to=jepler@unpythonic.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=munisekharrms@gmail.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.