glocktop: dlmwaiters above 100 fixes
cover glocktop: dlmwaiters above 100 fixes
Hi,
these patches fixes issues for me with glocktop. I got a:
*** buffer overflow detected ***: terminated
Aborted (core dumped)
debugging with gdb figured out that there are some maximum limitation to handle dlm waiters which was in my case 117. This patches increased the maximum allowed dlm waiters. These limitations are still static and should be changed to dynamic allocation in due courses otherwise buffer overflow happens again.
- Alex
Alexander Aring (2):
glocktop: use MAX_LINES for dlmwlines
glocktop: allocate fsdlm dynamically
gfs2/glocktop/glocktop.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.26.2
PATCH 1/2 glocktop: use MAX_LINES for dlmwlines
This patch uses MAX_LINES to handle 100 DLM waiters and above. There is still a limitation but very unlikely to hit.
--- gfs2/glocktop/glocktop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
gfs2/glocktop/glocktop.c +1 -1
@@ -159,7 +159,7 @@ struct mount_point {struct gfs2_sb sb; };struct mount_point *mounts; -char dlmwlines[100 ][96 ];/* waiters lines */ +char dlmwlines[MAX_LINES ][96 ];/* waiters lines */ char dlmglines[MAX_LINES ][97 ];/* granted lines */ char contended_filenames[MAX_FILES ][PATH_MAX ];unsigned long long contended_blocks[MAX_FILES ];
Signature · 1 line
2.26.2
PATCH 2/2 glocktop: allocate fsdlm dynamically
In reply to Alexander AringThis patch allocates the fsdlm string dynamically with respect of dlmwaiters. The fsdlm has at least the dlmwaiters length, the 105 bytes are for some other predicted max length strings.
--- gfs2/glocktop/glocktop.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
gfs2/glocktop/glocktop.c +8 -2
@@ -1605,7 +1605,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters, int dlmgrants, int trace_dir_path, int show_held, int help, int summary) { - char fstitle[96], fsdlm[105]; + char fstitle[96], *fsdlm;char ctimestr[64 ];time_t t;int i;
@@ -1615,7 +1615,12 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters,strftime (ctimestr,64 ,"%a %b %d %T %Y" ,localtime (&t)); ctimestr[63 ] ='\0' ;memset (fstitle,0 ,sizeof (fstitle)); -memset (fsdlm,0 ,sizeof (fsdlm)); + fsdlm =calloc (1 ,105 + dlmwaiters); +if (!fsdlm) { +printf ("Failed to allocate fsdlm\n" ); +exit (-1 ); + } +sprintf (fstitle,"@ %.22s %s " , fsname, ctimestr);if (dlmwaiters) { sprintf(fsdlm, "dlm: %s/%s/%s [", dlm_dirtbl_size,
@@ -1628,6 +1633,7 @@ static void parse_glocks_file(int fd, const char *fsname, int dlmwaiters, }attron (A_BOLD );print_it (NULL ,"%s @%s %s" ,NULL , fstitle, hostname, fsdlm); +free (fsdlm);eol (0 );attroff (A_BOLD ); glock_details(fd, fsname, dlmwaiters, dlmgrants, trace_dir_path,
Signature · 1 line
2.26.2
Andrew Price
Appliedcover glocktop: dlmwaiters above 100 fixes
In reply to Alexander AringQuoted 14 lines · Alexander Aring
Hi,
these patches fixes issues for me with glocktop. I got a:
*** buffer overflow detected ***: terminated
Aborted (core dumped)debugging with gdb figured out that there are some maximum limitation to handle dlm waiters which was in my case 117. This patches increased the maximum allowed dlm waiters. These limitations are still static and should be changed to dynamic allocation in due courses otherwise buffer overflow happens again.
Quoted 9 lines
- Alex
Alexander Aring (2):
glocktop: useMAX_LINESfor dlmwlines
glocktop: allocate fsdlm dynamicallygfs2/glocktop/glocktop.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Applied. Thanks Alex.
Andy