Skip to contentSkip to conversation

0001-Fix-a-array-bound-overflow-bug-in-function-umr_clock

PATCH Applied 张二东 2 participants 4 messages Aug 27, 2020 – Aug 28, 2020

lore
Share & tools
lore

张二东

author
#0 lore raw

From ba05bc0f7fa5f8dbc8998384bb713a2a69be58b9 Mon Sep 17 00:00:00 2001
From: Erdong zhang <[email protected]>
Date: Thu, 27 Aug 2020 15:40:13 +0800
Subject: [PATCH] Fix a array bound overflow bug in function
umr_clock_manual

If i input a wrong clock name or a name not exist in asic_clocks when use umr set clock,
the function umr_clock_manual try to access array asic_clocks.clock[i] with index UMR_CLOCK_MAX, final the umr encounter a egmentation fault.

---
 src/app/clock.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
src/app/clock.c +5 -1
index 101da6f..8818918 100644
@@ -117,7 +117,11 @@ void umr_clock_manual(struct umr_asic *asic, const char* clock_name, void* value
 				break;
 			}
 		}
-		print_clock(asic_clocks.clocks[i], asic);
+
+		if(i < UMR_CLOCK_MAX)
+			print_clock(asic_clocks.clocks[i], asic);
+		else
+			printf("[ERROR]: Maybe wrong clock name!\n");
 	} else {
 		printf("[ERROR]: Invalid input!\n");
 	}
Signature · 1 line
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

author
#2 lore raw

Yes, you are right. New patch is in attachment.

thanks.

在 2020-08-28 01:14:02,"Tom St Denis" <[email protected]> 写道:

isn't a better fix to simply delete the line? The print seems redundant to me.

Tom

On Thu, Aug 27, 2020 at 9:27 AM 张二东 <[email protected]> wrote:

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

From e65ac007e4af51a0bff5a9d44f4cef74b315d288 Mon Sep 17 00:00:00 2001
From: Erdong zhang <[email protected]>
Date: Fri, 28 Aug 2020 09:33:12 +0800
Subject: [PATCH] Delete redundant print info to reslove a array bound
overflow issue in umr_clock_manual.

If i input a wrong clock name or a name not exist in asic_clocks when use umr set clock,
the function umr_clock_manual try to access array asic_clocks.clock[i] with index UMR_CLOCK_MAX, final the umr encounter a egmentation fault.

---
 src/app/clock.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/app/clock.c +3 -1
index 101da6f..70b3e0b 100644
@@ -117,7 +117,9 @@ void umr_clock_manual(struct umr_asic *asic, const char* clock_name, void* value
 				break;
 			}
 		}
-		print_clock(asic_clocks.clocks[i], asic);
+
+		if(i == UMR_CLOCK_MAX)
+			printf("[ERROR]: Maybe wrong clock name or not support so far!\n");
 	} else {
 		printf("[ERROR]: Invalid input!\n");
 	}
Signature · 1 line
2.17.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Applied
#3 lore raw

Thanks, applied!

In future patches can you please add a Signed-off line (e.g. use "-s" with git when forming the commit).

Tom

Quoted 9 lines · 张二东

Yes, you are right. New patch is in attachment.

thanks.

Quoted 22 lines

在 2020-08-28 01:14:02,"Tom St Denis" <[email protected]> 写道:

isn't a better fix to simply delete the line? The print seems redundant to me.

Tom

Quoted 9 lines · 张二东

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx