linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aashish Lakhwara <aashish.l@samsung.com>
To: tglx@linutronix.de, linux-kernel@vger.kernel.org
Cc: himanshu.sh@samssung.com, a.sahrawat@samsung.com,
	pankaj.m@samsung.com, Aashish Lakhwara <aashish.l@samsung.com>,
	Himanshu Shukla <himanshu.sh@samsung.com>
Subject: [PATCH] posix-timers: Remove the stack variable clockid_t introduced as part of Protect posix clock array access against speculation
Date: Wed,  1 Aug 2018 11:24:25 +0530	[thread overview]
Message-ID: <20180801055857epcas5p35ac85b8c9c9339eb3080e6d89b1a0ce6~GrS4x1NZj0970809708epcas5p3l@epcas5p3.samsung.com> (raw)
In-Reply-To: CGME20180801055857epcas5p35ac85b8c9c9339eb3080e6d89b1a0ce6@epcas5p3.samsung.com

The "array_index_mask_nospec" code has been updated to allow index
argument to have const-qualified type.
Now the stack variable "idx" is no longer required and can be removed.
We should directly pass the const variable "id" to array_index_mask_nospec

Signed-off-by: Aashish Lakhwara <aashish.l@samsung.com>
Signed-off-by: Himanshu Shukla <himanshu.sh@samsung.com>
---
 kernel/time/posix-timers.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/time/posix-timers.c b/kernel/time/posix-timers.c
index e08ce3f..face369 100644
--- a/kernel/time/posix-timers.c
+++ b/kernel/time/posix-timers.c
@@ -1357,8 +1357,6 @@ static int common_nsleep(const clockid_t which_clock, int flags,
 
 static const struct k_clock *clockid_to_kclock(const clockid_t id)
 {
-	clockid_t idx = id;
-
 	if (id < 0) {
 		return (id & CLOCKFD_MASK) == CLOCKFD ?
 			&clock_posix_dynamic : &clock_posix_cpu;
@@ -1367,5 +1365,5 @@ static const struct k_clock *clockid_to_kclock(const clockid_t id)
 	if (id >= ARRAY_SIZE(posix_clocks))
 		return NULL;
 
-	return posix_clocks[array_index_nospec(idx, ARRAY_SIZE(posix_clocks))];
+	return posix_clocks[array_index_nospec(id, ARRAY_SIZE(posix_clocks))];
 }
-- 
1.9.1


       reply	other threads:[~2018-08-01  6:01 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20180801055857epcas5p35ac85b8c9c9339eb3080e6d89b1a0ce6@epcas5p3.samsung.com>
2018-08-01  5:54 ` Aashish Lakhwara [this message]
2018-08-01 19:50   ` [PATCH] posix-timers: Remove the stack variable clockid_t introduced as part of Protect posix clock array access against speculation Thomas Gleixner

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='20180801055857epcas5p35ac85b8c9c9339eb3080e6d89b1a0ce6~GrS4x1NZj0970809708epcas5p3l@epcas5p3.samsung.com' \
    --to=aashish.l@samsung.com \
    --cc=a.sahrawat@samsung.com \
    --cc=himanshu.sh@samssung.com \
    --cc=himanshu.sh@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pankaj.m@samsung.com \
    --cc=tglx@linutronix.de \
    /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).