From: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>
To: Geert Uytterhoeven <geert@linux-m68k.org>
Cc: "Jörn Engel" <joern@wohnheim.fh-wedel.de>,
"XIAO Gang" <xiao@unice.fr>,
"Linux Kernel Development" <linux-kernel@vger.kernel.org>
Subject: Re: Suggestion on "int len" sanity
Date: Fri, 3 Jun 2005 13:20:58 +0100 [thread overview]
Message-ID: <20050603122058.GF29811@parcelfarce.linux.theplanet.co.uk> (raw)
In-Reply-To: <Pine.LNX.4.62.0506031143100.16362@numbat.sonytel.be>
On Fri, Jun 03, 2005 at 11:45:51AM +0200, Geert Uytterhoeven wrote:
> On Thu, 2 Jun 2005, [iso-8859-1] J?rn Engel wrote:
> > int vfs_readlink(struct dentry *dentry, char __user *buffer, int buflen, const char *link)
> > {
> > union {
> > unsigned len;
> ^^^^^^^^
> Plain unsigned is deprecated.
>
> > int ret;
> > } u;
>
> Ugh...
Ugh, indeed - who the hell had come up with _that_?
> >
> > u.ret = PTR_ERR(link);
> > if (IS_ERR(link))
> > goto out;
> >
> > u.len = strlen(link);
> > if (u.len > (unsigned) buflen)
> > u.len = buflen;
> > if (copy_to_user(buffer, link, u.len))
> > u.ret = -EFAULT;
> > out:
> > return u.ret;
> > }
>
> buflen should be size_t.
>
> Since the return value may be negative, it should be signed. But int is not an
> option, since size_t is 64 bit on 64-bit machines, while int is still 32-bit.
> So the return type should be ssize_t.
BS from the beginning to end - we are talking about symlink bodies.
These are *not* going to be 2Gb long.
And that quite neatly shows why the whole plan is a non-starter - you need
to understand what's going on in the code being mangled.
next prev parent reply other threads:[~2005-06-03 12:20 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2005-06-02 7:28 XIAO Gang
2005-06-02 8:48 ` Jörn Engel
2005-06-02 9:12 ` XIAO Gang
2005-06-02 9:47 ` Jörn Engel
2005-06-03 9:45 ` Geert Uytterhoeven
2005-06-03 12:20 ` Al Viro [this message]
2005-06-03 14:19 ` Jörn Engel
2005-06-03 12:28 ` Andreas Schwab
2005-06-03 12:43 ` Geert Uytterhoeven
2005-06-03 14:38 ` Andreas Schwab
2005-06-03 18:04 ` randy_dunlap
2005-06-03 18:09 ` Lars Marowsky-Bree
2005-06-03 18:16 ` randy_dunlap
2005-06-04 11:28 ` Christoph Hellwig
2005-06-04 16:58 ` randy_dunlap
2005-06-04 17:07 ` Jörn Engel
2005-06-04 17:11 ` randy_dunlap
-- strict thread matches above, loose matches on Subject: below --
2005-06-01 7:06 XIAO Gang
2005-06-01 13:46 ` Jörn Engel
2005-06-01 20:39 ` Willy Tarreau
2005-06-03 9:42 ` Geert Uytterhoeven
2005-06-03 12:47 ` Takashi Iwai
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=20050603122058.GF29811@parcelfarce.linux.theplanet.co.uk \
--to=viro@parcelfarce.linux.theplanet.co.uk \
--cc=geert@linux-m68k.org \
--cc=joern@wohnheim.fh-wedel.de \
--cc=linux-kernel@vger.kernel.org \
--cc=xiao@unice.fr \
/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
Powered by JetHome