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] [day] [month] [year] [list]
Message-ID: <CAFQAk7ja-d-QvccAYHWAUR=P3Jf9Sh33wn=MSTfao-BE9q9Qjw@mail.gmail.com>
Date:   Sat, 26 Nov 2022 11:28:37 +0800
From:   Jiachen Zhang <zhangjiachen.jaycee@...edance.com>
To:     Andrew Morton <akpm@...ux-foundation.org>
Cc:     "Matthew Wilcox (Oracle)" <willy@...radead.org>,
        linux-fsdevel@...r.kernel.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org, xieyongji@...edance.com
Subject: Re: [External] Re: [PATCH] filemap: Fix some misleading comments

On Sat, Nov 26, 2022 at 8:52 AM Andrew Morton <akpm@...ux-foundation.org> wrote:
>
> On Fri, 25 Nov 2022 15:09:59 +0800 Jiachen Zhang <zhangjiachen.jaycee@...edance.com> wrote:
>
> > The users of filemap_write_and_wait_range() and file_write_and_wait_range()
> > interfaces should set the lend parameter to LLONG_MAX, rather than -1, to
> > indicate they want to writeback to the very end-of-file, as several kernel
> > code paths are checking the 'wbc->range_end == LLONG_MAX' conditions.
>
> Unclear.  LLONG_MAX differs from -1 on 64-bit and differs differently
> on 32-bit.
>

I think whether using -1 or LLONG_MAX causes no difference if there is
no other code comparing  'wbc->range_end == LLONG_MAX'.  There is no
case in the kernel code using -1 for now, but maybe we'd better fix
the misleading comments to prevent future misuse.

> > --- a/mm/filemap.c
> > +++ b/mm/filemap.c
> > @@ -661,7 +661,8 @@ EXPORT_SYMBOL_GPL(filemap_range_has_writeback);
> >   * Write out and wait upon file offsets lstart->lend, inclusive.
> >   *
> >   * Note that @lend is inclusive (describes the last byte to be written) so
> > - * that this function can be used to write to the very end-of-file (end = -1).
> > + * that this function can be used to write to the very end-of-file (@lend =
> > + * LLONG_MAX).
> >   *
>
> The write(2) manpage says "According to POSIX.1, if count is greater
> than SSIZE_MAX, the result is implementation-defined; see NOTES for the
> upper limit on Linux." And filemap_fdatawrite_wbc() enforces LONG_MAX,
> which differs from LLONG_MAX on 32-bit.
>
> I suspect more research is needed here.

The reason 'wbc.nr_to_write' might be set to LONG_MAX for
filemap_fdatawrite_wbc() might be because 'nr_to_write' is defined as
the 'long' type. Maybe it should be fine as 'lend' and 'range_end' are
defined as type 'off_t'.

Thanks,
Jiachen

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ