From 15b78ac5d1bdf0b38498e281fe0a769e37f0384b Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Sat, 29 Dec 2007 14:25:29 +0000 Subject: [PATCH] Apply the LCONVPATH() to the (old) linux_stat() and linux_lstat() syscalls. Without it, code has two problems: - behaviour of the old and new [l]stat are different with regard of the /compat/linux - directly accessing the userspace data from the kernel asks for the panics. Reported and tested by: Peter Holm Reviewed by: rdivacky MFC after: 3 days --- sys/compat/linux/linux_stats.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sys/compat/linux/linux_stats.c b/sys/compat/linux/linux_stats.c index 4dd941904b76..048a401dbb5b 100644 --- a/sys/compat/linux/linux_stats.c +++ b/sys/compat/linux/linux_stats.c @@ -263,12 +263,17 @@ int linux_stat(struct thread *td, struct linux_stat_args *args) { struct stat buf; + char *path; int error; + + LCONVPATHEXIST(td, args->path, &path); + #ifdef DEBUG if (ldebug(stat)) - printf(ARGS(stat, "%s, *"), args->path); + printf(ARGS(stat, "%s, *"), args->path); #endif - error = kern_stat(td, args->path, UIO_SYSSPACE, &buf); + error = kern_stat(td, path, UIO_SYSSPACE, &buf); + LFREEPATH(path); if (error) return (error); translate_path_major_minor(td, args->path, &buf); @@ -279,13 +284,17 @@ int linux_lstat(struct thread *td, struct linux_lstat_args *args) { struct stat buf; + char *path; int error; + LCONVPATHEXIST(td, args->path, &path); + #ifdef DEBUG if (ldebug(lstat)) - printf(ARGS(lstat, "%s, *"), args->path); + printf(ARGS(lstat, "%s, *"), args->path); #endif error = kern_lstat(td, args->path, UIO_SYSSPACE, &buf); + LFREEPATH(path); if (error) return (error); translate_path_major_minor(td, args->path, &buf);