On Thu, Jul 11, 2024 at 01:39:15PM +0800, David Gow wrote:
> On Wed, 10 Jul 2024 at 08:02, Kees Cook <[email protected]> wrote:
> > diff --git a/lib/kunit/executor_test.c b/lib/kunit/executor_test.c
> > index 3f7f967e3688..7191be9c4f9b 100644
> > --- a/lib/kunit/executor_test.c
> > +++ b/lib/kunit/executor_test.c
> > @@ -286,7 +286,7 @@ static struct kunit_suite *alloc_fake_suite(struct 
> > kunit *test,
> >
> >         /* We normally never expect to allocate suites, hence the non-const 
> > cast. */
> >         suite = kunit_kzalloc(test, sizeof(*suite), GFP_KERNEL);
> > -       strncpy((char *)suite->name, suite_name, sizeof(suite->name) - 1);
> > +       strscpy((char *)suite->name, suite_name);
> 
> This is broken: we still need to pass the length of suite->name. The
> (char *) cast, which is necessary to remove the 'cosnt' qualifier,
> stops the strscpy() macro from treating suite->name as an array.

Ah! Thanks for catching that. I do build tests with "allmodconfig", and
I saw the #include for executor_test.c, but didn't notice it was for
_builtin_ only...

-- 
Kees Cook

Reply via email to