Skip to content

Commit 0000ff2

Browse files
committed
Merge tag 'exportfs-6.9' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/cel/linux
Merge exportfs fixes from Chuck Lever: * tag 'exportfs-6.9' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/cel/linux: fs: Create a generic is_dot_dotdot() utility exportfs: fix the fallback implementation of the get_name export operation Link: https://lore.kernel.org/r/BDC2AEB4-7085-4A7C-8DE8-A659FE1DBA6A@oracle.com Signed-off-by: Christian Brauner <brauner@kernel.org>
2 parents bd46543 + 42c3732 commit 0000ff2

File tree

6 files changed

+15
-33
lines changed

6 files changed

+15
-33
lines changed

fs/crypto/fname.c

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,7 @@ struct fscrypt_nokey_name {
7474

7575
static inline bool fscrypt_is_dot_dotdot(const struct qstr *str)
7676
{
77-
if (str->len == 1 && str->name[0] == '.')
78-
return true;
79-
80-
if (str->len == 2 && str->name[0] == '.' && str->name[1] == '.')
81-
return true;
82-
83-
return false;
77+
return is_dot_dotdot(str->name, str->len);
8478
}
8579

8680
/**

fs/ecryptfs/crypto.c

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1949,16 +1949,6 @@ int ecryptfs_encrypt_and_encode_filename(
19491949
return rc;
19501950
}
19511951

1952-
static bool is_dot_dotdot(const char *name, size_t name_size)
1953-
{
1954-
if (name_size == 1 && name[0] == '.')
1955-
return true;
1956-
else if (name_size == 2 && name[0] == '.' && name[1] == '.')
1957-
return true;
1958-
1959-
return false;
1960-
}
1961-
19621952
/**
19631953
* ecryptfs_decode_and_decrypt_filename - converts the encoded cipher text name to decoded plaintext
19641954
* @plaintext_name: The plaintext name

fs/exportfs/expfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@ static bool filldir_one(struct dir_context *ctx, const char *name, int len,
255255
container_of(ctx, struct getdents_callback, ctx);
256256

257257
buf->sequence++;
258-
if (buf->ino == ino && len <= NAME_MAX) {
258+
if (buf->ino == ino && len <= NAME_MAX && !is_dot_dotdot(name, len)) {
259259
memcpy(buf->name, name, len);
260260
buf->name[len] = '\0';
261261
buf->found = 1;

fs/f2fs/f2fs.h

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3364,17 +3364,6 @@ static inline bool f2fs_cp_error(struct f2fs_sb_info *sbi)
33643364
return is_set_ckpt_flags(sbi, CP_ERROR_FLAG);
33653365
}
33663366

3367-
static inline bool is_dot_dotdot(const u8 *name, size_t len)
3368-
{
3369-
if (len == 1 && name[0] == '.')
3370-
return true;
3371-
3372-
if (len == 2 && name[0] == '.' && name[1] == '.')
3373-
return true;
3374-
3375-
return false;
3376-
}
3377-
33783367
static inline void *f2fs_kmalloc(struct f2fs_sb_info *sbi,
33793368
size_t size, gfp_t flags)
33803369
{

fs/namei.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2676,10 +2676,8 @@ static int lookup_one_common(struct mnt_idmap *idmap,
26762676
if (!len)
26772677
return -EACCES;
26782678

2679-
if (unlikely(name[0] == '.')) {
2680-
if (len < 2 || (len == 2 && name[1] == '.'))
2681-
return -EACCES;
2682-
}
2679+
if (is_dot_dotdot(name, len))
2680+
return -EACCES;
26832681

26842682
while (len--) {
26852683
unsigned int c = *(const unsigned char *)name++;

include/linux/fs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2928,6 +2928,17 @@ extern bool path_is_under(const struct path *, const struct path *);
29282928

29292929
extern char *file_path(struct file *, char *, int);
29302930

2931+
/**
2932+
* is_dot_dotdot - returns true only if @name is "." or ".."
2933+
* @name: file name to check
2934+
* @len: length of file name, in bytes
2935+
*/
2936+
static inline bool is_dot_dotdot(const char *name, size_t len)
2937+
{
2938+
return len && unlikely(name[0] == '.') &&
2939+
(len == 1 || (len == 2 && name[1] == '.'));
2940+
}
2941+
29312942
#include <linux/err.h>
29322943

29332944
/* needed for stackable file system support */

0 commit comments

Comments
 (0)