Re: [PATCH 3/4] software node: verify that property data is not on stack

From: Andy Shevchenko

Date: Wed Mar 25 2026 - 08:09:01 EST


On Tue, Mar 24, 2026 at 09:17:18AM -0700, Dmitry Torokhov wrote:
> On Tue, Mar 24, 2026 at 02:33:31PM +0200, Andy Shevchenko wrote:
> > On Mon, Mar 23, 2026 at 05:39:39PM -0700, Dmitry Torokhov wrote:
> > > When registering a software node, ensure that the property data is not
> > > located on the stack, as it is expected to persist for the lifetime of
> > > the node.

...

> > > +#include <linux/sched/task_stack.h>
> >
> > Looking at this name the use of it here doesn't sound right...
>
> Because ... ? object_is_on_stack() is defined there.

Because it's defined there. The key word here I see is 'task' in the name of
the header, without Ack from sched folks, I am not convinced we can use that at
any point in the kernel.

...

> > > + for (prop = node->properties; prop && prop->name; prop++) {
> > > + if (!prop->is_inline && object_is_on_stack(prop->pointer)) {
> > > + pr_err("%s: property data can't be on stack\n", __func__);
> > > + return -EINVAL;
> > > + }
> > > + }
> >
> > And again same question, why we can't simply dup them as we do for (string)
> > arrays?
>
> Because majority of users of software_node_register() deal with static
> const properties so duping them is waste of memory.

So, then why can't we do that for the references? Just then copy and free at
software unregistration if required.

--
With Best Regards,
Andy Shevchenko