mirror of https://gitee.com/openkylin/linux.git
x86: be careful about tailcall breakage for sys_open[at] too
Came up through a quick grep for other cases similar to the ftruncate()
one in commit 0a489cb3b6
.
Also, add a comment, so that people who read the code understand why we
do what looks like a no-op.
(Again, this won't actually matter to any sane user, since libc will
save and restore the register gcc stomps on, but it's still wrong to
stomp on it)
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
This commit is contained in:
parent
0a489cb3b6
commit
385910f2b2
16
fs/open.c
16
fs/open.c
|
@ -332,6 +332,7 @@ static long do_sys_ftruncate(unsigned int fd, loff_t length, int small)
|
||||||
asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
|
asmlinkage long sys_ftruncate(unsigned int fd, unsigned long length)
|
||||||
{
|
{
|
||||||
long ret = do_sys_ftruncate(fd, length, 1);
|
long ret = do_sys_ftruncate(fd, length, 1);
|
||||||
|
/* avoid REGPARM breakage on x86: */
|
||||||
prevent_tail_call(ret);
|
prevent_tail_call(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -346,6 +347,7 @@ asmlinkage long sys_truncate64(const char __user * path, loff_t length)
|
||||||
asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
|
asmlinkage long sys_ftruncate64(unsigned int fd, loff_t length)
|
||||||
{
|
{
|
||||||
long ret = do_sys_ftruncate(fd, length, 0);
|
long ret = do_sys_ftruncate(fd, length, 0);
|
||||||
|
/* avoid REGPARM breakage on x86: */
|
||||||
prevent_tail_call(ret);
|
prevent_tail_call(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1097,20 +1099,30 @@ long do_sys_open(int dfd, const char __user *filename, int flags, int mode)
|
||||||
|
|
||||||
asmlinkage long sys_open(const char __user *filename, int flags, int mode)
|
asmlinkage long sys_open(const char __user *filename, int flags, int mode)
|
||||||
{
|
{
|
||||||
|
long ret;
|
||||||
|
|
||||||
if (force_o_largefile())
|
if (force_o_largefile())
|
||||||
flags |= O_LARGEFILE;
|
flags |= O_LARGEFILE;
|
||||||
|
|
||||||
return do_sys_open(AT_FDCWD, filename, flags, mode);
|
ret = do_sys_open(AT_FDCWD, filename, flags, mode);
|
||||||
|
/* avoid REGPARM breakage on x86: */
|
||||||
|
prevent_tail_call(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(sys_open);
|
EXPORT_SYMBOL_GPL(sys_open);
|
||||||
|
|
||||||
asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
|
asmlinkage long sys_openat(int dfd, const char __user *filename, int flags,
|
||||||
int mode)
|
int mode)
|
||||||
{
|
{
|
||||||
|
long ret;
|
||||||
|
|
||||||
if (force_o_largefile())
|
if (force_o_largefile())
|
||||||
flags |= O_LARGEFILE;
|
flags |= O_LARGEFILE;
|
||||||
|
|
||||||
return do_sys_open(dfd, filename, flags, mode);
|
ret = do_sys_open(dfd, filename, flags, mode);
|
||||||
|
/* avoid REGPARM breakage on x86: */
|
||||||
|
prevent_tail_call(ret);
|
||||||
|
return ret;
|
||||||
}
|
}
|
||||||
EXPORT_SYMBOL_GPL(sys_openat);
|
EXPORT_SYMBOL_GPL(sys_openat);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue