linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Antonio Borneo <antonio.borneo@st.com>
To: Giuseppe Cavallaro <peppe.cavallaro@st.com>,
	Alexandre Torgue <alexandre.torgue@st.com>,
	Jose Abreu <joabreu@synopsys.com>,
	"David S. Miller" <davem@davemloft.net>, <netdev@vger.kernel.org>
Cc: Antonio Borneo <antonio.borneo@st.com>,
	Maxime Coquelin <mcoquelin.stm32@gmail.com>,
	<linux-stm32@st-md-mailman.stormreply.com>,
	<linux-arm-kernel@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>
Subject: [PATCH] net: stmmac: fix length of PTP clock's name string
Date: Mon, 7 Oct 2019 17:43:04 +0200	[thread overview]
Message-ID: <20191007154306.95827-3-antonio.borneo@st.com> (raw)
In-Reply-To: <20191007154306.95827-1-antonio.borneo@st.com>

The field "name" in struct ptp_clock_info has a fixed size of 16
chars and is used as zero terminated string by clock_name_show()
in drivers/ptp/ptp_sysfs.c
The current initialization value requires 17 chars to fit also the
null termination, and this causes overflow to the next bytes in
the struct when the string is read as null terminated:
	hexdump -C /sys/class/ptp/ptp0/clock_name
	00000000  73 74 6d 6d 61 63 5f 70  74 70 5f 63 6c 6f 63 6b  |stmmac_ptp_clock|
	00000010  a0 ac b9 03 0a                                    |.....|
where the extra 4 bytes (excluding the newline) after the string
represent the integer 0x03b9aca0 = 62500000 assigned to the field
"max_adj" that follows "name" in the same struct.

There is no strict requirement for the "name" content and in the
comment in ptp_clock_kernel.h it's reported it should just be 'A
short "friendly name" to identify the clock'.
Replace it with "stmmac ptp".

Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
Fixes: 92ba6888510c ("stmmac: add the support for PTP hw clock driver")
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
index 173493db038c..df638b18b72c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_ptp.c
@@ -164,7 +164,7 @@ static int stmmac_enable(struct ptp_clock_info *ptp,
 /* structure describing a PTP hardware clock */
 static struct ptp_clock_info stmmac_ptp_clock_ops = {
 	.owner = THIS_MODULE,
-	.name = "stmmac_ptp_clock",
+	.name = "stmmac ptp",
 	.max_adj = 62500000,
 	.n_alarm = 0,
 	.n_ext_ts = 0,
-- 
2.23.0


  parent reply	other threads:[~2019-10-07 15:43 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-07 15:43 [PATCH] ptp: fix typo of "mechanism" in Kconfig help text Antonio Borneo
2019-10-07 15:43 ` [PATCH] staging: rtl8723bs: fix typo of "mechanism" in comment Antonio Borneo
2019-10-07 15:43 ` Antonio Borneo [this message]
2019-10-09 23:10   ` [PATCH] net: stmmac: fix length of PTP clock's name string Jakub Kicinski
2019-10-07 15:43 ` [PATCH] net: stmmac: fix disabling flexible PPS output Antonio Borneo
2019-10-09 23:10   ` Jakub Kicinski
2019-10-07 15:43 ` [PATCH] net: stmmac: add flexible PPS to dwmac 4.10a Antonio Borneo
2019-10-09 22:26   ` Jakub Kicinski
2020-11-24 14:15     ` Ahmad Fatoum
2020-11-24 14:23       ` Antonio Borneo
2020-11-24 18:20         ` Jakub Kicinski
2020-11-24 18:27           ` Antonio Borneo
2020-11-24 18:56             ` Jakub Kicinski
2020-11-24 14:27       ` Ahmad Fatoum
2020-11-24 22:37       ` [PATCH] net: stmmac: fix incorrect merge of patch upstream Antonio Borneo
2020-11-25 10:55         ` Ahmad Fatoum
2020-11-25 19:26         ` Jakub Kicinski
2019-10-07 19:04 ` [PATCH] ptp: fix typo of "mechanism" in Kconfig help text David Miller

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=20191007154306.95827-3-antonio.borneo@st.com \
    --to=antonio.borneo@st.com \
    --cc=alexandre.torgue@st.com \
    --cc=davem@davemloft.net \
    --cc=joabreu@synopsys.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-stm32@st-md-mailman.stormreply.com \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=peppe.cavallaro@st.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).