mirror of
https://github.com/Fishwaldo/Star64_linux.git
synced 2025-07-23 07:12:09 +00:00
kernfs: fix xattr name handling in LSM helpers
The implementation of kernfs_security_xattr_*() helpers reuses the kernfs_node_xattr_*() functions, which take the suffix of the xattr name and extract full xattr name from it using xattr_full_name(). However, this function relies on the fact that the suffix passed to xattr handlers from VFS is always constructed from the full name by just incerementing the pointer. This doesn't necessarily hold for the callers of kernfs_security_xattr_*(), so their usage will easily lead to out-of-bounds access. Fix this by moving the xattr name reconstruction to the VFS xattr handlers and replacing the kernfs_security_xattr_*() helpers with more general kernfs_xattr_*() helpers that take full xattr name and allow accessing all kernfs node's xattrs. Reported-by: kernel test robot <rong.a.chen@intel.com> Fixes:b230d5aba2
("LSM: add new hook for kernfs node initialization") Fixes:ec882da5cd
("selinux: implement the kernfs_init_security hook") Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
593854c052
commit
1537ad15c9
3 changed files with 33 additions and 56 deletions
|
@ -371,10 +371,10 @@ __poll_t kernfs_generic_poll(struct kernfs_open_file *of,
|
|||
struct poll_table_struct *pt);
|
||||
void kernfs_notify(struct kernfs_node *kn);
|
||||
|
||||
int kernfs_security_xattr_get(struct kernfs_node *kn, const char *suffix,
|
||||
void *value, size_t size);
|
||||
int kernfs_security_xattr_set(struct kernfs_node *kn, const char *suffix,
|
||||
void *value, size_t size, int flags);
|
||||
int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
|
||||
void *value, size_t size);
|
||||
int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
|
||||
const void *value, size_t size, int flags);
|
||||
|
||||
const void *kernfs_super_ns(struct super_block *sb);
|
||||
int kernfs_get_tree(struct fs_context *fc);
|
||||
|
@ -478,14 +478,12 @@ static inline int kernfs_setattr(struct kernfs_node *kn,
|
|||
|
||||
static inline void kernfs_notify(struct kernfs_node *kn) { }
|
||||
|
||||
static inline int kernfs_security_xattr_get(struct kernfs_node *kn,
|
||||
const char *suffix, void *value,
|
||||
size_t size)
|
||||
static inline int kernfs_xattr_get(struct kernfs_node *kn, const char *name,
|
||||
void *value, size_t size)
|
||||
{ return -ENOSYS; }
|
||||
|
||||
static inline int kernfs_security_xattr_set(struct kernfs_node *kn,
|
||||
const char *suffix, void *value,
|
||||
size_t size, int flags)
|
||||
static inline int kernfs_xattr_set(struct kernfs_node *kn, const char *name,
|
||||
const void *value, size_t size, int flags)
|
||||
{ return -ENOSYS; }
|
||||
|
||||
static inline const void *kernfs_super_ns(struct super_block *sb)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue