All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild@lists.01.org
Subject: Re: [PATCH] cachefiles: do not yet allow on idmapped mounts
Date: Wed, 17 Mar 2021 17:25:11 +0300	[thread overview]
Message-ID: <20210317142511.GB2087@kadam> (raw)
In-Reply-To: <20210316112257.2974212-1-christian.brauner@ubuntu.com>

[-- Attachment #1: Type: text/plain, Size: 14952 bytes --]

Hi Christian,

url:    https://github.com/0day-ci/linux/commits/Christian-Brauner/cachefiles-do-not-yet-allow-on-idmapped-mounts/20210316-192557
base:   1e28eed17697bcf343c6743f0028cc3b5dd88bf0
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/cachefiles/bind.c:247 cachefiles_daemon_add_cache() error: uninitialized symbol 'root'.

vim +/root +247 fs/cachefiles/bind.c

9ae326a69004de David Howells        2009-04-03   81  static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
9ae326a69004de David Howells        2009-04-03   82  {
9ae326a69004de David Howells        2009-04-03   83  	struct cachefiles_object *fsdef;
b0446be4be4476 Al Viro              2009-08-09   84  	struct path path;
9ae326a69004de David Howells        2009-04-03   85  	struct kstatfs stats;
9ae326a69004de David Howells        2009-04-03   86  	struct dentry *graveyard, *cachedir, *root;
9ae326a69004de David Howells        2009-04-03   87  	const struct cred *saved_cred;
9ae326a69004de David Howells        2009-04-03   88  	int ret;
9ae326a69004de David Howells        2009-04-03   89  
9ae326a69004de David Howells        2009-04-03   90  	_enter("");
9ae326a69004de David Howells        2009-04-03   91  
9ae326a69004de David Howells        2009-04-03   92  	/* we want to work under the module's security ID */
9ae326a69004de David Howells        2009-04-03   93  	ret = cachefiles_get_security_ID(cache);
9ae326a69004de David Howells        2009-04-03   94  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03   95  		return ret;
9ae326a69004de David Howells        2009-04-03   96  
9ae326a69004de David Howells        2009-04-03   97  	cachefiles_begin_secure(cache, &saved_cred);
9ae326a69004de David Howells        2009-04-03   98  
9ae326a69004de David Howells        2009-04-03   99  	/* allocate the root index object */
9ae326a69004de David Howells        2009-04-03  100  	ret = -ENOMEM;
9ae326a69004de David Howells        2009-04-03  101  
9ae326a69004de David Howells        2009-04-03  102  	fsdef = kmem_cache_alloc(cachefiles_object_jar, GFP_KERNEL);
9ae326a69004de David Howells        2009-04-03  103  	if (!fsdef)
9ae326a69004de David Howells        2009-04-03  104  		goto error_root_object;
9ae326a69004de David Howells        2009-04-03  105  
9ae326a69004de David Howells        2009-04-03  106  	ASSERTCMP(fsdef->backer, ==, NULL);
9ae326a69004de David Howells        2009-04-03  107  
9ae326a69004de David Howells        2009-04-03  108  	atomic_set(&fsdef->usage, 1);
9ae326a69004de David Howells        2009-04-03  109  	fsdef->type = FSCACHE_COOKIE_TYPE_INDEX;
9ae326a69004de David Howells        2009-04-03  110  
9ae326a69004de David Howells        2009-04-03  111  	_debug("- fsdef %p", fsdef);
9ae326a69004de David Howells        2009-04-03  112  
9ae326a69004de David Howells        2009-04-03  113  	/* look up the directory at the root of the cache */
b0446be4be4476 Al Viro              2009-08-09  114  	ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
9ae326a69004de David Howells        2009-04-03  115  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  116  		goto error_open_root;
9ae326a69004de David Howells        2009-04-03  117  
b2653f9eca0ed7 Christian Brauner    2021-03-16  118  	ret = -EINVAL;
b2653f9eca0ed7 Christian Brauner    2021-03-16  119  	if (mnt_user_ns(path.mnt) != &init_user_ns)
b2653f9eca0ed7 Christian Brauner    2021-03-16  120  		goto error_unsupported;
                                                                ^^^^^^^^^^^^^^^^^^^^^^^
Needs to be moved after we initialize root.

b2653f9eca0ed7 Christian Brauner    2021-03-16  121  
b0446be4be4476 Al Viro              2009-08-09  122  	cache->mnt = path.mnt;
b0446be4be4476 Al Viro              2009-08-09  123  	root = path.dentry;
                                                        ^^^^^^^^^^^^^^^^^^
Here

9ae326a69004de David Howells        2009-04-03  124  
9ae326a69004de David Howells        2009-04-03  125  	/* check parameters */
9ae326a69004de David Howells        2009-04-03  126  	ret = -EOPNOTSUPP;
466b77bc954c23 David Howells        2015-03-17  127  	if (d_is_negative(root) ||
466b77bc954c23 David Howells        2015-03-17  128  	    !d_backing_inode(root)->i_op->lookup ||
466b77bc954c23 David Howells        2015-03-17  129  	    !d_backing_inode(root)->i_op->mkdir ||
5d6c31910bc071 Andreas Gruenbacher  2016-09-29  130  	    !(d_backing_inode(root)->i_opflags & IOP_XATTR) ||
9ae326a69004de David Howells        2009-04-03  131  	    !root->d_sb->s_op->statfs ||
9ae326a69004de David Howells        2009-04-03  132  	    !root->d_sb->s_op->sync_fs)
9ae326a69004de David Howells        2009-04-03  133  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  134  
9ae326a69004de David Howells        2009-04-03  135  	ret = -EROFS;
bc98a42c1f7d0f David Howells        2017-07-17  136  	if (sb_rdonly(root->d_sb))
9ae326a69004de David Howells        2009-04-03  137  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  138  
9ae326a69004de David Howells        2009-04-03  139  	/* determine the security of the on-disk cache as this governs
9ae326a69004de David Howells        2009-04-03  140  	 * security ID of files we create */
9ae326a69004de David Howells        2009-04-03  141  	ret = cachefiles_determine_cache_security(cache, root, &saved_cred);
9ae326a69004de David Howells        2009-04-03  142  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  143  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  144  
9ae326a69004de David Howells        2009-04-03  145  	/* get the cache size and blocksize */
ebabe9a9001af0 Christoph Hellwig    2010-07-07  146  	ret = vfs_statfs(&path, &stats);
9ae326a69004de David Howells        2009-04-03  147  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  148  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  149  
9ae326a69004de David Howells        2009-04-03  150  	ret = -ERANGE;
9ae326a69004de David Howells        2009-04-03  151  	if (stats.f_bsize <= 0)
9ae326a69004de David Howells        2009-04-03  152  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  153  
9ae326a69004de David Howells        2009-04-03  154  	ret = -EOPNOTSUPP;
9ae326a69004de David Howells        2009-04-03  155  	if (stats.f_bsize > PAGE_SIZE)
9ae326a69004de David Howells        2009-04-03  156  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  157  
9ae326a69004de David Howells        2009-04-03  158  	cache->bsize = stats.f_bsize;
9ae326a69004de David Howells        2009-04-03  159  	cache->bshift = 0;
9ae326a69004de David Howells        2009-04-03  160  	if (stats.f_bsize < PAGE_SIZE)
9ae326a69004de David Howells        2009-04-03  161  		cache->bshift = PAGE_SHIFT - ilog2(stats.f_bsize);
9ae326a69004de David Howells        2009-04-03  162  
9ae326a69004de David Howells        2009-04-03  163  	_debug("blksize %u (shift %u)",
9ae326a69004de David Howells        2009-04-03  164  	       cache->bsize, cache->bshift);
9ae326a69004de David Howells        2009-04-03  165  
9ae326a69004de David Howells        2009-04-03  166  	_debug("size %llu, avail %llu",
9ae326a69004de David Howells        2009-04-03  167  	       (unsigned long long) stats.f_blocks,
9ae326a69004de David Howells        2009-04-03  168  	       (unsigned long long) stats.f_bavail);
9ae326a69004de David Howells        2009-04-03  169  
9ae326a69004de David Howells        2009-04-03  170  	/* set up caching limits */
9ae326a69004de David Howells        2009-04-03  171  	do_div(stats.f_files, 100);
9ae326a69004de David Howells        2009-04-03  172  	cache->fstop = stats.f_files * cache->fstop_percent;
9ae326a69004de David Howells        2009-04-03  173  	cache->fcull = stats.f_files * cache->fcull_percent;
9ae326a69004de David Howells        2009-04-03  174  	cache->frun  = stats.f_files * cache->frun_percent;
9ae326a69004de David Howells        2009-04-03  175  
9ae326a69004de David Howells        2009-04-03  176  	_debug("limits {%llu,%llu,%llu} files",
9ae326a69004de David Howells        2009-04-03  177  	       (unsigned long long) cache->frun,
9ae326a69004de David Howells        2009-04-03  178  	       (unsigned long long) cache->fcull,
9ae326a69004de David Howells        2009-04-03  179  	       (unsigned long long) cache->fstop);
9ae326a69004de David Howells        2009-04-03  180  
9ae326a69004de David Howells        2009-04-03  181  	stats.f_blocks >>= cache->bshift;
9ae326a69004de David Howells        2009-04-03  182  	do_div(stats.f_blocks, 100);
9ae326a69004de David Howells        2009-04-03  183  	cache->bstop = stats.f_blocks * cache->bstop_percent;
9ae326a69004de David Howells        2009-04-03  184  	cache->bcull = stats.f_blocks * cache->bcull_percent;
9ae326a69004de David Howells        2009-04-03  185  	cache->brun  = stats.f_blocks * cache->brun_percent;
9ae326a69004de David Howells        2009-04-03  186  
9ae326a69004de David Howells        2009-04-03  187  	_debug("limits {%llu,%llu,%llu} blocks",
9ae326a69004de David Howells        2009-04-03  188  	       (unsigned long long) cache->brun,
9ae326a69004de David Howells        2009-04-03  189  	       (unsigned long long) cache->bcull,
9ae326a69004de David Howells        2009-04-03  190  	       (unsigned long long) cache->bstop);
9ae326a69004de David Howells        2009-04-03  191  
9ae326a69004de David Howells        2009-04-03  192  	/* get the cache directory and check its type */
9ae326a69004de David Howells        2009-04-03  193  	cachedir = cachefiles_get_directory(cache, root, "cache");
9ae326a69004de David Howells        2009-04-03  194  	if (IS_ERR(cachedir)) {
9ae326a69004de David Howells        2009-04-03  195  		ret = PTR_ERR(cachedir);
9ae326a69004de David Howells        2009-04-03  196  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  197  	}
9ae326a69004de David Howells        2009-04-03  198  
9ae326a69004de David Howells        2009-04-03  199  	fsdef->dentry = cachedir;
9ae326a69004de David Howells        2009-04-03  200  	fsdef->fscache.cookie = NULL;
9ae326a69004de David Howells        2009-04-03  201  
9ae326a69004de David Howells        2009-04-03  202  	ret = cachefiles_check_object_type(fsdef);
9ae326a69004de David Howells        2009-04-03  203  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  204  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  205  
9ae326a69004de David Howells        2009-04-03  206  	/* get the graveyard directory */
9ae326a69004de David Howells        2009-04-03  207  	graveyard = cachefiles_get_directory(cache, root, "graveyard");
9ae326a69004de David Howells        2009-04-03  208  	if (IS_ERR(graveyard)) {
9ae326a69004de David Howells        2009-04-03  209  		ret = PTR_ERR(graveyard);
9ae326a69004de David Howells        2009-04-03  210  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  211  	}
9ae326a69004de David Howells        2009-04-03  212  
9ae326a69004de David Howells        2009-04-03  213  	cache->graveyard = graveyard;
9ae326a69004de David Howells        2009-04-03  214  
9ae326a69004de David Howells        2009-04-03  215  	/* publish the cache */
9ae326a69004de David Howells        2009-04-03  216  	fscache_init_cache(&cache->cache,
9ae326a69004de David Howells        2009-04-03  217  			   &cachefiles_cache_ops,
9ae326a69004de David Howells        2009-04-03  218  			   "%s",
9ae326a69004de David Howells        2009-04-03  219  			   fsdef->dentry->d_sb->s_id);
9ae326a69004de David Howells        2009-04-03  220  
f29507ce667010 Kiran Kumar Modukuri 2018-06-21  221  	fscache_object_init(&fsdef->fscache, &fscache_fsdef_index,
f29507ce667010 Kiran Kumar Modukuri 2018-06-21  222  			    &cache->cache);
9ae326a69004de David Howells        2009-04-03  223  
9ae326a69004de David Howells        2009-04-03  224  	ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag);
9ae326a69004de David Howells        2009-04-03  225  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  226  		goto error_add_cache;
9ae326a69004de David Howells        2009-04-03  227  
9ae326a69004de David Howells        2009-04-03  228  	/* done */
9ae326a69004de David Howells        2009-04-03  229  	set_bit(CACHEFILES_READY, &cache->flags);
9ae326a69004de David Howells        2009-04-03  230  	dput(root);
9ae326a69004de David Howells        2009-04-03  231  
0227d6abb37845 Fabian Frederick     2014-06-06  232  	pr_info("File cache on %s registered\n", cache->cache.identifier);
9ae326a69004de David Howells        2009-04-03  233  
9ae326a69004de David Howells        2009-04-03  234  	/* check how much space the cache has */
9ae326a69004de David Howells        2009-04-03  235  	cachefiles_has_space(cache, 0, 0);
9ae326a69004de David Howells        2009-04-03  236  	cachefiles_end_secure(cache, saved_cred);
9ae326a69004de David Howells        2009-04-03  237  	return 0;
9ae326a69004de David Howells        2009-04-03  238  
9ae326a69004de David Howells        2009-04-03  239  error_add_cache:
9ae326a69004de David Howells        2009-04-03  240  	dput(cache->graveyard);
9ae326a69004de David Howells        2009-04-03  241  	cache->graveyard = NULL;
9ae326a69004de David Howells        2009-04-03  242  error_unsupported:
9ae326a69004de David Howells        2009-04-03  243  	mntput(cache->mnt);
9ae326a69004de David Howells        2009-04-03  244  	cache->mnt = NULL;
9ae326a69004de David Howells        2009-04-03  245  	dput(fsdef->dentry);
9ae326a69004de David Howells        2009-04-03  246  	fsdef->dentry = NULL;
9ae326a69004de David Howells        2009-04-03 @247  	dput(root);
                                                        ^^^^^^^^^^

9ae326a69004de David Howells        2009-04-03  248  error_open_root:
9ae326a69004de David Howells        2009-04-03  249  	kmem_cache_free(cachefiles_object_jar, fsdef);
9ae326a69004de David Howells        2009-04-03  250  error_root_object:
9ae326a69004de David Howells        2009-04-03  251  	cachefiles_end_secure(cache, saved_cred);
6ff66ac77aeaa9 Fabian Frederick     2014-09-25  252  	pr_err("Failed to register: %d\n", ret);
9ae326a69004de David Howells        2009-04-03  253  	return ret;
9ae326a69004de David Howells        2009-04-03  254  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34575 bytes --]

WARNING: multiple messages have this Message-ID (diff)
From: Dan Carpenter <dan.carpenter@oracle.com>
To: kbuild-all@lists.01.org
Subject: Re: [PATCH] cachefiles: do not yet allow on idmapped mounts
Date: Wed, 17 Mar 2021 17:25:11 +0300	[thread overview]
Message-ID: <20210317142511.GB2087@kadam> (raw)
In-Reply-To: <20210316112257.2974212-1-christian.brauner@ubuntu.com>

[-- Attachment #1: Type: text/plain, Size: 14952 bytes --]

Hi Christian,

url:    https://github.com/0day-ci/linux/commits/Christian-Brauner/cachefiles-do-not-yet-allow-on-idmapped-mounts/20210316-192557
base:   1e28eed17697bcf343c6743f0028cc3b5dd88bf0
config: x86_64-randconfig-m001-20210317 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

New smatch warnings:
fs/cachefiles/bind.c:247 cachefiles_daemon_add_cache() error: uninitialized symbol 'root'.

vim +/root +247 fs/cachefiles/bind.c

9ae326a69004de David Howells        2009-04-03   81  static int cachefiles_daemon_add_cache(struct cachefiles_cache *cache)
9ae326a69004de David Howells        2009-04-03   82  {
9ae326a69004de David Howells        2009-04-03   83  	struct cachefiles_object *fsdef;
b0446be4be4476 Al Viro              2009-08-09   84  	struct path path;
9ae326a69004de David Howells        2009-04-03   85  	struct kstatfs stats;
9ae326a69004de David Howells        2009-04-03   86  	struct dentry *graveyard, *cachedir, *root;
9ae326a69004de David Howells        2009-04-03   87  	const struct cred *saved_cred;
9ae326a69004de David Howells        2009-04-03   88  	int ret;
9ae326a69004de David Howells        2009-04-03   89  
9ae326a69004de David Howells        2009-04-03   90  	_enter("");
9ae326a69004de David Howells        2009-04-03   91  
9ae326a69004de David Howells        2009-04-03   92  	/* we want to work under the module's security ID */
9ae326a69004de David Howells        2009-04-03   93  	ret = cachefiles_get_security_ID(cache);
9ae326a69004de David Howells        2009-04-03   94  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03   95  		return ret;
9ae326a69004de David Howells        2009-04-03   96  
9ae326a69004de David Howells        2009-04-03   97  	cachefiles_begin_secure(cache, &saved_cred);
9ae326a69004de David Howells        2009-04-03   98  
9ae326a69004de David Howells        2009-04-03   99  	/* allocate the root index object */
9ae326a69004de David Howells        2009-04-03  100  	ret = -ENOMEM;
9ae326a69004de David Howells        2009-04-03  101  
9ae326a69004de David Howells        2009-04-03  102  	fsdef = kmem_cache_alloc(cachefiles_object_jar, GFP_KERNEL);
9ae326a69004de David Howells        2009-04-03  103  	if (!fsdef)
9ae326a69004de David Howells        2009-04-03  104  		goto error_root_object;
9ae326a69004de David Howells        2009-04-03  105  
9ae326a69004de David Howells        2009-04-03  106  	ASSERTCMP(fsdef->backer, ==, NULL);
9ae326a69004de David Howells        2009-04-03  107  
9ae326a69004de David Howells        2009-04-03  108  	atomic_set(&fsdef->usage, 1);
9ae326a69004de David Howells        2009-04-03  109  	fsdef->type = FSCACHE_COOKIE_TYPE_INDEX;
9ae326a69004de David Howells        2009-04-03  110  
9ae326a69004de David Howells        2009-04-03  111  	_debug("- fsdef %p", fsdef);
9ae326a69004de David Howells        2009-04-03  112  
9ae326a69004de David Howells        2009-04-03  113  	/* look up the directory at the root of the cache */
b0446be4be4476 Al Viro              2009-08-09  114  	ret = kern_path(cache->rootdirname, LOOKUP_DIRECTORY, &path);
9ae326a69004de David Howells        2009-04-03  115  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  116  		goto error_open_root;
9ae326a69004de David Howells        2009-04-03  117  
b2653f9eca0ed7 Christian Brauner    2021-03-16  118  	ret = -EINVAL;
b2653f9eca0ed7 Christian Brauner    2021-03-16  119  	if (mnt_user_ns(path.mnt) != &init_user_ns)
b2653f9eca0ed7 Christian Brauner    2021-03-16  120  		goto error_unsupported;
                                                                ^^^^^^^^^^^^^^^^^^^^^^^
Needs to be moved after we initialize root.

b2653f9eca0ed7 Christian Brauner    2021-03-16  121  
b0446be4be4476 Al Viro              2009-08-09  122  	cache->mnt = path.mnt;
b0446be4be4476 Al Viro              2009-08-09  123  	root = path.dentry;
                                                        ^^^^^^^^^^^^^^^^^^
Here

9ae326a69004de David Howells        2009-04-03  124  
9ae326a69004de David Howells        2009-04-03  125  	/* check parameters */
9ae326a69004de David Howells        2009-04-03  126  	ret = -EOPNOTSUPP;
466b77bc954c23 David Howells        2015-03-17  127  	if (d_is_negative(root) ||
466b77bc954c23 David Howells        2015-03-17  128  	    !d_backing_inode(root)->i_op->lookup ||
466b77bc954c23 David Howells        2015-03-17  129  	    !d_backing_inode(root)->i_op->mkdir ||
5d6c31910bc071 Andreas Gruenbacher  2016-09-29  130  	    !(d_backing_inode(root)->i_opflags & IOP_XATTR) ||
9ae326a69004de David Howells        2009-04-03  131  	    !root->d_sb->s_op->statfs ||
9ae326a69004de David Howells        2009-04-03  132  	    !root->d_sb->s_op->sync_fs)
9ae326a69004de David Howells        2009-04-03  133  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  134  
9ae326a69004de David Howells        2009-04-03  135  	ret = -EROFS;
bc98a42c1f7d0f David Howells        2017-07-17  136  	if (sb_rdonly(root->d_sb))
9ae326a69004de David Howells        2009-04-03  137  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  138  
9ae326a69004de David Howells        2009-04-03  139  	/* determine the security of the on-disk cache as this governs
9ae326a69004de David Howells        2009-04-03  140  	 * security ID of files we create */
9ae326a69004de David Howells        2009-04-03  141  	ret = cachefiles_determine_cache_security(cache, root, &saved_cred);
9ae326a69004de David Howells        2009-04-03  142  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  143  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  144  
9ae326a69004de David Howells        2009-04-03  145  	/* get the cache size and blocksize */
ebabe9a9001af0 Christoph Hellwig    2010-07-07  146  	ret = vfs_statfs(&path, &stats);
9ae326a69004de David Howells        2009-04-03  147  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  148  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  149  
9ae326a69004de David Howells        2009-04-03  150  	ret = -ERANGE;
9ae326a69004de David Howells        2009-04-03  151  	if (stats.f_bsize <= 0)
9ae326a69004de David Howells        2009-04-03  152  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  153  
9ae326a69004de David Howells        2009-04-03  154  	ret = -EOPNOTSUPP;
9ae326a69004de David Howells        2009-04-03  155  	if (stats.f_bsize > PAGE_SIZE)
9ae326a69004de David Howells        2009-04-03  156  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  157  
9ae326a69004de David Howells        2009-04-03  158  	cache->bsize = stats.f_bsize;
9ae326a69004de David Howells        2009-04-03  159  	cache->bshift = 0;
9ae326a69004de David Howells        2009-04-03  160  	if (stats.f_bsize < PAGE_SIZE)
9ae326a69004de David Howells        2009-04-03  161  		cache->bshift = PAGE_SHIFT - ilog2(stats.f_bsize);
9ae326a69004de David Howells        2009-04-03  162  
9ae326a69004de David Howells        2009-04-03  163  	_debug("blksize %u (shift %u)",
9ae326a69004de David Howells        2009-04-03  164  	       cache->bsize, cache->bshift);
9ae326a69004de David Howells        2009-04-03  165  
9ae326a69004de David Howells        2009-04-03  166  	_debug("size %llu, avail %llu",
9ae326a69004de David Howells        2009-04-03  167  	       (unsigned long long) stats.f_blocks,
9ae326a69004de David Howells        2009-04-03  168  	       (unsigned long long) stats.f_bavail);
9ae326a69004de David Howells        2009-04-03  169  
9ae326a69004de David Howells        2009-04-03  170  	/* set up caching limits */
9ae326a69004de David Howells        2009-04-03  171  	do_div(stats.f_files, 100);
9ae326a69004de David Howells        2009-04-03  172  	cache->fstop = stats.f_files * cache->fstop_percent;
9ae326a69004de David Howells        2009-04-03  173  	cache->fcull = stats.f_files * cache->fcull_percent;
9ae326a69004de David Howells        2009-04-03  174  	cache->frun  = stats.f_files * cache->frun_percent;
9ae326a69004de David Howells        2009-04-03  175  
9ae326a69004de David Howells        2009-04-03  176  	_debug("limits {%llu,%llu,%llu} files",
9ae326a69004de David Howells        2009-04-03  177  	       (unsigned long long) cache->frun,
9ae326a69004de David Howells        2009-04-03  178  	       (unsigned long long) cache->fcull,
9ae326a69004de David Howells        2009-04-03  179  	       (unsigned long long) cache->fstop);
9ae326a69004de David Howells        2009-04-03  180  
9ae326a69004de David Howells        2009-04-03  181  	stats.f_blocks >>= cache->bshift;
9ae326a69004de David Howells        2009-04-03  182  	do_div(stats.f_blocks, 100);
9ae326a69004de David Howells        2009-04-03  183  	cache->bstop = stats.f_blocks * cache->bstop_percent;
9ae326a69004de David Howells        2009-04-03  184  	cache->bcull = stats.f_blocks * cache->bcull_percent;
9ae326a69004de David Howells        2009-04-03  185  	cache->brun  = stats.f_blocks * cache->brun_percent;
9ae326a69004de David Howells        2009-04-03  186  
9ae326a69004de David Howells        2009-04-03  187  	_debug("limits {%llu,%llu,%llu} blocks",
9ae326a69004de David Howells        2009-04-03  188  	       (unsigned long long) cache->brun,
9ae326a69004de David Howells        2009-04-03  189  	       (unsigned long long) cache->bcull,
9ae326a69004de David Howells        2009-04-03  190  	       (unsigned long long) cache->bstop);
9ae326a69004de David Howells        2009-04-03  191  
9ae326a69004de David Howells        2009-04-03  192  	/* get the cache directory and check its type */
9ae326a69004de David Howells        2009-04-03  193  	cachedir = cachefiles_get_directory(cache, root, "cache");
9ae326a69004de David Howells        2009-04-03  194  	if (IS_ERR(cachedir)) {
9ae326a69004de David Howells        2009-04-03  195  		ret = PTR_ERR(cachedir);
9ae326a69004de David Howells        2009-04-03  196  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  197  	}
9ae326a69004de David Howells        2009-04-03  198  
9ae326a69004de David Howells        2009-04-03  199  	fsdef->dentry = cachedir;
9ae326a69004de David Howells        2009-04-03  200  	fsdef->fscache.cookie = NULL;
9ae326a69004de David Howells        2009-04-03  201  
9ae326a69004de David Howells        2009-04-03  202  	ret = cachefiles_check_object_type(fsdef);
9ae326a69004de David Howells        2009-04-03  203  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  204  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  205  
9ae326a69004de David Howells        2009-04-03  206  	/* get the graveyard directory */
9ae326a69004de David Howells        2009-04-03  207  	graveyard = cachefiles_get_directory(cache, root, "graveyard");
9ae326a69004de David Howells        2009-04-03  208  	if (IS_ERR(graveyard)) {
9ae326a69004de David Howells        2009-04-03  209  		ret = PTR_ERR(graveyard);
9ae326a69004de David Howells        2009-04-03  210  		goto error_unsupported;
9ae326a69004de David Howells        2009-04-03  211  	}
9ae326a69004de David Howells        2009-04-03  212  
9ae326a69004de David Howells        2009-04-03  213  	cache->graveyard = graveyard;
9ae326a69004de David Howells        2009-04-03  214  
9ae326a69004de David Howells        2009-04-03  215  	/* publish the cache */
9ae326a69004de David Howells        2009-04-03  216  	fscache_init_cache(&cache->cache,
9ae326a69004de David Howells        2009-04-03  217  			   &cachefiles_cache_ops,
9ae326a69004de David Howells        2009-04-03  218  			   "%s",
9ae326a69004de David Howells        2009-04-03  219  			   fsdef->dentry->d_sb->s_id);
9ae326a69004de David Howells        2009-04-03  220  
f29507ce667010 Kiran Kumar Modukuri 2018-06-21  221  	fscache_object_init(&fsdef->fscache, &fscache_fsdef_index,
f29507ce667010 Kiran Kumar Modukuri 2018-06-21  222  			    &cache->cache);
9ae326a69004de David Howells        2009-04-03  223  
9ae326a69004de David Howells        2009-04-03  224  	ret = fscache_add_cache(&cache->cache, &fsdef->fscache, cache->tag);
9ae326a69004de David Howells        2009-04-03  225  	if (ret < 0)
9ae326a69004de David Howells        2009-04-03  226  		goto error_add_cache;
9ae326a69004de David Howells        2009-04-03  227  
9ae326a69004de David Howells        2009-04-03  228  	/* done */
9ae326a69004de David Howells        2009-04-03  229  	set_bit(CACHEFILES_READY, &cache->flags);
9ae326a69004de David Howells        2009-04-03  230  	dput(root);
9ae326a69004de David Howells        2009-04-03  231  
0227d6abb37845 Fabian Frederick     2014-06-06  232  	pr_info("File cache on %s registered\n", cache->cache.identifier);
9ae326a69004de David Howells        2009-04-03  233  
9ae326a69004de David Howells        2009-04-03  234  	/* check how much space the cache has */
9ae326a69004de David Howells        2009-04-03  235  	cachefiles_has_space(cache, 0, 0);
9ae326a69004de David Howells        2009-04-03  236  	cachefiles_end_secure(cache, saved_cred);
9ae326a69004de David Howells        2009-04-03  237  	return 0;
9ae326a69004de David Howells        2009-04-03  238  
9ae326a69004de David Howells        2009-04-03  239  error_add_cache:
9ae326a69004de David Howells        2009-04-03  240  	dput(cache->graveyard);
9ae326a69004de David Howells        2009-04-03  241  	cache->graveyard = NULL;
9ae326a69004de David Howells        2009-04-03  242  error_unsupported:
9ae326a69004de David Howells        2009-04-03  243  	mntput(cache->mnt);
9ae326a69004de David Howells        2009-04-03  244  	cache->mnt = NULL;
9ae326a69004de David Howells        2009-04-03  245  	dput(fsdef->dentry);
9ae326a69004de David Howells        2009-04-03  246  	fsdef->dentry = NULL;
9ae326a69004de David Howells        2009-04-03 @247  	dput(root);
                                                        ^^^^^^^^^^

9ae326a69004de David Howells        2009-04-03  248  error_open_root:
9ae326a69004de David Howells        2009-04-03  249  	kmem_cache_free(cachefiles_object_jar, fsdef);
9ae326a69004de David Howells        2009-04-03  250  error_root_object:
9ae326a69004de David Howells        2009-04-03  251  	cachefiles_end_secure(cache, saved_cred);
6ff66ac77aeaa9 Fabian Frederick     2014-09-25  252  	pr_err("Failed to register: %d\n", ret);
9ae326a69004de David Howells        2009-04-03  253  	return ret;
9ae326a69004de David Howells        2009-04-03  254  }

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 34575 bytes --]

  reply	other threads:[~2021-03-17 14:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-16 11:22 [PATCH] cachefiles: do not yet allow on idmapped mounts Christian Brauner
2021-03-17 14:25 ` Dan Carpenter [this message]
2021-03-17 14:25   ` Dan Carpenter
2021-03-17 17:15   ` Christian Brauner
2021-03-17 13:04 kernel test robot
2021-03-24  8:51 David Howells

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210317142511.GB2087@kadam \
    --to=dan.carpenter@oracle.com \
    --cc=kbuild@lists.01.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.