Building the Linux kernel with Clang and LLVM
 help / color / mirror / Atom feed
From: kernel test robot <lkp@intel.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: llvm@lists.linux.dev, oe-kbuild-all@lists.linux.dev
Subject: [bigeasy-staging:ucount 4/4] kernel/ucount.c:14:11: error: field designator 'refcnt' does not refer to any field in type 'atomic_t'
Date: Sun, 26 Jan 2025 00:42:22 +0800	[thread overview]
Message-ID: <202501260026.51BnOJBu-lkp@intel.com> (raw)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/bigeasy/staging.git ucount
head:   e9941c1a05c13c6c791c76ab322b385f5e535a6f
commit: e9941c1a05c13c6c791c76ab322b385f5e535a6f [4/4] ucount: use rcuref
config: x86_64-allnoconfig (https://download.01.org/0day-ci/archive/20250126/202501260026.51BnOJBu-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250126/202501260026.51BnOJBu-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501260026.51BnOJBu-lkp@intel.com/

All errors (new ones prefixed by >>):

>> kernel/ucount.c:14:11: error: field designator 'refcnt' does not refer to any field in type 'atomic_t'
      14 |         .count = RCUREF_INIT(1),
         |                  ^~~~~~~~~~~~~~
   include/linux/types.h:192:27: note: expanded from macro 'RCUREF_INIT'
     192 | #define RCUREF_INIT(i)  { .refcnt = ATOMIC_INIT(i - 1) }
         |                           ~^~~~~~~~~~~~~~~~~~~~~~~~~~~
>> kernel/ucount.c:141:8: error: call to undeclared function 'rcuref_get'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     141 |                         if (rcuref_get(&ucounts->count))
         |                             ^
   kernel/ucount.c:141:8: note: did you mean 'kref_get'?
   include/linux/kref.h:43:20: note: 'kref_get' declared here
      43 | static inline void kref_get(struct kref *kref)
         |                    ^
>> kernel/ucount.c:172:2: error: call to undeclared function 'rcuref_init'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     172 |         rcuref_init(&new->count, 1);
         |         ^
>> kernel/ucount.c:200:6: error: call to undeclared function 'rcuref_put'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
     200 |         if (rcuref_put(&ucounts->count)) {
         |             ^
   kernel/ucount.c:200:6: note: did you mean 'kref_put'?
   include/linux/kref.h:62:19: note: 'kref_put' declared here
      62 | static inline int kref_put(struct kref *kref, void (*release)(struct kref *kref))
         |                   ^
   4 errors generated.


vim +14 kernel/ucount.c

    10	
    11	struct ucounts init_ucounts = {
    12		.ns    = &init_user_ns,
    13		.uid   = GLOBAL_ROOT_UID,
  > 14		.count = RCUREF_INIT(1),
    15	};
    16	
    17	#define UCOUNTS_HASHTABLE_BITS 10
    18	#define UCOUNTS_HASHTABLE_ENTRIES (1 << UCOUNTS_HASHTABLE_BITS)
    19	static struct hlist_nulls_head ucounts_hashtable[UCOUNTS_HASHTABLE_ENTRIES]= {
    20		[0 ... UCOUNTS_HASHTABLE_ENTRIES - 1] = HLIST_NULLS_HEAD_INIT(0)
    21	};
    22	static DEFINE_SPINLOCK(ucounts_lock);
    23	
    24	#define ucounts_hashfn(ns, uid)						\
    25		hash_long((unsigned long)__kuid_val(uid) + (unsigned long)(ns), \
    26			  UCOUNTS_HASHTABLE_BITS)
    27	#define ucounts_hashentry(ns, uid)	\
    28		(ucounts_hashtable + ucounts_hashfn(ns, uid))
    29	
    30	#ifdef CONFIG_SYSCTL
    31	static struct ctl_table_set *
    32	set_lookup(struct ctl_table_root *root)
    33	{
    34		return &current_user_ns()->set;
    35	}
    36	
    37	static int set_is_seen(struct ctl_table_set *set)
    38	{
    39		return &current_user_ns()->set == set;
    40	}
    41	
    42	static int set_permissions(struct ctl_table_header *head,
    43				   const struct ctl_table *table)
    44	{
    45		struct user_namespace *user_ns =
    46			container_of(head->set, struct user_namespace, set);
    47		int mode;
    48	
    49		/* Allow users with CAP_SYS_RESOURCE unrestrained access */
    50		if (ns_capable(user_ns, CAP_SYS_RESOURCE))
    51			mode = (table->mode & S_IRWXU) >> 6;
    52		else
    53		/* Allow all others at most read-only access */
    54			mode = table->mode & S_IROTH;
    55		return (mode << 6) | (mode << 3) | mode;
    56	}
    57	
    58	static struct ctl_table_root set_root = {
    59		.lookup = set_lookup,
    60		.permissions = set_permissions,
    61	};
    62	
    63	static long ue_zero = 0;
    64	static long ue_int_max = INT_MAX;
    65	
    66	#define UCOUNT_ENTRY(name)					\
    67		{							\
    68			.procname	= name,				\
    69			.maxlen		= sizeof(long),			\
    70			.mode		= 0644,				\
    71			.proc_handler	= proc_doulongvec_minmax,	\
    72			.extra1		= &ue_zero,			\
    73			.extra2		= &ue_int_max,			\
    74		}
    75	static const struct ctl_table user_table[] = {
    76		UCOUNT_ENTRY("max_user_namespaces"),
    77		UCOUNT_ENTRY("max_pid_namespaces"),
    78		UCOUNT_ENTRY("max_uts_namespaces"),
    79		UCOUNT_ENTRY("max_ipc_namespaces"),
    80		UCOUNT_ENTRY("max_net_namespaces"),
    81		UCOUNT_ENTRY("max_mnt_namespaces"),
    82		UCOUNT_ENTRY("max_cgroup_namespaces"),
    83		UCOUNT_ENTRY("max_time_namespaces"),
    84	#ifdef CONFIG_INOTIFY_USER
    85		UCOUNT_ENTRY("max_inotify_instances"),
    86		UCOUNT_ENTRY("max_inotify_watches"),
    87	#endif
    88	#ifdef CONFIG_FANOTIFY
    89		UCOUNT_ENTRY("max_fanotify_groups"),
    90		UCOUNT_ENTRY("max_fanotify_marks"),
    91	#endif
    92	};
    93	#endif /* CONFIG_SYSCTL */
    94	
    95	bool setup_userns_sysctls(struct user_namespace *ns)
    96	{
    97	#ifdef CONFIG_SYSCTL
    98		struct ctl_table *tbl;
    99	
   100		BUILD_BUG_ON(ARRAY_SIZE(user_table) != UCOUNT_COUNTS);
   101		setup_sysctl_set(&ns->set, &set_root, set_is_seen);
   102		tbl = kmemdup(user_table, sizeof(user_table), GFP_KERNEL);
   103		if (tbl) {
   104			int i;
   105			for (i = 0; i < UCOUNT_COUNTS; i++) {
   106				tbl[i].data = &ns->ucount_max[i];
   107			}
   108			ns->sysctls = __register_sysctl_table(&ns->set, "user", tbl,
   109							      ARRAY_SIZE(user_table));
   110		}
   111		if (!ns->sysctls) {
   112			kfree(tbl);
   113			retire_sysctl_set(&ns->set);
   114			return false;
   115		}
   116	#endif
   117		return true;
   118	}
   119	
   120	void retire_userns_sysctls(struct user_namespace *ns)
   121	{
   122	#ifdef CONFIG_SYSCTL
   123		const struct ctl_table *tbl;
   124	
   125		tbl = ns->sysctls->ctl_table_arg;
   126		unregister_sysctl_table(ns->sysctls);
   127		retire_sysctl_set(&ns->set);
   128		kfree(tbl);
   129	#endif
   130	}
   131	
   132	static struct ucounts *find_ucounts(struct user_namespace *ns, kuid_t uid,
   133					    struct hlist_nulls_head *hashent)
   134	{
   135		struct ucounts *ucounts;
   136		struct hlist_nulls_node *pos;
   137	
   138		guard(rcu)();
   139		hlist_nulls_for_each_entry_rcu(ucounts, pos, hashent, node) {
   140			if (uid_eq(ucounts->uid, uid) && (ucounts->ns == ns)) {
 > 141				if (rcuref_get(&ucounts->count))
   142					return ucounts;
   143			}
   144		}
   145		return NULL;
   146	}
   147	
   148	static void hlist_add_ucounts(struct ucounts *ucounts)
   149	{
   150		struct hlist_nulls_head *hashent = ucounts_hashentry(ucounts->ns, ucounts->uid);
   151	
   152		spin_lock_irq(&ucounts_lock);
   153		hlist_nulls_add_head_rcu(&ucounts->node, hashent);
   154		spin_unlock_irq(&ucounts_lock);
   155	}
   156	
   157	struct ucounts *alloc_ucounts(struct user_namespace *ns, kuid_t uid)
   158	{
   159		struct hlist_nulls_head *hashent = ucounts_hashentry(ns, uid);
   160		struct ucounts *ucounts, *new;
   161	
   162		ucounts = find_ucounts(ns, uid, hashent);
   163		if (ucounts)
   164			return ucounts;
   165	
   166		new = kzalloc(sizeof(*new), GFP_KERNEL);
   167		if (!new)
   168			return NULL;
   169	
   170		new->ns = ns;
   171		new->uid = uid;
 > 172		rcuref_init(&new->count, 1);
   173	
   174		spin_lock_irq(&ucounts_lock);
   175		ucounts = find_ucounts(ns, uid, hashent);
   176		if (ucounts) {
   177			spin_unlock_irq(&ucounts_lock);
   178			kfree(new);
   179			return ucounts;
   180		}
   181	
   182		hlist_nulls_add_head_rcu(&new->node, hashent);
   183		get_user_ns(new->ns);
   184		spin_unlock_irq(&ucounts_lock);
   185		return new;
   186	}
   187	
   188	static void ucounts_free(struct rcu_head *rcu)
   189	{
   190		struct ucounts *ucounts = container_of(rcu, struct ucounts, rcu);
   191	
   192		put_user_ns(ucounts->ns);
   193		kfree(ucounts);
   194	}
   195	
   196	void put_ucounts(struct ucounts *ucounts)
   197	{
   198		unsigned long flags;
   199	
 > 200		if (rcuref_put(&ucounts->count)) {
   201			spin_lock_irqsave(&ucounts_lock, flags);
   202			hlist_nulls_del_rcu(&ucounts->node);
   203			spin_unlock_irqrestore(&ucounts_lock, flags);
   204	
   205			call_rcu(&ucounts->rcu, ucounts_free);
   206		}
   207	}
   208	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

                 reply	other threads:[~2025-01-25 16:43 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=202501260026.51BnOJBu-lkp@intel.com \
    --to=lkp@intel.com \
    --cc=bigeasy@linutronix.de \
    --cc=llvm@lists.linux.dev \
    --cc=oe-kbuild-all@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox