lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:   Mon, 14 May 2018 11:23:04 -0700
From:   Deepa Dinamani <deepa.kernel@...il.com>
To:     Kees Cook <keescook@...omium.org>
Cc:     Al Viro <viro@...iv.linux.org.uk>,
        Thomas Gleixner <tglx@...utronix.de>,
        Arnd Bergmann <arnd@...db.de>,
        LKML <linux-kernel@...r.kernel.org>,
        "linux-fsdevel@...r.kernel.org" <linux-fsdevel@...r.kernel.org>,
        y2038 Mailman List <y2038@...ts.linaro.org>,
        anton@...era.com, Felipe Balbi <balbi@...nel.org>,
        "J. Bruce Fields" <bfields@...ldses.org>,
        "Darrick J. Wong" <darrick.wong@...cle.com>,
        David Howells <dhowells@...hat.com>,
        David Sterba <dsterba@...e.com>,
        David Woodhouse <dwmw2@...radead.org>,
        Christoph Hellwig <hch@....de>,
        OGAWA Hirofumi <hirofumi@...l.parknet.co.jp>,
        Mike Marshall <hubcap@...ibond.com>, Jan Kara <jack@...e.com>,
        Jaegeuk Kim <jaegeuk@...nel.org>,
        Jan Harkes <jaharkes@...cmu.edu>, Jiri Slaby <jslaby@...e.com>,
        Mark Fasheh <mark@...heh.com>,
        Miklos Szeredi <miklos@...redi.hu>,
        Nicolas Pitre <nico@...aro.org>,
        reiserfs-devel@...r.kernel.org,
        Richard Weinberger <richard@....at>,
        Sage Weil <sage@...hat.com>, Steve French <sfrench@...ba.org>,
        Steven Whitehouse <swhiteho@...hat.com>,
        Tejun Heo <tj@...nel.org>,
        Trond Myklebust <trond.myklebust@...marydata.com>,
        "Ted Ts'o" <tytso@....edu>
Subject: Re: [PATCH 6/6] vfs: change inode times to use struct timespec64

On Mon, May 14, 2018 at 10:53 AM, Kees Cook <keescook@...omium.org> wrote:
> On Mon, May 14, 2018 at 10:25 AM, Deepa Dinamani <deepa.kernel@...il.com> wrote:
>> On Mon, May 14, 2018 at 9:30 AM, Kees Cook <keescook@...omium.org> wrote:
>>> On Sun, May 13, 2018 at 9:05 PM, Deepa Dinamani <deepa.kernel@...il.com> wrote:
>>>> Kees mentioned that he wants to merge a patch to pstore that changes
>>>> it to use timespec64 internally for 4.17:
>>>> https://lkml.org/lkml/2018/5/13/3
>>>
>>> I'm still working on a v2 for pstore. What is the correct
>>> cross-architecture format string for timespec64's tv_sec? In your
>>> other patches, you're using %lld and a (long long) cast. I'd really
>>> like to avoid the need for casts.
>>
>> We cannot really avoid it for now.
>> struct timespec64 is defined this way for now:
>>
>> struct timespec {
>> __kernel_time_t tv_sec; /* seconds */
>> long tv_nsec; /* nanoseconds */
>> };
>>
>> #if __BITS_PER_LONG == 64
>> /* this trick allows us to optimize out timespec64_to_timespec */
>> # define timespec64 timespec
>>
>> #else
>>
>> struct timespec64 {
>> time64_t tv_sec; /* seconds */
>> long tv_nsec; /* nanoseconds */
>> };
>>
>> #endif
>>
>> This will all lead to tv_sec being long on a 64 bit architecture and
>> long long on a 32 bit architecture.
>> So there is no way of avoiding the cast for now.
>>
>> We plan to get rid of this trick and to have a single definition for
>> timespec64. But, that cleanup is planned for later when we cleanup all
>> struct timespec uses internally.
>
> Can we do something like:
>
> #if __BITS_PER_LONG == 64
> # define TVSEC_FMT "%ld"
> #else
> # define TVSEC_FMT "%lld"
> #endif
>
> so we can do stuff like:  sprintf(buf, "seconds: " KTIME_FMT, time->tv_sec)
>
> ? It seems easier to clean up than casts.

We have already introduced these casts in many places now.
It would be easier to do the clean up if they all follow a similar
pattern. ( I could probably write a coccinelle script that is not very
long).
But, it would be not much trouble if you wanted to follow this for pstore.

We also contemplated adding a format specifier for time. But, I think
we deferred it until we have a uniform way of using time internally.

-Deepa

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ