Re: [PATCH net-next 2/4] netconsole: Add option to auto-populate CPU number in userdata

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

 



On Tue, Nov 19, 2024 at 09:07:45AM -0800, Breno Leitao wrote:
> > >  #endif
> > >  	bool			enabled;
> > >  	bool			extended;
> > 
> > > +	/* Check if CPU NR should be populated, and append it to the user
> > > +	 * dictionary.
> > > +	 */
> > > +	if (child_count < MAX_USERDATA_ITEMS && nt->userdata_auto & AUTO_CPU_NR)
> > > +		scnprintf(&nt->userdata_complete[complete_idx],
> > > +			  MAX_USERDATA_ENTRY_LENGTH, " cpu=%u\n",
> > > +			  raw_smp_processor_id());
> > 
> > I guess it may be tricky for backward compat, but shouldn't we return
> > an error rather than silently skip?
> 
> yes, this should be easy to do, in fact. Probably return -E2BIG to
> userspace when trying to update the entry. I thought about something as
> the following patch, and piggy-back into it.

Back to this topic, in fact, this is not needed at all. 

The configfs make item helper (userdatum_make_item()) checks for
exceeding entries, and fails if an additional entry is created.


	static struct config_item *userdatum_make_item(struct config_group *group,
							const char *name)
	{
		....
		child_count = list_count_nodes(&nt->userdata_group.cg_children);
		if (child_count >= MAX_USERDATA_ITEMS)
			return ERR_PTR(-ENOSPC);


I've sent an additional test for this mechanism, and make the check in
update_userdata() a warning instead of just silently dropping the entry.

https://lore.kernel.org/all/20241204-netcons_overflow_test-v1-0-a85a8d0ace21@xxxxxxxxxx/




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite Forum]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux