From: Linus Torvalds <torvalds@linux-foundation.org>
To: Al Viro <viro@ZenIV.linux.org.uk>
Cc: Jeff Mahoney <jeffm@suse.com>,
Andrew Morton <akpm@linux-foundation.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Al Viro <viro@ftp.linux.org.uk>
Subject: Re: [PATCH] dup2: Fix return value with oldfd == newfd and invalid fd
Date: Mon, 11 May 2009 12:26:59 -0700 (PDT) [thread overview]
Message-ID: <alpine.LFD.2.01.0905111220270.3586@localhost.localdomain> (raw)
In-Reply-To: <20090511191142.GK8633@ZenIV.linux.org.uk>
On Mon, 11 May 2009, Al Viro wrote:
>
> I'm not sure that it's a right fix, actually. Note that userland declaration
> of that sucker is int dup2(int, int); so should we really take unsigned int
> as arguments?
Hmm. They've been "unsigned int" for as long as our history goes back
(including BK), but yes, making them "int" would have hidden this issue as
well.
That said, I think we had reasons to do our fd's as unsigned, ie the whole
"compare against MAX" thing that doesn't take negative values into
account.
In fact, I think we should do more of those. Right now we literally depend
on things like "max_fds" being "unsigned int", and that the compiler then
turns all the
if (fd < fdt->max_fds)
tests silently into unsigned tests even when 'fd' is 'int'.
So I suspect we should probably make fs/file.c use _more_ "unsigned int"
rather than having less of them.
Linus
next prev parent reply other threads:[~2009-05-11 19:29 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-05-11 18:25 Jeff Mahoney
2009-05-11 18:40 ` Linus Torvalds
2009-05-11 19:00 ` Jeff Mahoney
2009-05-11 19:11 ` Al Viro
2009-05-11 19:26 ` Linus Torvalds [this message]
2009-05-11 19:49 ` Al Viro
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=alpine.LFD.2.01.0905111220270.3586@localhost.localdomain \
--to=torvalds@linux-foundation.org \
--cc=akpm@linux-foundation.org \
--cc=jeffm@suse.com \
--cc=linux-kernel@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
--cc=viro@ftp.linux.org.uk \
/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®