Commit 51518aa6 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'fsverity-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt

Pull fsverity updates from Eric Biggers:
 "A couple small cleanups for fs/verity/"

* tag 'fsverity-for-linus' of git://git.kernel.org/pub/scm/fs/fscrypt/fscrypt:
  fs-verity: Use struct_size() helper in enable_verity()
  fs-verity: remove unused parameter desc_size in fsverity_create_info()
parents c1f4cfdb e6af1bb0
...@@ -202,7 +202,7 @@ static int enable_verity(struct file *filp, ...@@ -202,7 +202,7 @@ static int enable_verity(struct file *filp,
const struct fsverity_operations *vops = inode->i_sb->s_vop; const struct fsverity_operations *vops = inode->i_sb->s_vop;
struct merkle_tree_params params = { }; struct merkle_tree_params params = { };
struct fsverity_descriptor *desc; struct fsverity_descriptor *desc;
size_t desc_size = sizeof(*desc) + arg->sig_size; size_t desc_size = struct_size(desc, signature, arg->sig_size);
struct fsverity_info *vi; struct fsverity_info *vi;
int err; int err;
...@@ -281,7 +281,7 @@ static int enable_verity(struct file *filp, ...@@ -281,7 +281,7 @@ static int enable_verity(struct file *filp,
* from disk. This is simpler, and it serves as an extra check that the * from disk. This is simpler, and it serves as an extra check that the
* metadata we're writing is valid before actually enabling verity. * metadata we're writing is valid before actually enabling verity.
*/ */
vi = fsverity_create_info(inode, desc, desc_size); vi = fsverity_create_info(inode, desc);
if (IS_ERR(vi)) { if (IS_ERR(vi)) {
err = PTR_ERR(vi); err = PTR_ERR(vi);
goto rollback; goto rollback;
......
...@@ -122,16 +122,14 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params, ...@@ -122,16 +122,14 @@ int fsverity_init_merkle_tree_params(struct merkle_tree_params *params,
const u8 *salt, size_t salt_size); const u8 *salt, size_t salt_size);
struct fsverity_info *fsverity_create_info(const struct inode *inode, struct fsverity_info *fsverity_create_info(const struct inode *inode,
struct fsverity_descriptor *desc, struct fsverity_descriptor *desc);
size_t desc_size);
void fsverity_set_info(struct inode *inode, struct fsverity_info *vi); void fsverity_set_info(struct inode *inode, struct fsverity_info *vi);
void fsverity_free_info(struct fsverity_info *vi); void fsverity_free_info(struct fsverity_info *vi);
int fsverity_get_descriptor(struct inode *inode, int fsverity_get_descriptor(struct inode *inode,
struct fsverity_descriptor **desc_ret, struct fsverity_descriptor **desc_ret);
size_t *desc_size_ret);
int __init fsverity_init_info_cache(void); int __init fsverity_init_info_cache(void);
void __init fsverity_exit_info_cache(void); void __init fsverity_exit_info_cache(void);
......
...@@ -147,8 +147,7 @@ static int compute_file_digest(struct fsverity_hash_alg *hash_alg, ...@@ -147,8 +147,7 @@ static int compute_file_digest(struct fsverity_hash_alg *hash_alg,
* fsverity_descriptor must have already undergone basic validation. * fsverity_descriptor must have already undergone basic validation.
*/ */
struct fsverity_info *fsverity_create_info(const struct inode *inode, struct fsverity_info *fsverity_create_info(const struct inode *inode,
struct fsverity_descriptor *desc, struct fsverity_descriptor *desc)
size_t desc_size)
{ {
struct fsverity_info *vi; struct fsverity_info *vi;
int err; int err;
...@@ -264,8 +263,7 @@ static bool validate_fsverity_descriptor(struct inode *inode, ...@@ -264,8 +263,7 @@ static bool validate_fsverity_descriptor(struct inode *inode,
* the filesystem, and do basic validation of it. * the filesystem, and do basic validation of it.
*/ */
int fsverity_get_descriptor(struct inode *inode, int fsverity_get_descriptor(struct inode *inode,
struct fsverity_descriptor **desc_ret, struct fsverity_descriptor **desc_ret)
size_t *desc_size_ret)
{ {
int res; int res;
struct fsverity_descriptor *desc; struct fsverity_descriptor *desc;
...@@ -297,7 +295,6 @@ int fsverity_get_descriptor(struct inode *inode, ...@@ -297,7 +295,6 @@ int fsverity_get_descriptor(struct inode *inode,
} }
*desc_ret = desc; *desc_ret = desc;
*desc_size_ret = res;
return 0; return 0;
} }
...@@ -306,17 +303,16 @@ static int ensure_verity_info(struct inode *inode) ...@@ -306,17 +303,16 @@ static int ensure_verity_info(struct inode *inode)
{ {
struct fsverity_info *vi = fsverity_get_info(inode); struct fsverity_info *vi = fsverity_get_info(inode);
struct fsverity_descriptor *desc; struct fsverity_descriptor *desc;
size_t desc_size;
int err; int err;
if (vi) if (vi)
return 0; return 0;
err = fsverity_get_descriptor(inode, &desc, &desc_size); err = fsverity_get_descriptor(inode, &desc);
if (err) if (err)
return err; return err;
vi = fsverity_create_info(inode, desc, desc_size); vi = fsverity_create_info(inode, desc);
if (IS_ERR(vi)) { if (IS_ERR(vi)) {
err = PTR_ERR(vi); err = PTR_ERR(vi);
goto out_free_desc; goto out_free_desc;
......
...@@ -101,7 +101,7 @@ static int fsverity_read_descriptor(struct inode *inode, ...@@ -101,7 +101,7 @@ static int fsverity_read_descriptor(struct inode *inode,
size_t desc_size; size_t desc_size;
int res; int res;
res = fsverity_get_descriptor(inode, &desc, &desc_size); res = fsverity_get_descriptor(inode, &desc);
if (res) if (res)
return res; return res;
...@@ -119,10 +119,9 @@ static int fsverity_read_signature(struct inode *inode, ...@@ -119,10 +119,9 @@ static int fsverity_read_signature(struct inode *inode,
void __user *buf, u64 offset, int length) void __user *buf, u64 offset, int length)
{ {
struct fsverity_descriptor *desc; struct fsverity_descriptor *desc;
size_t desc_size;
int res; int res;
res = fsverity_get_descriptor(inode, &desc, &desc_size); res = fsverity_get_descriptor(inode, &desc);
if (res) if (res)
return res; return res;
......
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