mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-03-30 19:15:14 +00:00
switch copy_module_from_fd() to fdget
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
This commit is contained in:
parent
e95c311e17
commit
a2e0578be3
1 changed files with 6 additions and 7 deletions
|
@ -2540,21 +2540,20 @@ static int copy_module_from_user(const void __user *umod, unsigned long len,
|
||||||
/* Sets info->hdr and info->len. */
|
/* Sets info->hdr and info->len. */
|
||||||
static int copy_module_from_fd(int fd, struct load_info *info)
|
static int copy_module_from_fd(int fd, struct load_info *info)
|
||||||
{
|
{
|
||||||
struct file *file;
|
struct fd f = fdget(fd);
|
||||||
int err;
|
int err;
|
||||||
struct kstat stat;
|
struct kstat stat;
|
||||||
loff_t pos;
|
loff_t pos;
|
||||||
ssize_t bytes = 0;
|
ssize_t bytes = 0;
|
||||||
|
|
||||||
file = fget(fd);
|
if (!f.file)
|
||||||
if (!file)
|
|
||||||
return -ENOEXEC;
|
return -ENOEXEC;
|
||||||
|
|
||||||
err = security_kernel_module_from_file(file);
|
err = security_kernel_module_from_file(f.file);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
err = vfs_getattr(&file->f_path, &stat);
|
err = vfs_getattr(&f.file->f_path, &stat);
|
||||||
if (err)
|
if (err)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
@ -2577,7 +2576,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
|
||||||
|
|
||||||
pos = 0;
|
pos = 0;
|
||||||
while (pos < stat.size) {
|
while (pos < stat.size) {
|
||||||
bytes = kernel_read(file, pos, (char *)(info->hdr) + pos,
|
bytes = kernel_read(f.file, pos, (char *)(info->hdr) + pos,
|
||||||
stat.size - pos);
|
stat.size - pos);
|
||||||
if (bytes < 0) {
|
if (bytes < 0) {
|
||||||
vfree(info->hdr);
|
vfree(info->hdr);
|
||||||
|
@ -2591,7 +2590,7 @@ static int copy_module_from_fd(int fd, struct load_info *info)
|
||||||
info->len = pos;
|
info->len = pos;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
fput(file);
|
fdput(f);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue