Skip to content

Commit ddbc7d0

Browse files
committed
y2038: move itimer reset into itimer.c
Preparing for a change to the itimer internals, stop using the do_setitimer() symbol and instead use a new higher-level interface. The do_getitimer()/do_setitimer functions can now be made static, allowing the compiler to potentially produce better object code. Reviewed-by: Thomas Gleixner <[email protected]> Signed-off-by: Arnd Bergmann <[email protected]>
1 parent 4c22ea2 commit ddbc7d0

File tree

3 files changed

+21
-13
lines changed

3 files changed

+21
-13
lines changed

include/linux/time.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,11 @@ extern time64_t mktime64(const unsigned int year, const unsigned int mon,
3535
extern u32 (*arch_gettimeoffset)(void);
3636
#endif
3737

38-
struct itimerval;
39-
extern int do_setitimer(int which, struct itimerval *value,
40-
struct itimerval *ovalue);
41-
extern int do_getitimer(int which, struct itimerval *value);
38+
#ifdef CONFIG_POSIX_TIMERS
39+
extern void clear_itimer(void);
40+
#else
41+
static inline void clear_itimer(void) {}
42+
#endif
4243

4344
extern long do_utimes(int dfd, const char __user *filename, struct timespec64 *times, int flags);
4445

kernel/time/itimer.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ static void get_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
7373
value->it_interval = ns_to_timeval(interval);
7474
}
7575

76-
int do_getitimer(int which, struct itimerval *value)
76+
static int do_getitimer(int which, struct itimerval *value)
7777
{
7878
struct task_struct *tsk = current;
7979

@@ -197,7 +197,7 @@ static void set_cpu_itimer(struct task_struct *tsk, unsigned int clock_id,
197197
#define timeval_valid(t) \
198198
(((t)->tv_sec >= 0) && (((unsigned long) (t)->tv_usec) < USEC_PER_SEC))
199199

200-
int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
200+
static int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
201201
{
202202
struct task_struct *tsk = current;
203203
struct hrtimer *timer;
@@ -249,6 +249,17 @@ int do_setitimer(int which, struct itimerval *value, struct itimerval *ovalue)
249249
return 0;
250250
}
251251

252+
#ifdef CONFIG_SECURITY_SELINUX
253+
void clear_itimer(void)
254+
{
255+
struct itimerval v = {};
256+
int i;
257+
258+
for (i = 0; i < 3; i++)
259+
do_setitimer(i, &v, NULL);
260+
}
261+
#endif
262+
252263
#ifdef __ARCH_WANT_SYS_ALARM
253264

254265
/**

security/selinux/hooks.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2549,9 +2549,8 @@ static void selinux_bprm_committing_creds(struct linux_binprm *bprm)
25492549
static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
25502550
{
25512551
const struct task_security_struct *tsec = selinux_cred(current_cred());
2552-
struct itimerval itimer;
25532552
u32 osid, sid;
2554-
int rc, i;
2553+
int rc;
25552554

25562555
osid = tsec->osid;
25572556
sid = tsec->sid;
@@ -2569,11 +2568,8 @@ static void selinux_bprm_committed_creds(struct linux_binprm *bprm)
25692568
rc = avc_has_perm(&selinux_state,
25702569
osid, sid, SECCLASS_PROCESS, PROCESS__SIGINH, NULL);
25712570
if (rc) {
2572-
if (IS_ENABLED(CONFIG_POSIX_TIMERS)) {
2573-
memset(&itimer, 0, sizeof itimer);
2574-
for (i = 0; i < 3; i++)
2575-
do_setitimer(i, &itimer, NULL);
2576-
}
2571+
clear_itimer();
2572+
25772573
spin_lock_irq(&current->sighand->siglock);
25782574
if (!fatal_signal_pending(current)) {
25792575
flush_sigqueue(&current->pending);

0 commit comments

Comments
 (0)