From: Yu Kuai yukuai3@huawei.com
hulk inclusion category: feature bugzilla: https://gitee.com/openeuler/kernel/issues/IB5UKT
--------------------------------
Currently cookie is combined with:
csum + acc + key
For 'key', if it contains space, then cachefiles_cook_key() will generate new charmap to replace the ascii directly. However, from mainline this is only used for data cookie, and volume is always use ascii directly.
Hence is new_location is set, use ascii directly for volume cookie to keep cachefile location the same as mainline.
Signed-off-by: Yu Kuai yukuai3@huawei.com Signed-off-by: Baokun Li libaokun1@huawei.com --- fs/cachefiles/interface.c | 2 +- fs/cachefiles/internal.h | 3 ++- fs/cachefiles/key.c | 11 ++++++++--- 3 files changed, 11 insertions(+), 5 deletions(-)
diff --git a/fs/cachefiles/interface.c b/fs/cachefiles/interface.c index 5eedd6382737..a13089d06e16 100644 --- a/fs/cachefiles/interface.c +++ b/fs/cachefiles/interface.c @@ -77,7 +77,7 @@ static struct fscache_object *cachefiles_alloc_object( ((char *)buffer)[keylen + 4] = 0;
/* turn the raw key into something that can work with as a filename */ - key = cachefiles_cook_key(buffer, keylen + 2, object->type); + key = cachefiles_cook_key(object, buffer, keylen + 2); if (!key) goto nomem_key;
diff --git a/fs/cachefiles/internal.h b/fs/cachefiles/internal.h index f975042c1658..510a895efe7a 100644 --- a/fs/cachefiles/internal.h +++ b/fs/cachefiles/internal.h @@ -195,7 +195,8 @@ extern const struct fscache_cache_ops cachefiles_cache_ops; /* * key.c */ -extern char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type); +extern char *cachefiles_cook_key(struct cachefiles_object *object, + const u8 *raw, int keylen);
/* * namei.c diff --git a/fs/cachefiles/key.c b/fs/cachefiles/key.c index 1e2f840dabaa..f94847a44ab5 100644 --- a/fs/cachefiles/key.c +++ b/fs/cachefiles/key.c @@ -50,19 +50,24 @@ static int cachefiles_cook_csum(const u8 *raw, int keylen, char *key) * cooked * - need to cut the cooked key into 252 char lengths (189 raw bytes) */ -char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type) +char *cachefiles_cook_key(struct cachefiles_object *object, + const u8 *raw, int keylen) { unsigned int acc; char *key; int loop, len, max, seg, mark, print; + uint8_t type = object->type; + struct fscache_cookie *cookie = object->fscache.cookie;
_enter(",%d", keylen);
BUG_ON(keylen < 2 || keylen > 514);
print = 1; - for (loop = 2; loop < keylen; loop++) - print &= cachefiles_filecharmap[raw[loop]]; + if (!volume_new_location(cookie)) { + for (loop = 2; loop < keylen; loop++) + print &= cachefiles_filecharmap[raw[loop]]; + }
if (print) { /* if the path is usable ASCII, then we render it directly */