lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAMRc=McamALbJ2jtpeek9L3k2pX8rkpsqhMfgsBqaygG58-cTw@mail.gmail.com>
Date:   Tue, 19 Sep 2023 00:46:14 -0700
From:   brgl@...ev.pl
To:     Kent Gibson <warthog618@...il.com>
Cc:     Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Linus Walleij <linus.walleij@...aro.org>,
        Alexey Dobriyan <adobriyan@...il.com>,
        Peter Zijlstra <peterz@...radead.org>,
        Linus Torvalds <torvalds@...ux-foundation.org>,
        akpm@...ux-foundation.org, linux-gpio@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bartosz.golaszewski@...aro.org>,
        brgl@...ev.pl
Subject: Re: [PATCH v4] gpio: sim: fix an invalid __free() usage

On Tue, 19 Sep 2023 09:37:17 +0200, Kent Gibson <warthog618@...il.com> said:
> On Tue, Sep 19, 2023 at 12:31:36AM -0700, brgl@...ev.pl wrote:
>> On Mon, 18 Sep 2023 17:31:36 +0200, Andy Shevchenko
>> <andriy.shevchenko@...ux.intel.com> said:
>> > On Mon, Sep 18, 2023 at 04:55:33PM +0200, Bartosz Golaszewski wrote:
>> >> From: Bartosz Golaszewski <bartosz.golaszewski@...aro.org>
>> >>
>> >> gpio_sim_make_line_names() returns NULL or ERR_PTR() so we must not use
>> >> __free(kfree) on the returned address. Split this function into two, one
>> >> that determines the size of the "gpio-line-names" array to allocate and
>> >> one that actually sets the names at correct offsets. The allocation and
>> >> assignment of the managed pointer happens in between.
>> >
>> > ...
>> >
>> >> +	unsigned int size = 0;
>> >>
>> >>  	list_for_each_entry(line, &bank->line_list, siblings) {
>> >> +		if (!line->name || (line->offset >= bank->num_lines))
>> >>  			continue;
>> >>
>> >> +		size = line->offset + 1;
>> >>  	}
>> >>
>> >> +	return size;
>> >
>> > So, now the function iterates over all lines and returns the size of the last
>> > match, correct?
>> >
>> > Why not
>> >
>> > 	list_for_each_entry_reversed() {
>> > 		if (line->name && ())
>> > 			break;
>> > 	}
>> >
>> > 	return size;
>> >
>> > ?
>>
>> Because the line objects are not sorted by offset. They are added at the end
>> of the list in the order the user creates their corresponding configfs groups.
>>
>
> Then your patch is also broken as it uses the last named entry,
> not the named entry with the greatest offset??
>
> Cheers,
> Kent.
>

Yes, of course it is. Ironically v3 was at least correct in this part.

Thanks
Bart

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ