fs/intermezzo/ext_attr.c

fs/intermezzo/kml.c
fs/intermezzo/psdev.c

	- fix copy_{to,from}_user error handling (thans to Rusty for pointing this out)
parent fa82a1da
...@@ -105,9 +105,8 @@ int presto_set_ext_attr(struct inode *inode, ...@@ -105,9 +105,8 @@ int presto_set_ext_attr(struct inode *inode,
printk("InterMezzo: out of memory!!!\n"); printk("InterMezzo: out of memory!!!\n");
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(buf, buffer, buffer_len); if (copy_from_user(buf, buffer, buffer_len))
if (error) return -EFAULT;
return error;
} else } else
buf = buffer; buf = buffer;
} else } else
......
...@@ -31,10 +31,9 @@ int begin_kml_reint (struct file *file, unsigned long arg) ...@@ -31,10 +31,9 @@ int begin_kml_reint (struct file *file, unsigned long arg)
ENTRY; ENTRY;
/* allocate buffer & copy it to kernel space */ /* allocate buffer & copy it to kernel space */
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
if (input.reclen > kml_fsdata->kml_maxsize) if (input.reclen > kml_fsdata->kml_maxsize)
...@@ -45,11 +44,10 @@ int begin_kml_reint (struct file *file, unsigned long arg) ...@@ -45,11 +44,10 @@ int begin_kml_reint (struct file *file, unsigned long arg)
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.volname, input.namelen); if (copy_from_user(path, input.volname, input.namelen)) {
if ( error ) {
PRESTO_FREE(path, input.namelen + 1); PRESTO_FREE(path, input.namelen + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.namelen] = '\0'; path[input.namelen] = '\0';
fset = kml_getfset (path); fset = kml_getfset (path);
...@@ -57,10 +55,9 @@ int begin_kml_reint (struct file *file, unsigned long arg) ...@@ -57,10 +55,9 @@ int begin_kml_reint (struct file *file, unsigned long arg)
kml_fsdata = FSET_GET_KMLDATA(fset); kml_fsdata = FSET_GET_KMLDATA(fset);
/* read the buf from user memory here */ /* read the buf from user memory here */
error = copy_from_user(kml_fsdata->kml_buf, input.recbuf, input.reclen); if (copy_from_user(kml_fsdata->kml_buf, input.recbuf, input.reclen)) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
kml_fsdata->kml_len = input.reclen; kml_fsdata->kml_len = input.reclen;
...@@ -94,21 +91,19 @@ int do_kml_reint (struct file *file, unsigned long arg) ...@@ -94,21 +91,19 @@ int do_kml_reint (struct file *file, unsigned long arg)
struct presto_file_set *fset; struct presto_file_set *fset;
ENTRY; ENTRY;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.namelen + 1); PRESTO_ALLOC(path, char *, input.namelen + 1);
if ( !path ) { if ( !path ) {
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.volname, input.namelen); if (copy_from_user(path, input.volname, input.namelen)) {
if ( error ) {
PRESTO_FREE(path, input.namelen + 1); PRESTO_FREE(path, input.namelen + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.namelen] = '\0'; path[input.namelen] = '\0';
fset = kml_getfset (path); fset = kml_getfset (path);
...@@ -138,7 +133,8 @@ int do_kml_reint (struct file *file, unsigned long arg) ...@@ -138,7 +133,8 @@ int do_kml_reint (struct file *file, unsigned long arg)
strlen (close->path) + 1, input.pathlen); strlen (close->path) + 1, input.pathlen);
error = -ENOMEM; error = -ENOMEM;
} }
copy_to_user((char *)arg, &input, sizeof (input)); if (copy_to_user((char *)arg, &input, sizeof (input)))
return -EFAULT;
} }
return error; return error;
} }
...@@ -161,10 +157,9 @@ int end_kml_reint (struct file *file, unsigned long arg) ...@@ -161,10 +157,9 @@ int end_kml_reint (struct file *file, unsigned long arg)
char *path; char *path;
ENTRY; ENTRY;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.namelen + 1); PRESTO_ALLOC(path, char *, input.namelen + 1);
...@@ -172,11 +167,11 @@ int end_kml_reint (struct file *file, unsigned long arg) ...@@ -172,11 +167,11 @@ int end_kml_reint (struct file *file, unsigned long arg)
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.volname, input.namelen); if (copy_from_user(path, input.volname, input.namelen)) {
if ( error ) { if ( error ) {
PRESTO_FREE(path, input.namelen + 1); PRESTO_FREE(path, input.namelen + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.namelen] = '\0'; path[input.namelen] = '\0';
fset = kml_getfset (path); fset = kml_getfset (path);
...@@ -193,7 +188,8 @@ int end_kml_reint (struct file *file, unsigned long arg) ...@@ -193,7 +188,8 @@ int end_kml_reint (struct file *file, unsigned long arg)
#if 0 #if 0
input.newpos = kml_upc->newpos; input.newpos = kml_upc->newpos;
input.count = kml_upc->count; input.count = kml_upc->count;
copy_to_user((char *)arg, &input, sizeof (input)); if (copy_to_user((char *)arg, &input, sizeof (input)))
return -EFAULT;
#endif #endif
return error; return error;
} }
...@@ -149,9 +149,8 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf, ...@@ -149,9 +149,8 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf,
return -EINVAL; return -EINVAL;
} }
error = copy_from_user(&hdr, buf, sizeof(hdr)); if (copy_from_user(&hdr, buf, sizeof(hdr)))
if ( error ) return -EFAULT;
return error;
CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%d,%d)\n", CDEBUG(D_PSDEV, "(process,opc,uniq)=(%d,%d,%d)\n",
current->pid, hdr.opcode, hdr.unique); current->pid, hdr.opcode, hdr.unique);
...@@ -183,9 +182,8 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf, ...@@ -183,9 +182,8 @@ static ssize_t presto_psdev_write(struct file *file, const char *buf,
req->rq_bufsize, count, hdr.opcode, hdr.unique); req->rq_bufsize, count, hdr.opcode, hdr.unique);
count = req->rq_bufsize; /* don't have more space! */ count = req->rq_bufsize; /* don't have more space! */
} }
error = copy_from_user(req->rq_data, buf, count); if (copy_from_user(req->rq_data, buf, count))
if ( error ) return -EFAULT;
return error;
/* adjust outsize: good upcalls can be aware of this */ /* adjust outsize: good upcalls can be aware of this */
req->rq_rep_size = count; req->rq_rep_size = count;
...@@ -280,14 +278,12 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -280,14 +278,12 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
char * tmp; char * tmp;
int error; int error;
error = copy_from_user(&readmount, (void *)arg, if (copy_from_user(&readmount, (void *)arg, sizeof(readmount)))
sizeof(readmount));
if ( error ) {
printk("psdev: can't copy %Zd bytes from %p to %p\n", printk("psdev: can't copy %Zd bytes from %p to %p\n",
sizeof(readmount), (struct readmount *) arg, sizeof(readmount), (struct readmount *) arg,
&readmount); &readmount);
EXIT; EXIT;
return error; return -EFAULT;
} }
len = readmount.io_len; len = readmount.io_len;
...@@ -307,15 +303,16 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -307,15 +303,16 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
* I mean, let's let the compiler do a little work ... * I mean, let's let the compiler do a little work ...
* gcc suggested the extra () * gcc suggested the extra ()
*/ */
error = copy_to_user(readmount.io_string, tmp, outlen); if (copy_to_user(readmount.io_string, tmp, outlen)) {
if ( error ) {
CDEBUG(D_PSDEV, "Copy_to_user string 0x%p failed\n", CDEBUG(D_PSDEV, "Copy_to_user string 0x%p failed\n",
readmount.io_string); readmount.io_string);
error = -EFAULT;
} }
if ((!error) && (error = copy_to_user(&(user_readmount->io_len), if (!error && copy_to_user(&(user_readmount->io_len),
&outlen, sizeof(int))) ) { &outlen, sizeof(int))) {
CDEBUG(D_PSDEV, "Copy_to_user len @0x%p failed\n", CDEBUG(D_PSDEV, "Copy_to_user len @0x%p failed\n",
&(user_readmount->io_len)); &(user_readmount->io_len));
error = -EFAULT;
} }
PRESTO_FREE(tmp, len); PRESTO_FREE(tmp, len);
...@@ -360,10 +357,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -360,10 +357,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int path_len; int path_len;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.path_len + 1); PRESTO_ALLOC(path, char *, input.path_len + 1);
...@@ -371,11 +367,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -371,11 +367,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.path, input.path_len); if (copy_from_user(path, input.path, input.path_len)) {
if ( error ) {
PRESTO_FREE(path, input.path_len + 1); PRESTO_FREE(path, input.path_len + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.path_len] = '\0'; path[input.path_len] = '\0';
CDEBUG(D_PSDEV, "clear_fsetroot: path %s\n", path); CDEBUG(D_PSDEV, "clear_fsetroot: path %s\n", path);
...@@ -401,10 +396,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -401,10 +396,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int path_len; int path_len;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.path_len + 1); PRESTO_ALLOC(path, char *, input.path_len + 1);
...@@ -412,11 +406,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -412,11 +406,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.path, input.path_len); if (copy_from_user(path, input.path, input.path_len)) {
if ( error ) {
PRESTO_FREE(path, input.path_len + 1); PRESTO_FREE(path, input.path_len + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.path_len] = '\0'; path[input.path_len] = '\0';
CDEBUG(D_PSDEV, "clear_all_fsetroot: path %s\n", path); CDEBUG(D_PSDEV, "clear_all_fsetroot: path %s\n", path);
...@@ -440,10 +433,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -440,10 +433,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int path_len; int path_len;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.path_len + 1); PRESTO_ALLOC(path, char *, input.path_len + 1);
...@@ -451,11 +443,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -451,11 +443,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.path, input.path_len); if (copy_from_user(path, input.path, input.path_len)) {
if ( error ) {
PRESTO_FREE(path, input.path_len + 1); PRESTO_FREE(path, input.path_len + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.path_len] = '\0'; path[input.path_len] = '\0';
CDEBUG(D_PSDEV, "get_kmlsize: len %d path %s\n", CDEBUG(D_PSDEV, "get_kmlsize: len %d path %s\n",
...@@ -474,7 +465,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -474,7 +465,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
CDEBUG(D_PSDEV, "get_kmlsize: size = %Zd\n", size); CDEBUG(D_PSDEV, "get_kmlsize: size = %Zd\n", size);
EXIT; EXIT;
return copy_to_user((char *)arg, &input, sizeof(input)); if (copy_to_user((char *)arg, &input, sizeof(input)))
return -EFAULT;
return 0;
} }
case PRESTO_GET_RECNO: { case PRESTO_GET_RECNO: {
...@@ -488,10 +481,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -488,10 +481,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int path_len; int path_len;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.path_len + 1); PRESTO_ALLOC(path, char *, input.path_len + 1);
...@@ -499,11 +491,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -499,11 +491,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.path, input.path_len); if (copy_from_user(path, input.path, input.path_len)) {
if ( error ) {
PRESTO_FREE(path, input.path_len + 1); PRESTO_FREE(path, input.path_len + 1);
EXIT; EXIT;
return error; return -EFAULT;
} }
path[input.path_len] = '\0'; path[input.path_len] = '\0';
CDEBUG(D_PSDEV, "get_recno: len %d path %s\n", CDEBUG(D_PSDEV, "get_recno: len %d path %s\n",
...@@ -522,7 +513,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -522,7 +513,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
CDEBUG(D_PSDEV, "get_recno: recno = %d\n", (int) recno); CDEBUG(D_PSDEV, "get_recno: recno = %d\n", (int) recno);
EXIT; EXIT;
return copy_to_user((char *)arg, &input, sizeof(input)); if (copy_to_user((char *)arg, &input, sizeof(input)))
return -EFAULT;
return 0;
} }
case PRESTO_SET_FSETROOT: { case PRESTO_SET_FSETROOT: {
...@@ -543,10 +536,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -543,10 +536,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int flags; int flags;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
PRESTO_ALLOC(path, char *, input.path_len + 1); PRESTO_ALLOC(path, char *, input.path_len + 1);
...@@ -554,9 +546,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -554,9 +546,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(path, input.path, input.path_len); if (copy_from_user(path, input.path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
error -EFAULT;
goto exit_free_path; goto exit_free_path;
} }
path[input.path_len] = '\0'; path[input.path_len] = '\0';
...@@ -567,9 +559,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -567,9 +559,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
goto exit_free_path; goto exit_free_path;
} }
error = copy_from_user(fsetname, input.name, input.name_len); if (copy_from_user(fsetname, input.name, input.name_len)) {
if ( error ) {
EXIT; EXIT;
error = -EFAULT;
goto exit_free_fsetname; goto exit_free_fsetname;
} }
fsetname[input.name_len] = '\0'; fsetname[input.name_len] = '\0';
...@@ -621,12 +613,11 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -621,12 +613,11 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct psdev_opt *user_opt = (struct psdev_opt *) arg; struct psdev_opt *user_opt = (struct psdev_opt *) arg;
int error; int error;
error = copy_from_user(&kopt, (void *)arg, sizeof(kopt)); if (copy_from_user(&kopt, (void *)arg, sizeof(kopt))) {
if ( error ) {
printk("psdev: can't copyin %Zd bytes from %p to %p\n", printk("psdev: can't copyin %Zd bytes from %p to %p\n",
sizeof(kopt), (struct kopt *) arg, &kopt); sizeof(kopt), (struct kopt *) arg, &kopt);
EXIT; EXIT;
return error; return -EFAULT;
} }
minor = minor(dev); minor = minor(dev);
if (cmd == PRESTO_SETOPT) if (cmd == PRESTO_SETOPT)
...@@ -650,12 +641,11 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -650,12 +641,11 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
return error; return error;
} }
error = copy_to_user(user_opt, &kopt, sizeof(kopt)); if (copy_to_user(user_opt, &kopt, sizeof(kopt))) {
if ( error ) {
CDEBUG(D_PSDEV, "Copy_to_user opt 0x%p failed\n", CDEBUG(D_PSDEV, "Copy_to_user opt 0x%p failed\n",
user_opt); user_opt);
EXIT; EXIT;
return error; return -EFAULT;
} }
CDEBUG(D_PSDEV, "dosetopt minor %d, opt %d, val %d return %d\n", CDEBUG(D_PSDEV, "dosetopt minor %d, opt %d, val %d return %d\n",
minor, kopt.optname, kopt.optval, error); minor, kopt.optname, kopt.optval, error);
...@@ -668,10 +658,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -668,10 +658,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct lento_input_attr input; struct lento_input_attr input;
struct iattr iattr; struct iattr iattr;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
iattr.ia_valid = input.valid; iattr.ia_valid = input.valid;
iattr.ia_mode = (umode_t)input.mode; iattr.ia_mode = (umode_t)input.mode;
...@@ -692,10 +681,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -692,10 +681,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_mode input; struct lento_input_mode input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_create(input.name, input.mode, &input.info); error = lento_create(input.name, input.mode, &input.info);
...@@ -707,10 +695,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -707,10 +695,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_old_new input; struct lento_input_old_new input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_link(input.oldname, input.newname, &input.info); error = lento_link(input.oldname, input.newname, &input.info);
...@@ -722,10 +709,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -722,10 +709,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input input; struct lento_input input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_unlink(input.name, &input.info); error = lento_unlink(input.name, &input.info);
...@@ -737,10 +723,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -737,10 +723,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_old_new input; struct lento_input_old_new input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_symlink(input.oldname, input.newname,&input.info); error = lento_symlink(input.oldname, input.newname,&input.info);
...@@ -752,10 +737,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -752,10 +737,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_mode input; struct lento_input_mode input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_mkdir(input.name, input.mode, &input.info); error = lento_mkdir(input.name, input.mode, &input.info);
...@@ -767,10 +751,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -767,10 +751,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input input; struct lento_input input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_rmdir(input.name, &input.info); error = lento_rmdir(input.name, &input.info);
...@@ -782,10 +765,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -782,10 +765,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_dev input; struct lento_input_dev input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_mknod(input.name, input.mode, error = lento_mknod(input.name, input.mode,
...@@ -798,10 +780,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -798,10 +780,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
int error; int error;
struct lento_input_old_new input; struct lento_input_old_new input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
error = lento_rename(input.oldname, input.newname, &input.info); error = lento_rename(input.oldname, input.newname, &input.info);
...@@ -817,30 +798,27 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -817,30 +798,27 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
char *name; char *name;
char *buffer; char *buffer;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
/* Now setup the input parameters */ /* Now setup the input parameters */
PRESTO_ALLOC(name, char *, input.name_len+1); PRESTO_ALLOC(name, char *, input.name_len+1);
/* We need null terminated strings for attr names */ /* We need null terminated strings for attr names */
name[input.name_len] = '\0'; name[input.name_len] = '\0';
error=copy_from_user(name, input.name, input.name_len); if (copy_from_user(name, input.name, input.name_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(name,input.name_len+1); PRESTO_FREE(name,input.name_len+1);
return error; return -EFAULT;
} }
PRESTO_ALLOC(buffer, char *, input.buffer_len+1); PRESTO_ALLOC(buffer, char *, input.buffer_len+1);
error=copy_from_user(buffer, input.buffer, input.buffer_len); if (copy_from_user(buffer, input.buffer, input.buffer_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(name,input.name_len+1); PRESTO_FREE(name,input.name_len+1);
PRESTO_FREE(buffer,input.buffer_len+1); PRESTO_FREE(buffer,input.buffer_len+1);
return error; return -EFAULT;
} }
/* Make null terminated for easy printing */ /* Make null terminated for easy printing */
buffer[input.buffer_len]='\0'; buffer[input.buffer_len]='\0';
...@@ -869,21 +847,19 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -869,21 +847,19 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct lento_input_ext_attr input; struct lento_input_ext_attr input;
char *name; char *name;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
/* Now setup the input parameters */ /* Now setup the input parameters */
PRESTO_ALLOC(name, char *, input.name_len+1); PRESTO_ALLOC(name, char *, input.name_len+1);
/* We need null terminated strings for attr names */ /* We need null terminated strings for attr names */
name[input.name_len] = '\0'; name[input.name_len] = '\0';
error=copy_from_user(name, input.name, input.name_len); if (copy_from_user(name, input.name, input.name_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(name,input.name_len+1); PRESTO_FREE(name,input.name_len+1);
return error; return -EFAULT;
} }
CDEBUG(D_PSDEV," delextattr params: name %s," CDEBUG(D_PSDEV," delextattr params: name %s,"
...@@ -907,10 +883,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -907,10 +883,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct lento_input_iopen input; struct lento_input_iopen input;
int error; int error;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
input.fd = lento_iopen(input.name, (ino_t)input.ino, input.fd = lento_iopen(input.name, (ino_t)input.ino,
...@@ -921,17 +896,18 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -921,17 +896,18 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
return input.fd; return input.fd;
} }
EXIT; EXIT;
return copy_to_user((char *)arg, &input, sizeof(input)); if (copy_to_user((char *)arg, &input, sizeof(input)))
return -EFAULT;
return 0;
} }
case PRESTO_VFS_CLOSE: { case PRESTO_VFS_CLOSE: {
int error; int error;
struct lento_input_close input; struct lento_input_close input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
CDEBUG(D_PIOCTL, "lento_close file descriptor: %d\n", input.fd); CDEBUG(D_PIOCTL, "lento_close file descriptor: %d\n", input.fd);
...@@ -952,10 +928,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -952,10 +928,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct presto_version remote_file_version; struct presto_version remote_file_version;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = input.path; user_path = input.path;
...@@ -964,11 +939,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -964,11 +939,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(input.path, user_path, input.path_len); if (copy_from_user(input.path, user_path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(input.path, input.path_len + 1); PRESTO_FREE(input.path, input.path_len + 1);
return error; return -EFAULT;
} }
input.path[input.path_len] = '\0'; input.path[input.path_len] = '\0';
...@@ -996,10 +970,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -996,10 +970,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
struct lento_vfs_context info; struct lento_vfs_context info;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = input.path; user_path = input.path;
...@@ -1008,11 +981,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1008,11 +981,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(input.path, user_path, input.path_len); if (copy_from_user(input.path, user_path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(input.path, input.path_len + 1); PRESTO_FREE(input.path, input.path_len + 1);
return error; return -EFAULT;
} }
input.path[input.path_len] = '\0'; input.path[input.path_len] = '\0';
...@@ -1035,10 +1007,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1035,10 +1007,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
__u32 path_len; __u32 path_len;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = input.path; user_path = input.path;
...@@ -1047,11 +1018,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1047,11 +1018,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(input.path, user_path, input.path_len); if (copy_from_user(input.path, user_path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(input.path, input.path_len + 1); PRESTO_FREE(input.path, input.path_len + 1);
return error; return -EFAULT;
} }
input.path[input.path_len] = '\0'; input.path[input.path_len] = '\0';
...@@ -1072,10 +1042,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1072,10 +1042,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
__u32 recno; __u32 recno;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = input.path; user_path = input.path;
...@@ -1084,11 +1053,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1084,11 +1053,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(input.path, user_path, input.path_len); if (copy_from_user(input.path, user_path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(input.path, input.path_len + 1); PRESTO_FREE(input.path, input.path_len + 1);
return error; return -EFAULT;
} }
input.path[input.path_len] = '\0'; input.path[input.path_len] = '\0';
...@@ -1111,10 +1079,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1111,10 +1079,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
char *path; char *path;
} input; } input;
error = copy_from_user(&input, (char *)arg, sizeof(input)); if (copy_from_user(&input, (char *)arg, sizeof(input))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = input.path; user_path = input.path;
...@@ -1123,11 +1090,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1123,11 +1090,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(input.path, user_path, input.path_len); if (copy_from_user(input.path, user_path, input.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(input.path, input.path_len + 1); PRESTO_FREE(input.path, input.path_len + 1);
return error; return -EFAULT;
} }
input.path[input.path_len] = '\0'; input.path[input.path_len] = '\0';
...@@ -1190,7 +1156,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1190,7 +1156,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
} }
/* return the correct cookie to wait for */ /* return the correct cookie to wait for */
input.mark_what = res; input.mark_what = res;
return copy_to_user((char *)arg, &input, sizeof(input)); if (copy_to_user((char *)arg, &input, sizeof(input)))
return -EFAULT;
return 0;
} }
#ifdef CONFIG_KREINT #ifdef CONFIG_KREINT
...@@ -1211,11 +1179,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1211,11 +1179,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
char *path; char *path;
} permit; } permit;
error = copy_from_user(&permit, (char *)arg, sizeof(permit)); if (copy_from_user(&permit, (char *)arg, sizeof(permit))) {
if ( error ) {
EXIT; EXIT;
return error; return -EFAULT;
} }
user_path = permit.path; user_path = permit.path;
PRESTO_ALLOC(permit.path, char *, permit.path_len + 1); PRESTO_ALLOC(permit.path, char *, permit.path_len + 1);
...@@ -1223,11 +1190,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1223,11 +1190,10 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
EXIT; EXIT;
return -ENOMEM; return -ENOMEM;
} }
error = copy_from_user(permit.path, user_path, permit.path_len); if (copy_from_user(permit.path, user_path, permit.path_len)) {
if ( error ) {
EXIT; EXIT;
PRESTO_FREE(permit.path, permit.path_len + 1); PRESTO_FREE(permit.path, permit.path_len + 1);
return error; return -EFAULT;
} }
permit.path[permit.path_len] = '\0'; permit.path[permit.path_len] = '\0';
...@@ -1241,7 +1207,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file, ...@@ -1241,7 +1207,9 @@ static int presto_psdev_ioctl(struct inode *inode, struct file *file,
return error; return error;
} }
/* return the correct cookie to wait for */ /* return the correct cookie to wait for */
return copy_to_user((char *)arg, &permit, sizeof(permit)); if (copy_to_user((char *)arg, &permit, sizeof(permit)))
return -EFAULT;
return 0;
} }
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment