Received: by 2002:a25:31c3:0:0:0:0:0 with SMTP id x186csp3916631ybx; Sat, 9 Nov 2019 05:46:32 -0800 (PST) X-Google-Smtp-Source: APXvYqwmmz/PGXXQZKqtzZv5QHeiCEiUsvJsXV9tKernnrviA105Kc5DLA85R/2sAE7RjYoowiut X-Received: by 2002:a17:906:245b:: with SMTP id a27mr14160572ejb.192.1573307192639; Sat, 09 Nov 2019 05:46:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573307192; cv=none; d=google.com; s=arc-20160816; b=zr8TRMkz8Prz0qyBao+UQlnOhdiNBYhtHgQjlSw/b0UbZXXbi6eeieDX+CkiI58aUy l3yVwUID8hP5WEN1zMf2xDAEpQchvb7Sg9w7f2fp3CEqCOH45akjWnCsTU19IOkADJsC Dw6lMMmb7Z/TuI32cvgSsZ8OUam/wipkroB8QWD+rofsTWeoTk+MQCM++lkzQVxTYtzU +boGyo+WXNuyVypHtB5li39K7MX8Mava1zYCY9Ee3BYFQhSQswGttTwmSbbVKbe+1LwF WyiePsX6lz2PPxv+0FvlI3ihdBI+4TI9HSBH6kzWg8osZ30IG8yEytYl1reGx2R6Bs64 /UaQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=Up5s8EpS5D7kkDC57nzXWxivAHhovvLoHXVf8DG9Twg=; b=ZsrbjOXMm5X4M9ThhF59y305L4ZKRcwT1T1h/7tzdnZJToIyntn7FOMKYRUxa7rzFo euSbs4Wvil9cn+2blqpPpl18Rp4rMIeoEz+5FjYh1jPbqTDlEy86lOjrtgW+1ALffceT 0MdkYST1FtfYizscVvgUfo4O1PJNhedYgH8L0I/prfhCe7RWu/EUfX9BcIJC50CbGZDD xnNubHczXwxwyufagnyHwl2MOQsBFmOYCddxgdKa+sehAavqiC/EmNX1iAqJZj6VFIWC v7WxaNQwvCLefaRZSbl8PkI57fXxv6BbueAXq1njkL6wPfNPLOHvyjUkfv3h/NoYtgis Q4Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AGwkpKy1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id g23si5627332ejk.186.2019.11.09.05.46.09; Sat, 09 Nov 2019 05:46:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=AGwkpKy1; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726559AbfKINnW (ORCPT + 99 others); Sat, 9 Nov 2019 08:43:22 -0500 Received: from us-smtp-delivery-1.mimecast.com ([207.211.31.120]:41234 "EHLO us-smtp-1.mimecast.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726515AbfKINnV (ORCPT ); Sat, 9 Nov 2019 08:43:21 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1573307000; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Up5s8EpS5D7kkDC57nzXWxivAHhovvLoHXVf8DG9Twg=; b=AGwkpKy10cWBahJwoKjimnQ03tjfmgC8Q09mcJ9gXz9dZ0rraqjtHLuTbMyUdI+6edl9TP mtgf1mWF/uTGlEI9mc+B6xwW2wczoTs6phpRs0NGMYCXt3wilVOgQVkBZP2+UKWL2CkCCU TDUfgqgUCQ4u+9yUoX+NCWwQmgTAzyQ= Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-97-dZppz_hZOXeIycl2SWQtyw-1; Sat, 09 Nov 2019 08:43:18 -0500 Received: by mail-ot1-f72.google.com with SMTP id y65so7256470ota.18 for ; Sat, 09 Nov 2019 05:43:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=mEmiWvgrHzBy2uEipunGX3PtOc+nxMNrW4xVu/URLUE=; b=BHlMxjdWQuNX5wYxrQkhZtGux/ZPWkiQ3/aTy0VmmiZZmFGR4N2XO88yBCsMj1uFIj AurWXrSwG1W1+rQnbvKbBK3ORl5hsyQG8LivKqvCN8H/4C8BQiHUn6kbVuZ+jKENBHFp +h7mAB0VAeyqJ/ZyjcJCuFke/t5zDpi5QNpSLZJXw02llgKKSZkl9kUwA2puqbG9sWwr kxKP6tBy4Dbhmuxk/GJ2UoqZ4eSB+w9PJh2FEXka0BZWR5VQPPEKOHVzsoT2oMg0He8D W6prnnGIUtWFOQFylaDDWlIMBiFKqJ7Rs8ZzvQeV9u3KlOgk9NYCz57wJgutqm6eaHaH KETw== X-Gm-Message-State: APjAAAUIR49MBy4xFG0AdBDokEnEqa1aLoQlwmSQFK6zG/GqBsQCXO3l yxxePwb6AieSbhLNHtt9fzumwQ0uARA1p6hMvVfptTAjpYxIaSLDXMzvt27yk/VaVvpNv4/e0Jl zhzQIvCvchhpg50plrXD9/LyC7P9AhBXnPuwllNyr X-Received: by 2002:aca:7595:: with SMTP id q143mr15605498oic.103.1573306997654; Sat, 09 Nov 2019 05:43:17 -0800 (PST) X-Received: by 2002:aca:7595:: with SMTP id q143mr15605470oic.103.1573306997218; Sat, 09 Nov 2019 05:43:17 -0800 (PST) MIME-Version: 1.0 References: <20191108210236.1296047-1-arnd@arndb.de> <20191108211323.1806194-11-arnd@arndb.de> In-Reply-To: <20191108211323.1806194-11-arnd@arndb.de> From: Ondrej Mosnacek Date: Sat, 9 Nov 2019 14:43:06 +0100 Message-ID: Subject: Re: [PATCH 20/23] y2038: move itimer reset into itimer.c To: Arnd Bergmann Cc: y2038@lists.linaro.org, John Stultz , Thomas Gleixner , Paul Moore , Stephen Smalley , Eric Paris , Linux kernel mailing list , Stephen Boyd , Sebastian Andrzej Siewior , Ingo Molnar , Anna-Maria Gleixner , Al Viro , SElinux list X-MC-Unique: dZppz_hZOXeIycl2SWQtyw-1 X-Mimecast-Spam-Score: 0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 8, 2019 at 10:18 PM Arnd Bergmann wrote: > 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. > > Signed-off-by: Arnd Bergmann > --- > include/linux/time.h | 9 +++++---- > kernel/time/itimer.c | 15 +++++++++++++-- > security/selinux/hooks.c | 10 +++------- > 3 files changed, 21 insertions(+), 13 deletions(-) > > diff --git a/include/linux/time.h b/include/linux/time.h > index 27d83fd2ae61..0760a4f5a15c 100644 > --- a/include/linux/time.h > +++ b/include/linux/time.h > @@ -35,10 +35,11 @@ extern time64_t mktime64(const unsigned int year, con= st unsigned int mon, > extern u32 (*arch_gettimeoffset)(void); > #endif > > -struct itimerval; > -extern int do_setitimer(int which, struct itimerval *value, > - struct itimerval *ovalue); > -extern int do_getitimer(int which, struct itimerval *value); > +#ifdef CONFIG_POSIX_TIMERS > +extern void clear_itimer(void); > +#else > +static inline void clear_itimer(void) {} > +#endif > > extern long do_utimes(int dfd, const char __user *filename, struct times= pec64 *times, int flags); > > diff --git a/kernel/time/itimer.c b/kernel/time/itimer.c > index 4664c6addf69..ce9cd19ce72e 100644 > --- a/kernel/time/itimer.c > +++ b/kernel/time/itimer.c > @@ -73,7 +73,7 @@ static void get_cpu_itimer(struct task_struct *tsk, uns= igned int clock_id, > value->it_interval =3D ns_to_timeval(interval); > } > > -int do_getitimer(int which, struct itimerval *value) > +static int do_getitimer(int which, struct itimerval *value) > { > struct task_struct *tsk =3D current; > > @@ -197,7 +197,7 @@ static void set_cpu_itimer(struct task_struct *tsk, u= nsigned int clock_id, > #define timeval_valid(t) \ > (((t)->tv_sec >=3D 0) && (((unsigned long) (t)->tv_usec) < USEC_P= ER_SEC)) > > -int do_setitimer(int which, struct itimerval *value, struct itimerval *o= value) > +static int do_setitimer(int which, struct itimerval *value, struct itime= rval *ovalue) > { > struct task_struct *tsk =3D current; > struct hrtimer *timer; > @@ -249,6 +249,17 @@ int do_setitimer(int which, struct itimerval *value,= struct itimerval *ovalue) > return 0; > } > > +#ifdef CONFIG_SECURITY_SELINUX Did you mean "#ifdef CONFIG_POSIX_TIMERS" here to match the header? > +void clear_itimer(void) > +{ > + struct itimerval v =3D {}; > + int i; > + > + for (i =3D 0; i < 3; i++) > + do_setitimer(i, &v, NULL); > +} > +#endif > + > #ifdef __ARCH_WANT_SYS_ALARM > > /** > diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c > index 9625b99e677f..c3f2e89acb87 100644 > --- a/security/selinux/hooks.c > +++ b/security/selinux/hooks.c > @@ -2549,9 +2549,8 @@ static void selinux_bprm_committing_creds(struct li= nux_binprm *bprm) > static void selinux_bprm_committed_creds(struct linux_binprm *bprm) > { > const struct task_security_struct *tsec =3D selinux_cred(current_= cred()); > - struct itimerval itimer; > u32 osid, sid; > - int rc, i; > + int rc; > > osid =3D tsec->osid; > sid =3D tsec->sid; > @@ -2569,11 +2568,8 @@ static void selinux_bprm_committed_creds(struct li= nux_binprm *bprm) > rc =3D avc_has_perm(&selinux_state, > osid, sid, SECCLASS_PROCESS, PROCESS__SIGINH, N= ULL); > if (rc) { > - if (IS_ENABLED(CONFIG_POSIX_TIMERS)) { > - memset(&itimer, 0, sizeof itimer); > - for (i =3D 0; i < 3; i++) > - do_setitimer(i, &itimer, NULL); > - } > + if (IS_ENABLED(CONFIG_POSIX_TIMERS)) > + clear_itimer(); Since you already define a no-op fallback for the case of !IS_ENABLED(CONFIG_POSIX_TIMERS) in time.h, why not simply call clear_itimer() unconditionally? > spin_lock_irq(¤t->sighand->siglock); > if (!fatal_signal_pending(current)) { > flush_sigqueue(¤t->pending); > -- > 2.20.0 > --=20 Ondrej Mosnacek Software Engineer, Security Technologies Red Hat, Inc.