diff options
author | Amir Goldstein <amir73il@gmail.com> | 2023-04-03 11:51:47 +0300 |
---|---|---|
committer | Amir Goldstein <amir73il@gmail.com> | 2023-06-19 14:01:13 +0300 |
commit | 5522c9c7cbd2ab4e886fa1c70896f0bdd483ce0b (patch) | |
tree | 6b93018913ace4c4d3c1d49768c4a3b4d72fe315 /fs/overlayfs/ovl_entry.h | |
parent | a6ff2bc0be179eea72832b5396481a08ccd22d5a (diff) |
ovl: use ovl_numlower() and ovl_lowerstack() accessors
This helps fortify against dereferencing a NULL ovl_entry,
before we move the ovl_entry reference into ovl_inode.
Reviewed-by: Alexander Larsson <alexl@redhat.com>
Signed-off-by: Amir Goldstein <amir73il@gmail.com>
Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
Diffstat (limited to 'fs/overlayfs/ovl_entry.h')
-rw-r--r-- | fs/overlayfs/ovl_entry.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/fs/overlayfs/ovl_entry.h b/fs/overlayfs/ovl_entry.h index 4c7312126b3b..0e009fa39d54 100644 --- a/fs/overlayfs/ovl_entry.h +++ b/fs/overlayfs/ovl_entry.h @@ -113,10 +113,20 @@ struct ovl_entry { }; struct rcu_head rcu; }; - unsigned numlower; - struct ovl_path lowerstack[]; + unsigned int __numlower; + struct ovl_path __lowerstack[]; }; +static inline unsigned int ovl_numlower(struct ovl_entry *oe) +{ + return oe ? oe->__numlower : 0; +} + +static inline struct ovl_path *ovl_lowerstack(struct ovl_entry *oe) +{ + return ovl_numlower(oe) ? oe->__lowerstack : NULL; +} + struct ovl_entry *ovl_alloc_entry(unsigned int numlower); static inline struct ovl_entry *OVL_E(struct dentry *dentry) |