Re: [PATCH] kunit: executor: Simplify string allocation handling

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

 



On Thu, Jul 11, 2024 at 01:39:15PM +0800, David Gow wrote:
> On Wed, 10 Jul 2024 at 08:02, Kees Cook <kees@xxxxxxxxxx> 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




[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux