diff options
author | Stijn Tintel <stijn@linux-ipv6.be> | 2021-05-13 23:08:47 +0300 |
---|---|---|
committer | Stijn Tintel <stijn@linux-ipv6.be> | 2021-05-24 15:49:29 +0300 |
commit | 969a1a2d5c581d958ce5da37e827ed2217aac17a (patch) | |
tree | 3f3a82d33db86deffdce0ec8d6107a8c40b745e7 | |
parent | 84714a6d7d23dae56457a8300a52bd44bcea592e (diff) |
bcachefs: avoid out-of-bounds in split_devs
Calling mount with an empty source string causes an out-of-bounds error
in split_devs. Check the length of the source string to avoid this.
Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
-rw-r--r-- | fs/bcachefs/fs.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/fs/bcachefs/fs.c b/fs/bcachefs/fs.c index 3161760050c9..6f1512176c4d 100644 --- a/fs/bcachefs/fs.c +++ b/fs/bcachefs/fs.c @@ -30,6 +30,7 @@ #include <linux/posix_acl.h> #include <linux/random.h> #include <linux/statfs.h> +#include <linux/string.h> #include <linux/xattr.h> static struct kmem_cache *bch2_inode_cache; @@ -1310,6 +1311,9 @@ static char **split_devs(const char *_dev_name, unsigned *nr) char *dev_name = NULL, **devs = NULL, *s; size_t i, nr_devs = 0; + if (strlen(_dev_name) == 0) + return NULL; + dev_name = kstrdup(_dev_name, GFP_KERNEL); if (!dev_name) return NULL; |