All of lore.kernel.org
 help / color / mirror / Atom feed
* [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes
@ 2021-03-11 19:20 Alexander Aring
  2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines Alexander Aring
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Alexander Aring @ 2021-03-11 19:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

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(-)

-- 
2.26.2



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines
  2021-03-11 19:20 [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Alexander Aring
@ 2021-03-11 19:20 ` Alexander Aring
  2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 2/2] glocktop: allocate fsdlm dynamically Alexander Aring
  2021-03-13 15:09 ` [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Andrew Price
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2021-03-11 19:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This patch uses MAX_LINES to handle 100 DLM waiters and above. There is
still a limitation but very unlikely to hit.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 gfs2/glocktop/glocktop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index bd7fcf02..9df87d18 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -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];
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cluster-devel] [PATCH gfs2-utils 2/2] glocktop: allocate fsdlm dynamically
  2021-03-11 19:20 [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Alexander Aring
  2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines Alexander Aring
@ 2021-03-11 19:20 ` Alexander Aring
  2021-03-13 15:09 ` [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Andrew Price
  2 siblings, 0 replies; 4+ messages in thread
From: Alexander Aring @ 2021-03-11 19:20 UTC (permalink / raw)
  To: cluster-devel.redhat.com

This 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.

Signed-off-by: Alexander Aring <aahringo@redhat.com>
---
 gfs2/glocktop/glocktop.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/gfs2/glocktop/glocktop.c b/gfs2/glocktop/glocktop.c
index 9df87d18..0096a2a5 100644
--- a/gfs2/glocktop/glocktop.c
+++ b/gfs2/glocktop/glocktop.c
@@ -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,
-- 
2.26.2



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes
  2021-03-11 19:20 [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Alexander Aring
  2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines Alexander Aring
  2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 2/2] glocktop: allocate fsdlm dynamically Alexander Aring
@ 2021-03-13 15:09 ` Andrew Price
  2 siblings, 0 replies; 4+ messages in thread
From: Andrew Price @ 2021-03-13 15:09 UTC (permalink / raw)
  To: cluster-devel.redhat.com

On 11/03/2021 19:20, Alexander Aring wrote:
> 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(-)
> 

Applied. Thanks Alex.

Andy



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-13 15:09 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-11 19:20 [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Alexander Aring
2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 1/2] glocktop: use MAX_LINES for dlmwlines Alexander Aring
2021-03-11 19:20 ` [Cluster-devel] [PATCH gfs2-utils 2/2] glocktop: allocate fsdlm dynamically Alexander Aring
2021-03-13 15:09 ` [Cluster-devel] [PATCH gfs2-utils 0/2] glocktop: dlmwaiters above 100 fixes Andrew Price

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.