linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* file removal issue in tools/testing/selftests/powerpc/mm/tlbie_test.c
@ 2023-06-15 16:02 Colin King (gmail)
  0 siblings, 0 replies; only message in thread
From: Colin King (gmail) @ 2023-06-15 16:02 UTC (permalink / raw)
  To: Michael Ellerman, Nicholas Piggin, Christophe Leroy, Shuah Khan,
	Nicholas Miehlbradt, Nicholas Miehlbradt, Benjamin Gray
  Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org,
	open list:KERNEL SELFTEST FRAMEWORK

Hi,

Static analysis with cppcheck has found an issue in the following commit:

commit 047e6575aec71d75b765c22111820c4776cd1c43
Author: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
Date:   Tue Sep 24 09:22:53 2019 +0530

     powerpc/mm: Fixup tlbie vs mtpidr/mtlpidr ordering issue on POWER9


The issue in tools/testing/selftests/powerpc/mm/tlbie_test.c in 
end_verification_log() is as follows:

static inline void end_verification_log(unsigned int tid, unsigned 
nr_anamolies)
{
         FILE *f = fp[tid];
         char logfile[30];
         char path[LOGDIR_NAME_SIZE + 30];
         char separator[] = "/";

         fclose(f);

         if (nr_anamolies == 0) {
                 remove(path);
                 return;
         }
	.... etc


in the case where nr_anamolies is zero the remove(path) call is using an 
uninitialized path, this potentially could contain uninitialized garbage 
on the stack (and if one is unlucky enough it may be a valid filename 
that one does not want to be removed).

Not sure what the original intention was, but this code looks incorrect 
to me.

Colin

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2023-06-15 16:03 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-06-15 16:02 file removal issue in tools/testing/selftests/powerpc/mm/tlbie_test.c Colin King (gmail)

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).