From: Tejun Heo <tj@kernel.org>
To: Lai Jiangshan <laijs@cn.fujitsu.com>
Cc: linux-kernel@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Jean Delvare <jdelvare@suse.de>,
Monam Agarwal <monamagarwal123@gmail.com>,
Jeff Layton <jlayton@redhat.com>,
Andreas Gruenbacher <agruen@linbit.com>,
Stephen Hemminger <stephen@networkplumber.org>
Subject: Re: [PATCH 3/8] idr: fix NULL pointer dereference when ida_remove(unallocated_id)
Date: Fri, 18 Apr 2014 13:09:35 -0400 [thread overview]
Message-ID: <20140418170935.GA23576@htj.dyndns.org> (raw)
In-Reply-To: <1397825404-12039-4-git-send-email-laijs@cn.fujitsu.com>
On Fri, Apr 18, 2014 at 08:49:50PM +0800, Lai Jiangshan wrote:
> If the ida has at least one existed_id, and when an special unallocated_id
existing id or allocated id
when an unallocated id which
meets a certain condition is passed to...
> is passed to the ida_remove(), the system will crash because it hits NULL
> pointer dereference.
>
> This special unallocated_id is that it shares the same lowest idr layer with
The condition is that the ID shares the...
> an exsited_id, but the idr slot is different(if the unallocated_id is allocated).
the existing ID, would be different if the unallocated ID were to be allocated.
> In this case the supposed idr slot of the unallocated_id is NULL,
matching for
> It means @bitmap == NULL, and when the code dereference it, it crash the kernel.
causing @bitmap to be NULL which the function dereferences without
checking crashing the kernel.
>
> See the test code:
>
> static void test3(void)
> {
> int id;
> DEFINE_IDA(test_ida);
>
> printk(KERN_INFO "Start test3\n");
> if (ida_pre_get(&test_ida, GFP_KERNEL) < 0) return;
> if (ida_get_new(&test_ida, &id) < 0) return;
> ida_remove(&test_ida, 4000); /* bug: null deference here */
> printk(KERN_INFO "End of test3\n");
> }
>
> It only happens when unallocated_id, it is caller's fault. It is not
It happens only when the caller tries to free an unallocated ID which
is the caller's fault.
> a bug. But it is better to add the proper check and complains instead
and complain rather than crashing the kernel
> of crashing the kernel.
>
> Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
Acked-by: Tejun Heo <tj@kernel.org>
Thanks.
--
tejun
next prev parent reply other threads:[~2014-04-18 17:09 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-18 12:49 [PATCH 0/8] idr: fix & cleanup Lai Jiangshan
2014-04-18 12:49 ` [PATCH 1/8] idr: fix overflow bug for the max-high layer Lai Jiangshan
2014-04-18 16:29 ` Tejun Heo
2014-04-18 17:08 ` Lai Jiangshan
2014-04-18 17:10 ` Tejun Heo
2014-04-18 12:49 ` [PATCH 2/8] idr: fix unexpected id-removal when idr_remove(unallocated_id) Lai Jiangshan
2014-04-18 16:57 ` Tejun Heo
2014-04-18 12:49 ` [PATCH 3/8] idr: fix NULL pointer dereference when ida_remove(unallocated_id) Lai Jiangshan
2014-04-18 17:09 ` Tejun Heo [this message]
2014-04-18 12:49 ` [PATCH 4/8] idr: fix idr_replace()'s returned error code Lai Jiangshan
2014-04-18 17:12 ` Tejun Heo
2014-04-18 12:49 ` [PATCH 5/8] idr: covert BUG_ON() to WARN_ON_ONCE() if the argument is invalid Lai Jiangshan
2014-04-18 17:14 ` Tejun Heo
2014-04-18 12:49 ` [PATCH 6/8] idr: avoid ping-pong Lai Jiangshan
2014-04-18 17:17 ` Tejun Heo
2014-04-19 10:43 ` Lai Jiangshan
2014-04-19 13:01 ` Tejun Heo
2014-04-19 14:23 ` Lai Jiangshan
2014-04-18 12:49 ` [PATCH 7/8] idr: don't need to shink the free list when idr_remove() Lai Jiangshan
2014-04-18 17:19 ` Tejun Heo
2014-04-18 12:49 ` [PATCH 8/8] idr: reduce the unneeded check in free_layer() Lai Jiangshan
2014-04-18 17:21 ` Tejun Heo
2014-04-19 11:38 ` [PATCH 0/9 V2] idr: fix & cleanup Lai Jiangshan
2014-04-19 11:38 ` [PATCH 1/9 V2] idr: fix overflow bug during maximum ID calculation at maximum height Lai Jiangshan
2014-04-19 11:38 ` [PATCH 2/9 V2] idr: fix unexpected ID-removal when idr_remove(unallocated_id) Lai Jiangshan
2014-04-19 11:38 ` [PATCH 3/9 V2] idr: fix NULL pointer dereference when ida_remove(unallocated_id) Lai Jiangshan
2014-04-19 11:38 ` [PATCH 4/9 V2] idr: fix idr_replace()'s returned error code Lai Jiangshan
2014-04-19 11:38 ` [PATCH 5/9 V2] idr: covert BUG_ON() to WARN_ON_ONCE() if the argument is invalid Lai Jiangshan
2014-04-19 13:07 ` Tejun Heo
2014-04-19 14:04 ` Lai Jiangshan
2014-04-19 23:47 ` Tejun Heo
2014-04-19 11:38 ` [PATCH 6/9 V2] idr: avoid ping-pong Lai Jiangshan
2014-04-19 11:38 ` [PATCH 7/9 V2] idr: don't need to shink the free list when idr_remove() Lai Jiangshan
2014-04-19 11:38 ` [PATCH 8/9 V2] idr: reduce the unneeded check in free_layer() Lai Jiangshan
2014-04-19 11:38 ` [PATCH 9/9 V2] idr: remove useless C-PreProcessor branch Lai Jiangshan
2014-04-19 23:51 ` Tejun Heo
2014-04-20 3:56 ` Lai Jiangshan
2014-04-20 11:29 ` Tejun Heo
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=20140418170935.GA23576@htj.dyndns.org \
--to=tj@kernel.org \
--cc=agruen@linbit.com \
--cc=akpm@linux-foundation.org \
--cc=jdelvare@suse.de \
--cc=jlayton@redhat.com \
--cc=laijs@cn.fujitsu.com \
--cc=linux-kernel@vger.kernel.org \
--cc=monamagarwal123@gmail.com \
--cc=stephen@networkplumber.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