Re: [GIT PULL] ftrace: Check if pages were allocated before calling free_pages()
From: Steven Rostedt
Date: Thu Apr 01 2021 - 16:54:19 EST
On Thu, 1 Apr 2021 13:18:59 -0700
Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> On Thu, Apr 1, 2021 at 1:07 PM Steven Rostedt <rostedt@xxxxxxxxxxx> wrote:
> >
> > On Wed, 31 Mar 2021 11:03:21 -0700
> > Linus Torvalds <torvalds@xxxxxxxxxxxxxxxxxxxx> wrote:
> >
> > > @@ -6231,7 +6231,8 @@ static int ftrace_process_locs(struct module *mod,
> > > if (!addr)
> > > continue;
> > >
> > > - if (pg->index == pg->size) {
> > > + end_offset = (pg->index+1) * sizeof(pg->records[0]);
> > > + if (end_offset < PAGE_SIZE << pg->order) {
> >
> > I believe that needs to be:
> >
> > if (end_offset >= PAGE_SIZE << pg->order) {
>
[..]
> which will be
>
> end_offset = (3+1) * 1024;
>
> ie 4096. That just means that the struct fill fill things _up_to_ the
> end of the page.
>
> So only when the end_offset is strictly larger than the page would it
> have overflowed the allocation.
Ah, I forgot about the "+1" you added to the pg->index, which would make it
equivalent to replacing:
if (pg->index + 1 > pg->size) {
Will update and add your SOB.
Thanks,
-- Steve