[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <87ldzaotcg.fsf@yhuang6-desk2.ccr.corp.intel.com>
Date: Mon, 30 Sep 2024 08:53:03 +0800
From: "Huang, Ying" <ying.huang@...el.com>
To: Kees Bakker <kees@...erbout.nl>
Cc: Andrew Morton <akpm@...ux-foundation.org>, linux-mm@...ck.org,
linux-kernel@...r.kernel.org, linux-cxl@...r.kernel.org, Dan Williams
<dan.j.williams@...el.com>, David Hildenbrand <david@...hat.com>,
Davidlohr Bueso <dave@...olabs.net>, Jonathan Cameron
<jonathan.cameron@...wei.com>, Dave Jiang <dave.jiang@...el.com>, Alison
Schofield <alison.schofield@...el.com>, Vishal Verma
<vishal.l.verma@...el.com>, Ira Weiny <ira.weiny@...el.com>, Alistair
Popple <apopple@...dia.com>, Andy Shevchenko
<andriy.shevchenko@...ux.intel.com>, Bjorn Helgaas <bhelgaas@...gle.com>,
Baoquan He <bhe@...hat.com>
Subject: Re: [PATCH -v3 3/3] resource, kunit: Add test case for
region_intersects()
Kees Bakker <kees@...erbout.nl> writes:
> Op 06-09-2024 om 05:07 schreef Huang Ying:
>> [...]
>> +static void resource_test_insert_resource(struct kunit *test, struct resource *parent,
>> + resource_size_t start, resource_size_t size,
>> + const char *name, unsigned long flags)
>> +{
>> + struct resource *res;
>> +
>> + res = kzalloc(sizeof(*res), GFP_KERNEL);
>> + KUNIT_ASSERT_NOT_NULL(test, res);
>> +
>> + res->name = name;
>> + res->start = start;
>> + res->end = start + size - 1;
>> + res->flags = flags;
>> + if (insert_resource(parent, res)) {
>> + kfree(res);
>> + KUNIT_FAIL_AND_ABORT(test, "Fail to insert resource %pR\n", res);
> Isn't this a user-after-free?
Good catch! Thanks for pointing this out. I should be more careful for
the error path.
>> + }
>> +
>> + kunit_add_action_or_reset(test, remove_free_resource, res);
This may cause use-after-free if failed to allocate memory for
add_action. Will fix this too.
>> +}
>>
--
Best Regards,
Huang, Ying
Powered by blists - more mailing lists