All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] arm64: perf: Convert snprintf to sysfs_emit
@ 2021-05-20  7:59 ` Tian Tao
  0 siblings, 0 replies; 4+ messages in thread
From: Tian Tao @ 2021-05-20  7:59 UTC (permalink / raw)
  To: will, mark.rutland, catalin.marinas
  Cc: linux-arm-kernel, linux-perf-users, Tian Tao

Use sysfs_emit instead of snprintf to avoid buf overrun,because in
sysfs_emit it strictly checks whether buf is null or buf whether
pagesize aligned, otherwise it returns an error.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 arch/arm64/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index f594957..44b6eda 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
 	struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);
 	u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK;
 
-	return snprintf(page, PAGE_SIZE, "0x%08x\n", slots);
+	return sysfs_emit(page, "0x%08x\n", slots);
 }
 
 static DEVICE_ATTR_RO(slots);
-- 
2.7.4


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

* [PATCH] arm64: perf: Convert snprintf to sysfs_emit
@ 2021-05-20  7:59 ` Tian Tao
  0 siblings, 0 replies; 4+ messages in thread
From: Tian Tao @ 2021-05-20  7:59 UTC (permalink / raw)
  To: will, mark.rutland, catalin.marinas
  Cc: linux-arm-kernel, linux-perf-users, Tian Tao

Use sysfs_emit instead of snprintf to avoid buf overrun,because in
sysfs_emit it strictly checks whether buf is null or buf whether
pagesize aligned, otherwise it returns an error.

Signed-off-by: Tian Tao <tiantao6@hisilicon.com>
---
 arch/arm64/kernel/perf_event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/arm64/kernel/perf_event.c b/arch/arm64/kernel/perf_event.c
index f594957..44b6eda 100644
--- a/arch/arm64/kernel/perf_event.c
+++ b/arch/arm64/kernel/perf_event.c
@@ -312,7 +312,7 @@ static ssize_t slots_show(struct device *dev, struct device_attribute *attr,
 	struct arm_pmu *cpu_pmu = container_of(pmu, struct arm_pmu, pmu);
 	u32 slots = cpu_pmu->reg_pmmir & ARMV8_PMU_SLOTS_MASK;
 
-	return snprintf(page, PAGE_SIZE, "0x%08x\n", slots);
+	return sysfs_emit(page, "0x%08x\n", slots);
 }
 
 static DEVICE_ATTR_RO(slots);
-- 
2.7.4


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH] arm64: perf: Convert snprintf to sysfs_emit
  2021-05-20  7:59 ` Tian Tao
@ 2021-06-01 18:21   ` Will Deacon
  -1 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2021-06-01 18:21 UTC (permalink / raw)
  To: Tian Tao, catalin.marinas, mark.rutland
  Cc: kernel-team, Will Deacon, linux-perf-users, linux-arm-kernel

On Thu, 20 May 2021 15:59:45 +0800, Tian Tao wrote:
> Use sysfs_emit instead of snprintf to avoid buf overrun,because in
> sysfs_emit it strictly checks whether buf is null or buf whether
> pagesize aligned, otherwise it returns an error.

Applied to will (for-next/perf), thanks!

[1/1] arm64: perf: Convert snprintf to sysfs_emit
      https://git.kernel.org/will/c/a5740e955540

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

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

* Re: [PATCH] arm64: perf: Convert snprintf to sysfs_emit
@ 2021-06-01 18:21   ` Will Deacon
  0 siblings, 0 replies; 4+ messages in thread
From: Will Deacon @ 2021-06-01 18:21 UTC (permalink / raw)
  To: Tian Tao, catalin.marinas, mark.rutland
  Cc: kernel-team, Will Deacon, linux-perf-users, linux-arm-kernel

On Thu, 20 May 2021 15:59:45 +0800, Tian Tao wrote:
> Use sysfs_emit instead of snprintf to avoid buf overrun,because in
> sysfs_emit it strictly checks whether buf is null or buf whether
> pagesize aligned, otherwise it returns an error.

Applied to will (for-next/perf), thanks!

[1/1] arm64: perf: Convert snprintf to sysfs_emit
      https://git.kernel.org/will/c/a5740e955540

Cheers,
-- 
Will

https://fixes.arm64.dev
https://next.arm64.dev
https://will.arm64.dev

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2021-06-01 18:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-20  7:59 [PATCH] arm64: perf: Convert snprintf to sysfs_emit Tian Tao
2021-05-20  7:59 ` Tian Tao
2021-06-01 18:21 ` Will Deacon
2021-06-01 18:21   ` Will Deacon

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.