Re: [PATCH dwarves v4 2/2] pahole: Inject kfunc decl tags into BTF

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Eduard,

On Wed, Feb 28, 2024 at 11:33:28PM +0200, Eduard Zingerman wrote:
> On Wed, 2024-02-28 at 09:07 -0700, Daniel Xu wrote:
> > Hi Eduard,
> >
> > Apologies for long delay - life has been busy.
> 
> Hi Daniel,
> 
> No problem, thank you for reaching back.
> 
> [...]
> 
> > > > +static char *get_func_name(const char *sym)
> > > > +{
> > > > +	char *func, *end;
> > > > +
> > > > +	if (strncmp(sym, BTF_ID_FUNC_PFX, sizeof(BTF_ID_FUNC_PFX) - 1))
> > > > +		return NULL;
> > > > +
> > > > +	/* Strip prefix */
> > > > +	func = strdup(sym + sizeof(BTF_ID_FUNC_PFX) - 1);
> > > > +
> > > > +	/* Strip suffix */
> > > > +	end = strrchr(func, '_');
> > > > +	if (!end || *(end - 1) != '_') {
> > > 
> > > Nit: this would do out of bounds access on malformed input
> > >      "__BTF_ID__func___"
> > 
> > I think this is actually ok. Reason is we have the strncmp() above
> > so we know the prefix is there. Then the strdup() in the malformed cased
> > returns empty string. And strrchr() will then return NULL, so we don't
> > enter the branch.
> > 
> > I tested it with: https://pastes.dxuuu.xyz/c3j4kk
> > 
> >         $ gcc test.c
> >         dxu@kashmir~/scratch $ ./a.out
> >         name=(null)
> > 
> 
> The test is for "__BTF_ID__func__", but nitpick is for "__BTF_ID__func___"
> (three underscores in the end).
> 

Ha, got it. Didn't see the 3rd one. Fixed in v5.

[...]

Thanks,
Daniel




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux