Skip to content

Commit db2c549

Browse files
disconnect3dacmel
authored andcommitted
perf map: Fix off by one in strncpy() size argument
This patch fixes an off-by-one error in strncpy size argument in tools/perf/util/map.c. The issue is that in: strncmp(filename, "/system/lib/", 11) the passed string literal: "/system/lib/" has 12 bytes (without the NULL byte) and the passed size argument is 11. As a result, the logic won't match the ending "/" byte and will pass filepaths that are stored in other directories e.g. "/system/libmalicious/bin" or just "/system/libmalicious". This functionality seems to be present only on Android. I assume the /system/ directory is only writable by the root user, so I don't think this bug has much (or any) security impact. Fixes: eca8183 ("perf tools: Add automatic remapping of Android libraries") Signed-off-by: disconnect3d <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Changbin Du <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Keeping <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Michael Lentine <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Song Liu <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent be40920 commit db2c549

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

tools/perf/util/map.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ static inline bool replace_android_lib(const char *filename, char *newfilename)
8989
return true;
9090
}
9191

92-
if (!strncmp(filename, "/system/lib/", 11)) {
92+
if (!strncmp(filename, "/system/lib/", 12)) {
9393
char *ndk, *app;
9494
const char *arch;
9595
size_t ndk_length;

0 commit comments

Comments
 (0)