From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: Bharadwaj Raju <bharadwaj.raju777@gmail.com>
Cc: linux-rtc@vger.kernel.org, shuah@kernel.org,
linux-kernel@vger.kernel.org,
linux-kernel-mentees@lists.linux.dev
Subject: Re: [PATCH] rtc: fix use of uninit struct in rtc_read_alarm_internal
Date: Tue, 8 Apr 2025 16:44:48 +0200 [thread overview]
Message-ID: <2025040814444859857143@mail.local> (raw)
In-Reply-To: <CAPZ5DTHKSzg6UV0bT5U9Xet7jL1c__n+GgfYz-38GybGzerYNQ@mail.gmail.com>
Hello,
On 29/03/2025 19:59:46+0530, Bharadwaj Raju wrote:
> On Tue, Mar 18, 2025 at 3:21 AM Alexandre Belloni
> <alexandre.belloni@bootlin.com> wrote:
> >
> > On 18/03/2025 00:03:43+0530, Bharadwaj Raju wrote:
> > > The trace call invokes rtc_tm_to_time64 on a
> > > potentially uninitialized alarm->time. Move the
> > > trace call to the path where we do successfully
> > > initialize and read that struct.
> > >
> > > This fixes a KMSAN warning.
> > >
> > > Fixes: 29a1f599c0cc ("rtc: Add tracepoints for RTC system")
> > >
> > > Signed-off-by: Bharadwaj Raju <bharadwaj.raju777@gmail.com>
> > > ---
> > > drivers/rtc/interface.c | 3 ++-
> > > 1 file changed, 2 insertions(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c
> > > index aaf76406cd7d..82ba33bf478b 100644
> > > --- a/drivers/rtc/interface.c
> > > +++ b/drivers/rtc/interface.c
> > > @@ -201,11 +201,12 @@ static int rtc_read_alarm_internal(struct rtc_device *rtc,
> > > alarm->time.tm_yday = -1;
> > > alarm->time.tm_isdst = -1;
> > > err = rtc->ops->read_alarm(rtc->dev.parent, alarm);
> > > + if (!err)
> > > + trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
> > > }
> > >
> > > mutex_unlock(&rtc->ops_lock);
> > >
> > > - trace_rtc_read_alarm(rtc_tm_to_time64(&alarm->time), err);
> >
> > This removes the tracepoint when there is an error, rendering it les
> > useful.
> >
> > Also, as discussed about a year ago, alarm-time being uninitialized is
> > not actually an issue as mktime64 can handle whatever is the input so
> > this will never cause any problem so this isn't really a fix.
> >
> > I suggest the following:
>
> Thanks for reviewing. Would you like me to make a second version of
> the patch with this suggestion?
I've sent my patch now.
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2025-04-08 14:44 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-17 18:33 [PATCH] rtc: fix use of uninit struct in rtc_read_alarm_internal Bharadwaj Raju
2025-03-17 21:51 ` Alexandre Belloni
2025-03-29 14:29 ` Bharadwaj Raju
2025-04-08 14:44 ` Alexandre Belloni [this message]
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=2025040814444859857143@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=bharadwaj.raju777@gmail.com \
--cc=linux-kernel-mentees@lists.linux.dev \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-rtc@vger.kernel.org \
--cc=shuah@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: link
Be 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.