[Crash-utility] [PATCH] x86_64: Fix check for __per_cpu_offset initialisation

HAGIO KAZUHITO(萩尾 一仁) k-hagio-ab at nec.com
Mon Aug 16 01:47:15 UTC 2021


-----Original Message-----
> -----Original Message-----
> > -----Original Message-----
> > > Since at least kernel v2.6.30 the __per_cpu_offset gets initialized to
> > > __per_cpu_load. So first check if the __per_cpu_offset was set to a
> > > proper value before reading any per cpu variable to prevent potential
> > > bugs.
> > >
> > > Signed-off-by: Philipp Rudo <prudo at redhat.com>
> >
> > Thanks for the fix.
> >
> > Acked-by: Kazuhito Hagio <k-hagio-ab at nec.com>
> >
> > Kazu
> >
> > > ---
> > >  x86_64.c | 4 +++-
> > >  1 file changed, 3 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/x86_64.c b/x86_64.c
> > > index 6eb7d67..0bb8705 100644
> > > --- a/x86_64.c
> > > +++ b/x86_64.c
> > > @@ -1327,6 +1327,8 @@ x86_64_per_cpu_init(void)
> > >  		ms->stkinfo.isize = 16384;
> > >
> > >  	for (i = cpus = 0; i < NR_CPUS; i++) {
> > > +		if (kt->__per_cpu_offset[i] == symbol_value("__per_cpu_load"))
> > > +			break;
> 
> Rethought this, if __per_cpu_load is gone or renamed, crash cannot
> even start.  This check is not essential, so I will modify both hunks
> as follows and apply.

Applied.
https://github.com/crash-utility/crash/commit/44e5801d9016987b6b4ebd571bfde8ae3e75da7b

Thanks,
Kazu






More information about the Crash-utility mailing list