From: Daniel Gollub <dgollub@suse.de>
To: linux-kernel@vger.kernel.org
Cc: linux-api@vger.kernel.org
Cc: linux-man@vger.kernel.org
Cc: ltp-list@lists.sourceforge.net
Subject: [patch 0/3] [RFC] kernel/glibc mismatch of "readlink" syscall?
Date: Thu, 23 Oct 2008 16:50:55 +0200 [thread overview]
Message-ID: <20081023145054.998439866@marvin.suse.de> (raw)
Hi,
found something which looks for me like a kernel/glibc syscall mismatch. At
least the parameter list of "readlink" is different in the kernel compared to
glibc, POSIX and linux-man-pages. I'm not quite sure if this difference was
intended or not ...
man 3p readlink:
ssize_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
http://www.opengroup.org/onlinepubs/000095399/functions/readlink.html:
size_t readlink(const char *restrict path, char *restrict buf, size_t bufsize);
glibc (/usr/include/unistd.h):
size_t readlink (__const char *__restrict __path, char *__restrict __buf, size_t
man 2 readlink:
ssize_t readlink(const char *path, char *buf, size_t bufsiz);
^^^^^^
linux-2.6/include/linux/syscalls.h:
asmlinkage long sys_readlink(const char __user *path, char __user *buf, int
bufsiz); ^^^
All readlink prototypes, expect the one in the kernel, have an unsigned
buffer size. Even the readlink(2) man-page, which also describes an error
statement like this:
EINVAL bufsiz is not positive.
Note: the same man-page defined bufsiz as type of size_t (unsigned).
While reviewing LTP i discovered that the "readlink03" syscall test contains a
testcase to do a functional error-path test for "EINVAL bufsiz is not positive".
This testcase is using the glibc readlink() interface, which cause a unsigned
cast of the value "-1" and let the testcase fail (actually due to gcc/glibc
fortify checks and cause a __chk_fail()).
Before workarounding the testcase, or not applying -D_FORTIFY_SOURCE=2 on LTP
build, i try to understand if there is any reason for this mismatch between
kernel and glibc/POSIX. Regarding the man-page, i'm quite certain this was a
copy&paste-error by coping the prototype from the POSIX man-page.
Even sys_readlinkat(), which got introduced a long time after sys_readlink(),
got a signed buffer size. Intended?
In the rare case all this was unintended, find patches for kernel, man-pages
and LTP to change the kernel readlink syscall interface to a unsigned buffer
size.
Thoughts?
best regards,
Daniel
next reply other threads:[~2008-10-23 15:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 14:50 Daniel Gollub [this message]
2008-10-23 14:50 ` [patch 1/3] [RFC] Change sys_readlink/sys_readlinkat buffer size parameter to size_t (POSIX mismatch) Daniel Gollub
2008-10-23 14:50 ` [patch 2/3] [man-pages] Remove "bufsize is not positive" from readlink(2) error section Daniel Gollub
2008-10-23 14:50 ` [patch 3/3] [ltp] Remove testcase for "Buffer size is not positive" in kernel/syscalls/readlink/readlink03 Daniel Gollub
2008-10-24 22:53 ` [patch 0/3] [RFC] kernel/glibc mismatch of "readlink" syscall? Michael Kerrisk
2008-10-28 9:11 ` Andries E. Brouwer
2008-10-31 15:02 ` Kai Henningsen
2008-10-31 15:37 ` Daniel Gollub
2008-11-04 16:20 ` Michael Kerrisk
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=20081023145054.998439866@marvin.suse.de \
--to=dgollub@suse.de \
--cc=linux-api@vger.kernel.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
Powered by JetHome