mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Matthew Wilcox <willy@debian.org>
To: Walter Harms <WHarms@bfs.de>
Cc: kernel-janitors@lists.osdl.org, linux-kernel@vger.kernel.org
Subject: Re: [Kernel-janitors] mm/slab.c: linux 2.6.1 fix 2 unguarded kmalloc and a PAGE_SHIFT
Date: Thu, 29 Jan 2004 02:35:39 +0000	[thread overview]
Message-ID: <20040129023539.GA18725@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: =?ISO-8859-1?Q?=20PI-LINK-8a65df8cf252c22fbf1beee115ac60752f46e442?=

On Sun, Jan 25, 2004 at 03:02:24PM +0100, Walter Harms wrote:
> Hi list,
> this fixes catches 2 unguarded kmallocs() and changes a statement so that PAGE_SHIFT >20 causes a warning. 
> At least sparc64 is prepared for a  PAGE_SHIFT >20.

> -       if (num_physpages > (32 << 20) >> PAGE_SHIFT)
> +       if (num_physpages > (32 << (20-PAGE_SHIFT) )

Erm, that's a bad change to make.  There's nothing wrong with having
a PAGE_SHIFT of >20, and this code would still work ... but with your
change it's now undefined behaviour.  Please don't make this change.

(worked examples:

1. suppose we have a PAGE_SHIFT of 24 (16MB page size), the original
code shifts 32 left by 20 then right by 24, net result a right shift of
4 => 2.  Since any machine with a 16MB page size is going to have more
than 2 pages, we're fine.  the new code will shift 32 left by -4 which
is undefined.  bad.

2. suppose we have a PAGE_SHIFT of 26 (64MB page size), the original
code shifts right by 6, result 0.  Since the number of pages is > 0
(one hopes ;-), the test will also succeed as desired.

)

-- 
"Next the statesmen will invent cheap lies, putting the blame upon 
the nation that is attacked, and every man will be glad of those
conscience-soothing falsities, and will diligently study them, and refuse
to examine any refutations of them; and thus he will by and by convince 
himself that the war is just, and will thank God for the better sleep 
he enjoys after this process of grotesque self-deception." -- Mark Twain

           reply	other threads:[~2004-01-29  2:35 UTC|newest]

Thread overview: expand[flat|nested]  mbox.gz  Atom feed
 [parent not found: <vines.sxdD+dlw=B2?= =?ISO-8859-1?Q?+A@SZKOM.BFS.DE>]

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=20040129023539.GA18725@parcelfarce.linux.theplanet.co.uk \
    --to=willy@debian.org \
    --cc=WHarms@bfs.de \
    --cc=kernel-janitors@lists.osdl.org \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®