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-next>] [day] [month] [year] [list]
Message-ID: <1329450227.2373.6.camel@js-netbook>
Date:	Thu, 16 Feb 2012 19:43:47 -0800
From:	John Stultz <john.stultz@...aro.org>
To:	Dmitry Adamushko <dmitry.adamushko@...il.com>
Cc:	linux-kernel@...r.kernel.org,
	Andrew Morton <akpm@...ux-foundation.org>,
	Android Kernel Team <kernel-team@...roid.com>,
	Robert Love <rlove@...gle.com>, Mel Gorman <mel@....ul.ie>,
	Hugh Dickins <hughd@...gle.com>,
	Dave Hansen <dave@...ux.vnet.ibm.com>,
	Rik van Riel <riel@...hat.com>
Subject: Re: [PATCH 2/2] [RFC] fadvise: Add _VOLATILE,_ISVOLATILE, and
 _NONVOLATILE flags

On Sun, 2012-02-12 at 13:48 +0100, Dmitry Adamushko wrote:
> 
> On 10 February 2012 01:16, John Stultz <john.stultz@...aro.org> wrote:

>         +static inline void volatile_range_shrink(struct
>         volatile_range *range,
>         +                               pgoff_t start_index, pgoff_t
>         end_index)
>         +{
>         +       size_t pre = range_size(range);
>         +
>         +       range->range_node.start = start_index;
>         +       range->range_node.end = end_index;
>         +
> 
> I guess, here we get a whole range of races with volatile_shrink(),
> which may see inconsistent (in-the-middle-of-update) ranges
> (e.g. .start and .end).

We should be holding the vlist_mutex to avoid any such races. But you
also make clear that volatile_range_shrink() should really be called
volatile_range_resize(), since having two _shrink calls is terrible. My
apologies.
 

>         +       unsigned long nr_to_scan = sc->nr_to_scan;
>         +       const gfp_t gfp_mask = sc->gfp_mask;
>         +
>         +       /* We might recurse into filesystem code, so bail out
>         if necessary */
>         +       if (nr_to_scan && !(gfp_mask & __GFP_FS))
>         +               return -1;
>         +       if (!nr_to_scan)
>         +               return lru_count;
> 
> So it's u64 -> int here, which is possibly 32 bits and signed. Can't
> it lead to inconsistent results on 32bit platforms?

Good point. Thanks for pointing that out.

>         +               start = range->range_node.start * PAGE_SIZE;
>         +               end = (range->range_node.end + 1) * PAGE_SIZE
>         - 1;
> 
> PAGE_CACHE_SHIFT was used in fadvise() to calculate .start and .end
> indexes, and here we use PAGE_SIZE to get back to 'normal' addresses.
> Isn't it inconsistent at the very least?

Fair enough.

>         
>         +               nr_to_scan -= range_size(range);
> 
> hmm, unsigned long -= u64
>  
>         +               if (nr_to_scan <= 0)
> 
> nr_to_scan is "unsigned long" :-))

Good catch. 

Thanks for the feedback!
-john



--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ