Merge tag 'v3.10.101' into update
This is the 3.10.101 stable release
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include <linux/efi.h>
|
||||
#include <linux/fs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/mount.h>
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
@@ -108,9 +109,79 @@ out_free:
|
||||
return size;
|
||||
}
|
||||
|
||||
static int
|
||||
efivarfs_ioc_getxflags(struct file *file, void __user *arg)
|
||||
{
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
unsigned int i_flags;
|
||||
unsigned int flags = 0;
|
||||
|
||||
i_flags = inode->i_flags;
|
||||
if (i_flags & S_IMMUTABLE)
|
||||
flags |= FS_IMMUTABLE_FL;
|
||||
|
||||
if (copy_to_user(arg, &flags, sizeof(flags)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
efivarfs_ioc_setxflags(struct file *file, void __user *arg)
|
||||
{
|
||||
struct inode *inode = file->f_mapping->host;
|
||||
unsigned int flags;
|
||||
unsigned int i_flags = 0;
|
||||
int error;
|
||||
|
||||
if (!inode_owner_or_capable(inode))
|
||||
return -EACCES;
|
||||
|
||||
if (copy_from_user(&flags, arg, sizeof(flags)))
|
||||
return -EFAULT;
|
||||
|
||||
if (flags & ~FS_IMMUTABLE_FL)
|
||||
return -EOPNOTSUPP;
|
||||
|
||||
if (!capable(CAP_LINUX_IMMUTABLE))
|
||||
return -EPERM;
|
||||
|
||||
if (flags & FS_IMMUTABLE_FL)
|
||||
i_flags |= S_IMMUTABLE;
|
||||
|
||||
|
||||
error = mnt_want_write_file(file);
|
||||
if (error)
|
||||
return error;
|
||||
|
||||
mutex_lock(&inode->i_mutex);
|
||||
inode->i_flags &= ~S_IMMUTABLE;
|
||||
inode->i_flags |= i_flags;
|
||||
mutex_unlock(&inode->i_mutex);
|
||||
|
||||
mnt_drop_write_file(file);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
long
|
||||
efivarfs_file_ioctl(struct file *file, unsigned int cmd, unsigned long p)
|
||||
{
|
||||
void __user *arg = (void __user *)p;
|
||||
|
||||
switch (cmd) {
|
||||
case FS_IOC_GETFLAGS:
|
||||
return efivarfs_ioc_getxflags(file, arg);
|
||||
case FS_IOC_SETFLAGS:
|
||||
return efivarfs_ioc_setxflags(file, arg);
|
||||
}
|
||||
|
||||
return -ENOTTY;
|
||||
}
|
||||
|
||||
const struct file_operations efivarfs_file_operations = {
|
||||
.open = simple_open,
|
||||
.read = efivarfs_file_read,
|
||||
.write = efivarfs_file_write,
|
||||
.llseek = no_llseek,
|
||||
.unlocked_ioctl = efivarfs_file_ioctl,
|
||||
};
|
||||
|
||||
+19
-11
@@ -15,7 +15,8 @@
|
||||
#include "internal.h"
|
||||
|
||||
struct inode *efivarfs_get_inode(struct super_block *sb,
|
||||
const struct inode *dir, int mode, dev_t dev)
|
||||
const struct inode *dir, int mode,
|
||||
dev_t dev, bool is_removable)
|
||||
{
|
||||
struct inode *inode = new_inode(sb);
|
||||
|
||||
@@ -23,6 +24,7 @@ struct inode *efivarfs_get_inode(struct super_block *sb,
|
||||
inode->i_ino = get_next_ino();
|
||||
inode->i_mode = mode;
|
||||
inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME;
|
||||
inode->i_flags = is_removable ? 0 : S_IMMUTABLE;
|
||||
switch (mode & S_IFMT) {
|
||||
case S_IFREG:
|
||||
inode->i_fop = &efivarfs_file_operations;
|
||||
@@ -102,22 +104,17 @@ static void efivarfs_hex_to_guid(const char *str, efi_guid_t *guid)
|
||||
static int efivarfs_create(struct inode *dir, struct dentry *dentry,
|
||||
umode_t mode, bool excl)
|
||||
{
|
||||
struct inode *inode;
|
||||
struct inode *inode = NULL;
|
||||
struct efivar_entry *var;
|
||||
int namelen, i = 0, err = 0;
|
||||
bool is_removable = false;
|
||||
|
||||
if (!efivarfs_valid_name(dentry->d_name.name, dentry->d_name.len))
|
||||
return -EINVAL;
|
||||
|
||||
inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
|
||||
var = kzalloc(sizeof(struct efivar_entry), GFP_KERNEL);
|
||||
if (!var) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
if (!var)
|
||||
return -ENOMEM;
|
||||
|
||||
/* length of the variable name itself: remove GUID and separator */
|
||||
namelen = dentry->d_name.len - EFI_VARIABLE_GUID_LEN - 1;
|
||||
@@ -125,6 +122,16 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
|
||||
efivarfs_hex_to_guid(dentry->d_name.name + namelen + 1,
|
||||
&var->var.VendorGuid);
|
||||
|
||||
if (efivar_variable_is_removable(var->var.VendorGuid,
|
||||
dentry->d_name.name, namelen))
|
||||
is_removable = true;
|
||||
|
||||
inode = efivarfs_get_inode(dir->i_sb, dir, mode, 0, is_removable);
|
||||
if (!inode) {
|
||||
err = -ENOMEM;
|
||||
goto out;
|
||||
}
|
||||
|
||||
for (i = 0; i < namelen; i++)
|
||||
var->var.VariableName[i] = dentry->d_name.name[i];
|
||||
|
||||
@@ -138,7 +145,8 @@ static int efivarfs_create(struct inode *dir, struct dentry *dentry,
|
||||
out:
|
||||
if (err) {
|
||||
kfree(var);
|
||||
iput(inode);
|
||||
if (inode)
|
||||
iput(inode);
|
||||
}
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -15,7 +15,8 @@ extern const struct file_operations efivarfs_file_operations;
|
||||
extern const struct inode_operations efivarfs_dir_inode_operations;
|
||||
extern bool efivarfs_valid_name(const char *str, int len);
|
||||
extern struct inode *efivarfs_get_inode(struct super_block *sb,
|
||||
const struct inode *dir, int mode, dev_t dev);
|
||||
const struct inode *dir, int mode, dev_t dev,
|
||||
bool is_removable);
|
||||
|
||||
extern struct list_head efivarfs_list;
|
||||
|
||||
|
||||
+10
-6
@@ -128,8 +128,9 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
|
||||
struct dentry *dentry, *root = sb->s_root;
|
||||
unsigned long size = 0;
|
||||
char *name;
|
||||
int len, i;
|
||||
int len;
|
||||
int err = -ENOMEM;
|
||||
bool is_removable = false;
|
||||
|
||||
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
|
||||
if (!entry)
|
||||
@@ -138,15 +139,17 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
|
||||
memcpy(entry->var.VariableName, name16, name_size);
|
||||
memcpy(&(entry->var.VendorGuid), &vendor, sizeof(efi_guid_t));
|
||||
|
||||
len = ucs2_strlen(entry->var.VariableName);
|
||||
len = ucs2_utf8size(entry->var.VariableName);
|
||||
|
||||
/* name, plus '-', plus GUID, plus NUL*/
|
||||
name = kmalloc(len + 1 + EFI_VARIABLE_GUID_LEN + 1, GFP_KERNEL);
|
||||
if (!name)
|
||||
goto fail;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
name[i] = entry->var.VariableName[i] & 0xFF;
|
||||
ucs2_as_utf8(name, entry->var.VariableName, len);
|
||||
|
||||
if (efivar_variable_is_removable(entry->var.VendorGuid, name, len))
|
||||
is_removable = true;
|
||||
|
||||
name[len] = '-';
|
||||
|
||||
@@ -154,7 +157,8 @@ static int efivarfs_callback(efi_char16_t *name16, efi_guid_t vendor,
|
||||
|
||||
name[len + EFI_VARIABLE_GUID_LEN+1] = '\0';
|
||||
|
||||
inode = efivarfs_get_inode(sb, root->d_inode, S_IFREG | 0644, 0);
|
||||
inode = efivarfs_get_inode(sb, root->d_inode, S_IFREG | 0644, 0,
|
||||
is_removable);
|
||||
if (!inode)
|
||||
goto fail_name;
|
||||
|
||||
@@ -210,7 +214,7 @@ static int efivarfs_fill_super(struct super_block *sb, void *data, int silent)
|
||||
sb->s_d_op = &efivarfs_d_ops;
|
||||
sb->s_time_gran = 1;
|
||||
|
||||
inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0);
|
||||
inode = efivarfs_get_inode(sb, NULL, S_IFDIR | 0755, 0, true);
|
||||
if (!inode)
|
||||
return -ENOMEM;
|
||||
inode->i_op = &efivarfs_dir_inode_operations;
|
||||
|
||||
Reference in New Issue
Block a user