From: Jacob Keller <jacob.e.keller@intel.com>
To: Meghana Malladi <m-malladi@ti.com>, <dan.carpenter@linaro.org>,
<javier.carrasco.cruz@gmail.com>, <diogo.ivo@siemens.com>,
<horms@kernel.org>, <john.fastabend@gmail.com>, <hawk@kernel.org>,
<daniel@iogearbox.net>, <ast@kernel.org>,
<richardcochran@gmail.com>, <pabeni@redhat.com>,
<kuba@kernel.org>, <edumazet@google.com>, <davem@davemloft.net>,
<andrew+netdev@lunn.ch>
Cc: <bpf@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<netdev@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>,
<srk@ti.com>, Vignesh Raghavendra <vigneshr@ti.com>,
Roger Quadros <rogerq@kernel.org>, <danishanwar@ti.com>
Subject: Re: [PATCH net v4 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request
Date: Tue, 15 Apr 2025 10:45:09 -0700 [thread overview]
Message-ID: <0750ffc8-8185-4b72-980a-3e96c7075100@intel.com> (raw)
In-Reply-To: <20250415090543.717991-4-m-malladi@ti.com>
On 4/15/2025 2:05 AM, Meghana Malladi wrote:
> The ICSS IEP driver tracks perout and pps enable state with flags.
> Currently when disabling pps and perout signals during icss_iep_exit(),
> results in NULL pointer dereference for perout.
>
> To fix the null pointer dereference issue, the icss_iep_perout_enable_hw
> function can be modified to directly clear the IEP CMP registers when
> disabling PPS or PEROUT, without referencing the ptp_perout_request
> structure, as its contents are irrelevant in this case.
>
> Fixes: 9b115361248d ("net: ti: icssg-prueth: Fix clearing of IEP_CMP_CFG registers during iep_init")
> Reported-by: Dan Carpenter <dan.carpenter@linaro.org>
> Closes: https://lore.kernel.org/all/7b1c7c36-363a-4085-b26c-4f210bee1df6@stanley.mountain/
> Signed-off-by: Meghana Malladi <m-malladi@ti.com>
> ---
>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
> Changes from v3 (v4-v3):
> - Fix the logic in icss_iep_perout_enable_hw() to clear IEP registers
> when disabling periodic signal
>
> drivers/net/ethernet/ti/icssg/icss_iep.c | 121 +++++++++++------------
> 1 file changed, 58 insertions(+), 63 deletions(-)
>
> diff --git a/drivers/net/ethernet/ti/icssg/icss_iep.c b/drivers/net/ethernet/ti/icssg/icss_iep.c
> index b4a34c57b7b4..2a1c43316f46 100644
> --- a/drivers/net/ethernet/ti/icssg/icss_iep.c
> +++ b/drivers/net/ethernet/ti/icssg/icss_iep.c
> @@ -430,64 +446,39 @@ static int icss_iep_perout_enable_hw(struct icss_iep *iep,
> if (ret)
> return ret;
>
> - if (on) {
> - /* Configure CMP */
> - regmap_write(iep->map, ICSS_IEP_CMP1_REG0, lower_32_bits(cmp));
> - if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
> - regmap_write(iep->map, ICSS_IEP_CMP1_REG1, upper_32_bits(cmp));
> - /* Configure SYNC, based on req on width */
> - regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
> - div_u64(ns_width, iep->def_inc));
> - regmap_write(iep->map, ICSS_IEP_SYNC0_PERIOD_REG, 0);
> - regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
> - div_u64(ns_start, iep->def_inc));
> - regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0); /* one-shot mode */
> - /* Enable CMP 1 */
> - regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
> - IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
> - } else {
> - /* Disable CMP 1 */
> - regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
> - IEP_CMP_CFG_CMP_EN(1), 0);
> -
> - /* clear regs */
> - regmap_write(iep->map, ICSS_IEP_CMP1_REG0, 0);
> - if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
> - regmap_write(iep->map, ICSS_IEP_CMP1_REG1, 0);
> - }
> + /* Configure CMP */
> + regmap_write(iep->map, ICSS_IEP_CMP1_REG0, lower_32_bits(cmp));
> + if (iep->plat_data->flags & ICSS_IEP_64BIT_COUNTER_SUPPORT)
> + regmap_write(iep->map, ICSS_IEP_CMP1_REG1, upper_32_bits(cmp));
> + /* Configure SYNC, based on req on width */
> + regmap_write(iep->map, ICSS_IEP_SYNC_PWIDTH_REG,
> + div_u64(ns_width, iep->def_inc));
> + regmap_write(iep->map, ICSS_IEP_SYNC0_PERIOD_REG, 0);
> + regmap_write(iep->map, ICSS_IEP_SYNC_START_REG,
> + div_u64(ns_start, iep->def_inc));
> + regmap_write(iep->map, ICSS_IEP_SYNC_CTRL_REG, 0); /* one-shot mode */
> + /* Enable CMP 1 */
> + regmap_update_bits(iep->map, ICSS_IEP_CMP_CFG_REG,
> + IEP_CMP_CFG_CMP_EN(1), IEP_CMP_CFG_CMP_EN(1));
Nice to see this also has a marked improvement with removing a level of
indentation.
> @@ -498,11 +489,21 @@ static int icss_iep_perout_enable(struct icss_iep *iep,
> {
> int ret = 0;
>
> + if (!on)
> + goto disable;
> +
> /* Reject requests with unsupported flags */
> if (req->flags & ~(PTP_PEROUT_DUTY_CYCLE |
> PTP_PEROUT_PHASE))
> return -EOPNOTSUPP;
>
This likely causes a textual conflict with my .supported_perout_flags
patch. It looks like it wouldn't be too difficult to resolve though.
> + /* Set default "on" time (1ms) for the signal if not passed by the app */
> + if (!(req->flags & PTP_PEROUT_DUTY_CYCLE)) {
> + req->on.sec = 0;
> + req->on.nsec = NSEC_PER_MSEC;
> + }
> +
Regards,
Jake
next prev parent reply other threads:[~2025-04-15 17:45 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-04-15 9:05 [PATCH net v4 0/3] Bug fixes from XDP and perout series Meghana Malladi
2025-04-15 9:05 ` [PATCH net v4 1/3] net: ti: icssg-prueth: Fix kernel warning while bringing down network interface Meghana Malladi
2025-04-15 17:41 ` Jacob Keller
2025-04-15 9:05 ` [PATCH net v4 2/3] net: ti: icssg-prueth: Fix possible NULL pointer dereference inside emac_xmit_xdp_frame() Meghana Malladi
2025-04-15 17:42 ` Jacob Keller
2025-04-15 9:05 ` [PATCH net v4 3/3] net: ti: icss-iep: Fix possible NULL pointer dereference for perout request Meghana Malladi
2025-04-15 17:45 ` Jacob Keller [this message]
2025-04-17 10:30 ` [PATCH net v4 0/3] Bug fixes from XDP and perout series patchwork-bot+netdevbpf
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=0750ffc8-8185-4b72-980a-3e96c7075100@intel.com \
--to=jacob.e.keller@intel.com \
--cc=andrew+netdev@lunn.ch \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=dan.carpenter@linaro.org \
--cc=daniel@iogearbox.net \
--cc=danishanwar@ti.com \
--cc=davem@davemloft.net \
--cc=diogo.ivo@siemens.com \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=horms@kernel.org \
--cc=javier.carrasco.cruz@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m-malladi@ti.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@gmail.com \
--cc=rogerq@kernel.org \
--cc=srk@ti.com \
--cc=vigneshr@ti.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
all inboxes | Powered by JetHome®