From: Tian Tao <tiantao6@hisilicon.com> To: <will@kernel.org>, <mark.rutland@arm.com>, <catalin.marinas@arm.com> Cc: <linux-arm-kernel@lists.infradead.org>, <linux-perf-users@vger.kernel.org>, Tian Tao <tiantao6@hisilicon.com> Subject: [PATCH] arm64: perf: Convert snprintf to sysfs_emit Date: Thu, 20 May 2021 15:59:45 +0800 [thread overview] Message-ID: <1621497585-30887-1-git-send-email-tiantao6@hisilicon.com> (raw) 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
WARNING: multiple messages have this Message-ID (diff)
From: Tian Tao <tiantao6@hisilicon.com> To: <will@kernel.org>, <mark.rutland@arm.com>, <catalin.marinas@arm.com> Cc: <linux-arm-kernel@lists.infradead.org>, <linux-perf-users@vger.kernel.org>, Tian Tao <tiantao6@hisilicon.com> Subject: [PATCH] arm64: perf: Convert snprintf to sysfs_emit Date: Thu, 20 May 2021 15:59:45 +0800 [thread overview] Message-ID: <1621497585-30887-1-git-send-email-tiantao6@hisilicon.com> (raw) 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
next reply other threads:[~2021-05-20 7:59 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-05-20 7:59 Tian Tao [this message] 2021-05-20 7:59 ` [PATCH] arm64: perf: Convert snprintf to sysfs_emit Tian Tao 2021-06-01 18:21 ` Will Deacon 2021-06-01 18:21 ` Will Deacon
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=1621497585-30887-1-git-send-email-tiantao6@hisilicon.com \ --to=tiantao6@hisilicon.com \ --cc=catalin.marinas@arm.com \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-perf-users@vger.kernel.org \ --cc=mark.rutland@arm.com \ --cc=will@kernel.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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.