All of lore.kernel.org
 help / color / mirror / Atom feed
From: Guenter Roeck <linux@roeck-us.net>
To: "Chatradhi, Naveen Krishna" <NaveenKrishna.Chatradhi@amd.com>
Cc: Salvatore Bonaccorso <carnil@debian.org>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"naveenkrishna.ch@gmail.com" <naveenkrishna.ch@gmail.com>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: Re: [PATCH] hwmon: amd_energy: modify the visibility of the counters
Date: Sun, 22 Nov 2020 10:09:50 -0800	[thread overview]
Message-ID: <20201122180950.GA69147@roeck-us.net> (raw)
In-Reply-To: <DM6PR12MB438839666CD2BA3524D80E24E8FD0@DM6PR12MB4388.namprd12.prod.outlook.com>

On Sun, Nov 22, 2020 at 04:42:47PM +0000, Chatradhi, Naveen Krishna wrote:
> [AMD Official Use Only - Approved for External Use]
> 
> Hi Guenter,
> 
> > A much better fix would have been to cache RAPL data for a short period of time. To avoid any possibility of attacks, maybe add some random interval. Something like this:
> Thanks for the tip, I will check this out.
> 
> > In accumulate_delta():
> >        accums->next_update = jiffies + HZ / 2 + get_random_int % HZ;

[ and this was supposed to be get_random_int() ]

> 
> > In amd_energy_read():
> >        accum = &data->accums[channel];
> >        if (time_after(accum->next_update))
> Do you mean if (time_after(jiffies, accum->next_update))

yes ...

Guenter

> 
> >                accumulate_delta(data, channel, cpu, reg);
> >        *val = div64_ul(accum->energy_ctr * 1000000UL, BIT(data->energy_units));
> 
> > and drop amd_add_delta().
> 
> Regards,
> Naveenk
> 
> -----Original Message-----
> From: Guenter Roeck <linux@roeck-us.net> 
> Sent: Sunday, November 22, 2020 7:00 PM
> To: Chatradhi, Naveen Krishna <NaveenKrishna.Chatradhi@amd.com>
> Cc: Salvatore Bonaccorso <carnil@debian.org>; linux-hwmon@vger.kernel.org; naveenkrishna.ch@gmail.com; stable@vger.kernel.org
> Subject: Re: [PATCH] hwmon: amd_energy: modify the visibility of the counters
> 
> [CAUTION: External Email]
> 
> On Sun, Nov 22, 2020 at 06:56:24AM +0000, Chatradhi, Naveen Krishna wrote:
> > [AMD Official Use Only - Approved for External Use]
> >
> > Hi Guenter, Salvatore
> >
> > > This is very unusual, and may mess up the "sensors" command.
> > > What problem is this trying to solve ?
> > Guenter, sorry for the delayed response.
> > This fix is required to address the possible side channel attack reported in CVE-2020-12912.
> >
> [ ... ]
> >
> > >> ?
> > Yes, Salvatore, thanks for bringing the links.
> >
> A much better fix would have been to cache RAPL data for a short period of time. To avoid any possibility of attacks, maybe add some random interval. Something like this:
> 
> In accumulate_delta():
>         accums->next_update = jiffies + HZ / 2 + get_random_int % HZ;
> 
> In amd_energy_read():
>         accum = &data->accums[channel];
>         if (time_after(accum->next_update))
>                 accumulate_delta(data, channel, cpu, reg);
>         *val = div64_ul(accum->energy_ctr * 1000000UL, BIT(data->energy_units));
> 
> and drop amd_add_delta().
> 
> Guenter

  reply	other threads:[~2020-11-22 18:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-12 17:21 [PATCH] hwmon: amd_energy: modify the visibility of the counters Naveen Krishna Chatradhi
2020-11-12 17:24 ` Guenter Roeck
2020-11-13 13:58   ` Salvatore Bonaccorso
2020-11-13 14:47     ` Guenter Roeck
2020-11-22  6:56     ` Chatradhi, Naveen Krishna
2020-11-22 13:30       ` Guenter Roeck
2020-11-22 16:42         ` Chatradhi, Naveen Krishna
2020-11-22 18:09           ` Guenter Roeck [this message]
  -- strict thread matches above, loose matches on Subject: below --
2020-11-09  9:07 Naveen Krishna Chatradhi

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=20201122180950.GA69147@roeck-us.net \
    --to=linux@roeck-us.net \
    --cc=NaveenKrishna.Chatradhi@amd.com \
    --cc=carnil@debian.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=naveenkrishna.ch@gmail.com \
    --cc=stable@vger.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.