mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andries Brouwer <aebr@win.tue.nl>
To: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
Cc: Andries Brouwer <aebr@win.tue.nl>,
	Vojtech Pavlik <vojtech@suse.cz>,
	Linus Torvalds <torvalds@osdl.org>, Andrew Morton <akpm@osdl.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] Fix NR_KEYS off-by-one error
Date: Wed, 28 Jul 2004 13:51:30 +0200	[thread overview]
Message-ID: <20040728115130.GA4008@pclin040.win.tue.nl> (raw)
In-Reply-To: <871xjbkv8g.fsf@devron.myhome.or.jp>

On Sat, Jul 17, 2004 at 03:23:27PM +0900, OGAWA Hirofumi wrote:

> > :: KDGKBENT ioctl can use 256 entries (0-255), but it was defined as
> > :: key_map[NR_KEYS] (NR_KEYS == 255). The code seems also thinking it's 256.
> > :: 
> > :: 	key_map[0] = U(K_ALLOCATED);
> > :: 	for (j = 1; j < NR_KEYS; j++)
> > :: 		key_map[j] = U(K_HOLE);
> > 
> > I think the code has no opinion. It was 128 in 2.4.
> > I am not aware of assumptions on NR_KEYS.
> > So, do not think this is an off-by-one error.
> 
> My point is that key_map is 0-254 array. But KDGKBENT uses 255
> 
> 	case KDGKBENT:
> 		key_map = key_maps[s];
> 		if (key_map) {
> 		    val = U(key_map[i]);

Hmm. Yes.

In 2.4 the preceding code is

        if (i >= NR_KEYS || s >= MAX_NR_KEYMAPS)
                return -EINVAL;

It looks like somebody removed this test in 2.6. Bad.
No doubt an error caused by "fixing" gcc warnings.
Shame on akpm.

When an array has an arbitrary upper bound that can be changed
via a #define, and for some values of the upper bound a test
is superfluous, that does not mean that the test is superfluous.

Andries


  parent reply	other threads:[~2004-07-28 11:52 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-07-16 16:35 OGAWA Hirofumi
2004-07-16 16:44 ` Vojtech Pavlik
2004-07-16 17:18   ` OGAWA Hirofumi
2004-07-16 20:15   ` Andries Brouwer
2004-07-17  6:23     ` OGAWA Hirofumi
2004-07-26 22:43       ` Andrew Morton
2004-07-27 13:46         ` Vojtech Pavlik
2004-07-27 16:37           ` OGAWA Hirofumi
2004-07-27 17:54             ` Vojtech Pavlik
2004-07-27 18:35               ` OGAWA Hirofumi
2004-07-28 11:51       ` Andries Brouwer [this message]
2004-07-28 16:46         ` OGAWA Hirofumi
2004-07-28 20:42           ` Paul Jackson
2004-07-29  4:10             ` OGAWA Hirofumi
2004-07-29  6:15               ` Paul Jackson
2004-07-29  9:24                 ` OGAWA Hirofumi
2004-07-29  9:49                   ` Paul Jackson
2004-07-29 23:24                     ` Andrew Morton
2004-07-29 23:51                       ` Paul Jackson
2004-07-30  1:25                         ` OGAWA Hirofumi
2004-07-30  7:27                           ` Paul Jackson
2004-07-30  8:07                             ` Vojtech Pavlik
2004-07-30  8:41                               ` Andries Brouwer
2004-07-30  8:51                                 ` Vojtech Pavlik
2004-07-30  9:03                                 ` Vojtech Pavlik

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=20040728115130.GA4008@pclin040.win.tue.nl \
    --to=aebr@win.tue.nl \
    --cc=akpm@osdl.org \
    --cc=hirofumi@mail.parknet.co.jp \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@osdl.org \
    --cc=vojtech@suse.cz \
    /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®