stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Fengguang Wu <fengguang.wu@intel.com>
To: Jan Kara <jack@suse.cz>
Cc: Greg KH <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Ilya Tumaykin <librarian_rus@yahoo.com>
Subject: Re: [ 03/34] lib: proportion: lower PROP_MAX_SHIFT to 32 on 64-bit kernel
Date: Mon, 5 Mar 2012 13:31:26 -0800	[thread overview]
Message-ID: <20120305213126.GA16807@localhost> (raw)
In-Reply-To: <20120305150657.GB11238@quack.suse.cz>

On Mon, Mar 05, 2012 at 04:06:57PM +0100, Jan Kara wrote:
> On Thu 01-03-12 13:39:25, Greg KH wrote:
> > 2.6.32-longterm review patch.  If anyone has any objections, please let me know.
>   Not that I'd see anything wrong with this patch for 2.6.32. But it is
> also unnecessary since the code which was triggering the overflow does not
> exist in 2.6.32. So maybe just on the grounds of not applying unneeded
> patchs I'd skip this one.

FYI I never see this divide error for pre-3.2 kernels. However I've
run into problem (2) before 3.2 which makes bdi dirty threshold go
wild. So it seems safer to go with this patch.

To be frank the boxes that run into bugs (1) or (2) do not have
Terabytes of memory to create the big shift value in
calc_period_shift() which is the sufficient condition for triggering
the bugs as described in the below changelog. However the bugs do
magically go away with the patch applied. Perhaps this patch breaks
one necessary condition for triggering the bugs in a small memory box.

Thanks,
Fengguang

> > ------------------
> > 
> > From: Wu Fengguang <fengguang.wu@intel.com>
> > 
> > commit 3310225dfc71a35a2cc9340c15c0e08b14b3c754 upstream.
> > 
> > PROP_MAX_SHIFT should be set to <=32 on 64-bit box. This fixes two bugs
> > in the below lines of bdi_dirty_limit():
> > 
> > 	bdi_dirty *= numerator;
> > 	do_div(bdi_dirty, denominator);
> > 
> > 1) divide error: do_div() only uses the lower 32 bit of the denominator,
> >    which may trimmed to be 0 when PROP_MAX_SHIFT > 32.
> > 
> > 2) overflow: (bdi_dirty * numerator) could easily overflow if numerator
> >    used up to 48 bits, leaving only 16 bits to bdi_dirty
> > 
> > Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
> > Reported-by: Ilya Tumaykin <librarian_rus@yahoo.com>
> > Tested-by: Ilya Tumaykin <librarian_rus@yahoo.com>
> > Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
> > Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > 
> > ---
> >  include/linux/proportions.h |    4 ++++
> >  1 file changed, 4 insertions(+)
> > 
> > --- a/include/linux/proportions.h
> > +++ b/include/linux/proportions.h
> > @@ -81,7 +81,11 @@ void prop_inc_percpu(struct prop_descrip
> >   * Limit the time part in order to ensure there are some bits left for the
> >   * cycle counter and fraction multiply.
> >   */
> > +#if BITS_PER_LONG == 32
> >  #define PROP_MAX_SHIFT (3*BITS_PER_LONG/4)
> > +#else
> > +#define PROP_MAX_SHIFT (BITS_PER_LONG/2)
> > +#endif
> >  
> >  #define PROP_FRAC_SHIFT		(BITS_PER_LONG - PROP_MAX_SHIFT - 1)
> >  #define PROP_FRAC_BASE		(1UL << PROP_FRAC_SHIFT)
> > 
> > 
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > Please read the FAQ at  http://www.tux.org/lkml/
> -- 
> Jan Kara <jack@suse.cz>
> SUSE Labs, CR

  reply	other threads:[~2012-03-05 21:31 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01 21:46 [ 00/34] 2.6.32.58-longterm review Greg KH
2012-03-01 21:39 ` [ 01/34] drm/i915: no lvds quirk for AOpen MP45 Greg KH
2012-03-01 21:39 ` [ 02/34] hwmon: (f75375s) Fix bit shifting in f75375_write16 Greg KH
2012-03-01 21:39 ` [ 03/34] lib: proportion: lower PROP_MAX_SHIFT to 32 on 64-bit kernel Greg KH
2012-03-05 15:06   ` Jan Kara
2012-03-05 21:31     ` Fengguang Wu [this message]
2012-03-06 20:35       ` Jan Kara
2012-03-07  5:14         ` Fengguang Wu
2012-03-01 21:39 ` [ 04/34] relay: prevent integer overflow in relay_open() Greg KH
2012-03-01 21:39 ` [ 05/34] mac80211: timeout a single frame in the rx reorder buffer Greg KH
2012-03-01 21:39 ` [ 06/34] kernel.h: fix wrong usage of __ratelimit() Greg KH
2012-03-01 21:39 ` [ 07/34] printk_ratelimited(): fix uninitialized spinlock Greg KH
2012-03-01 21:39 ` [ 08/34] hwmon: (f75375s) Fix automatic pwm mode setting for F75373 & F75375 Greg KH
2012-03-01 21:39 ` [ 09/34] crypto: sha512 - Use binary and instead of modulus Greg KH
2012-03-01 21:39 ` [ 10/34] crypto: sha512 - Avoid stack bloat on i386 Greg KH
2012-03-01 21:39 ` [ 11/34] eCryptfs: Remove mmap from directory operations Greg KH
2012-03-01 21:39 ` [ 12/34] Ban ecryptfs over ecryptfs Greg KH
2012-03-01 21:39 ` [ 13/34] Add mount option to check uid of device being mounted = expect uid, CVE-2011-1833 Greg KH
2012-03-01 21:39 ` [ 14/34] crypto: sha512 - use standard ror64() Greg KH
2012-03-01 21:39 ` [ 15/34] drm/radeon/kms: fix MSI re-arm on rv370+ Greg KH
2012-03-01 21:39 ` [ 16/34] ecryptfs: read on a directory should return EISDIR if not supported Greg KH
2012-03-01 21:39 ` [ 17/34] SCSI: 3w-9xxx fix bug in sgl loading Greg KH
2012-03-01 21:39 ` [ 18/34] ARM: 7321/1: cache-v7: Disable preemption when reading CCSIDR Greg KH
2012-03-01 21:39 ` [ 19/34] ARM: 7325/1: fix v7 boot with lockdep enabled Greg KH
2012-03-01 21:39 ` [ 20/34] USB: Added Kamstrup VID/PIDs to cp210x serial driver Greg KH
2012-03-01 21:39 ` [ 21/34] USB: Fix handoff when BIOS disables host PCI device Greg KH
2012-03-01 21:39 ` [ 22/34] xhci: Fix encoding for HS bulk/control NAK rate Greg KH
2012-03-01 21:39 ` [ 23/34] [media] hdpvr: fix race conditon during start of streaming Greg KH
2012-03-01 21:39 ` [ 24/34] eCryptfs: Use notify_change for truncating lower inodes Greg KH
2012-03-01 21:39 ` [ 25/34] eCryptfs: Remove extra d_delete in ecryptfs_rmdir Greg KH
2012-03-01 21:39 ` [ 26/34] eCryptfs: Clear i_nlink in rmdir Greg KH
2012-03-01 21:39 ` [ 27/34] cdrom: use copy_to_user() without the underscores Greg KH
2012-03-01 21:39 ` [ 28/34] autofs: work around unhappy compat problem on x86-64 Greg KH
2012-03-01 21:39 ` [ 29/34] Fix autofs compile without CONFIG_COMPAT Greg KH
2012-03-01 21:39 ` [ 30/34] compat: fix compile breakage on s390 Greg KH
2012-03-01 21:39 ` [ 31/34] PM: Print a warning if firmware is requested when tasks are frozen Greg KH
2012-03-01 21:39 ` [ 32/34] firmware loader: allow builtin firmware load even if usermodehelper is disabled Greg KH
2012-03-01 21:39 ` [ 33/34] PM / Sleep: Fix freezer failures due to racy usermodehelper_is_disabled() Greg KH
2012-03-01 21:39 ` [ 34/34] PM / Sleep: Fix read_unlock_usermodehelper() call Greg KH
2012-03-02  7:19 ` [ 00/34] 2.6.32.58-longterm review Willy Tarreau
2012-03-02 13:51   ` Stefan Bader
2012-03-02 15:37   ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120305213126.GA16807@localhost \
    --to=fengguang.wu@intel.com \
    --cc=a.p.zijlstra@chello.nl \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=gregkh@linuxfoundation.org \
    --cc=jack@suse.cz \
    --cc=librarian_rus@yahoo.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).