Hi Viresh, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v5.11-rc3 next-20210114] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch] url: https://github.com/0day-ci/linux/commits/Viresh-Kumar/dcookies-Make-dcookies-depend-on-CONFIG_OPROFILE/20210111-140734 base: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 7c53f6b671f4aba70ff15e1b05148b10d58c2837 config: x86_64-rhel (attached as .config) compiler: gcc-9 (Debian 9.3.0-15) 9.3.0 reproduce (this is a W=1 build): # https://github.com/0day-ci/linux/commit/d48f031313d175610c430e9f04c3b6974e3fd3e2 git remote add linux-review https://github.com/0day-ci/linux git fetch --no-tags linux-review Viresh-Kumar/dcookies-Make-dcookies-depend-on-CONFIG_OPROFILE/20210111-140734 git checkout d48f031313d175610c430e9f04c3b6974e3fd3e2 # save the attached .config to linux build tree make W=1 ARCH=x86_64 If you fix the issue, kindly add following tag as appropriate Reported-by: kernel test robot <lkp@xxxxxxxxx> All errors (new ones prefixed by >>): >> fs/dcookies.c:117:5: error: redefinition of 'get_dcookie' 117 | int get_dcookie(const struct path *path, unsigned long *cookie) | ^~~~~~~~~~~ In file included from fs/dcookies.c:26: include/linux/dcookies.h:62:19: note: previous definition of 'get_dcookie' was here 62 | static inline int get_dcookie(const struct path *path, unsigned long *cookie) | ^~~~~~~~~~~ >> fs/dcookies.c:316:23: error: redefinition of 'dcookie_register' 316 | struct dcookie_user * dcookie_register(void) | ^~~~~~~~~~~~~~~~ In file included from fs/dcookies.c:26: include/linux/dcookies.h:52:37: note: previous definition of 'dcookie_register' was here 52 | static inline struct dcookie_user * dcookie_register(void) | ^~~~~~~~~~~~~~~~ >> fs/dcookies.c:341:6: error: redefinition of 'dcookie_unregister' 341 | void dcookie_unregister(struct dcookie_user * user) | ^~~~~~~~~~~~~~~~~~ In file included from fs/dcookies.c:26: include/linux/dcookies.h:57:20: note: previous definition of 'dcookie_unregister' was here 57 | static inline void dcookie_unregister(struct dcookie_user * user) | ^~~~~~~~~~~~~~~~~~ vim +/get_dcookie +117 fs/dcookies.c ^1da177e4c3f4152 Linus Torvalds 2005-04-16 112 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 113 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 114 /* This is the main kernel-side routine that retrieves the cookie ^1da177e4c3f4152 Linus Torvalds 2005-04-16 115 * value for a dentry/vfsmnt pair. ^1da177e4c3f4152 Linus Torvalds 2005-04-16 116 */ 71215a75ceddf38b Al Viro 2016-11-20 @117 int get_dcookie(const struct path *path, unsigned long *cookie) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 118 { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 119 int err = 0; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 120 struct dcookie_struct * dcs; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 121 353ab6e97b8f209d Ingo Molnar 2006-03-26 122 mutex_lock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 123 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 124 if (!is_live()) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 125 err = -EINVAL; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 126 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 127 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 128 c2452f32786159ed Nick Piggin 2008-12-01 129 if (path->dentry->d_flags & DCACHE_COOKIE) { c2452f32786159ed Nick Piggin 2008-12-01 130 dcs = find_dcookie((unsigned long)path->dentry); c2452f32786159ed Nick Piggin 2008-12-01 131 } else { 448678a0f3cdd015 Jan Blunck 2008-02-14 132 dcs = alloc_dcookie(path); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 133 if (!dcs) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 134 err = -ENOMEM; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 135 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 136 } c2452f32786159ed Nick Piggin 2008-12-01 137 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 138 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 139 *cookie = dcookie_value(dcs); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 140 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 141 out: 353ab6e97b8f209d Ingo Molnar 2006-03-26 142 mutex_unlock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 143 return err; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 144 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 145 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 146 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 147 /* And here is where the userspace process can look up the cookie value ^1da177e4c3f4152 Linus Torvalds 2005-04-16 148 * to retrieve the path. ^1da177e4c3f4152 Linus Torvalds 2005-04-16 149 */ 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 150 static int do_lookup_dcookie(u64 cookie64, char __user *buf, size_t len) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 151 { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 152 unsigned long cookie = (unsigned long)cookie64; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 153 int err = -EINVAL; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 154 char * kbuf; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 155 char * path; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 156 size_t pathlen; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 157 struct dcookie_struct * dcs; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 158 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 159 /* we could leak path information to users ^1da177e4c3f4152 Linus Torvalds 2005-04-16 160 * without dir read permission without this ^1da177e4c3f4152 Linus Torvalds 2005-04-16 161 */ ^1da177e4c3f4152 Linus Torvalds 2005-04-16 162 if (!capable(CAP_SYS_ADMIN)) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 163 return -EPERM; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 164 353ab6e97b8f209d Ingo Molnar 2006-03-26 165 mutex_lock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 166 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 167 if (!is_live()) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 168 err = -EINVAL; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 169 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 170 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 171 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 172 if (!(dcs = find_dcookie(cookie))) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 173 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 174 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 175 err = -ENOMEM; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 176 kbuf = kmalloc(PAGE_SIZE, GFP_KERNEL); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 177 if (!kbuf) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 178 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 179 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 180 /* FIXME: (deleted) ? */ cf28b4863f9ee8f1 Jan Blunck 2008-02-14 181 path = d_path(&dcs->path, kbuf, PAGE_SIZE); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 182 fe47ae7f53e179d2 Robert Richter 2011-05-31 183 mutex_unlock(&dcookie_mutex); fe47ae7f53e179d2 Robert Richter 2011-05-31 184 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 185 if (IS_ERR(path)) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 186 err = PTR_ERR(path); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 187 goto out_free; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 188 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 189 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 190 err = -ERANGE; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 191 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 192 pathlen = kbuf + PAGE_SIZE - path; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 193 if (pathlen <= len) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 194 err = pathlen; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 195 if (copy_to_user(buf, path, pathlen)) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 196 err = -EFAULT; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 197 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 198 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 199 out_free: ^1da177e4c3f4152 Linus Torvalds 2005-04-16 200 kfree(kbuf); fe47ae7f53e179d2 Robert Richter 2011-05-31 201 return err; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 202 out: 353ab6e97b8f209d Ingo Molnar 2006-03-26 203 mutex_unlock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 204 return err; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 205 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 206 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 207 SYSCALL_DEFINE3(lookup_dcookie, u64, cookie64, char __user *, buf, size_t, len) 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 208 { 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 209 return do_lookup_dcookie(cookie64, buf, len); 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 210 } 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 211 d5dc77bfeeab0b03 Al Viro 2013-02-25 212 #ifdef CONFIG_COMPAT d8d14bd09cddbaf0 Heiko Carstens 2014-01-29 213 COMPAT_SYSCALL_DEFINE4(lookup_dcookie, u32, w0, u32, w1, char __user *, buf, compat_size_t, len) d5dc77bfeeab0b03 Al Viro 2013-02-25 214 { d5dc77bfeeab0b03 Al Viro 2013-02-25 215 #ifdef __BIG_ENDIAN 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 216 return do_lookup_dcookie(((u64)w0 << 32) | w1, buf, len); d5dc77bfeeab0b03 Al Viro 2013-02-25 217 #else 98e5f7bd2c67f402 Dominik Brodowski 2018-03-17 218 return do_lookup_dcookie(((u64)w1 << 32) | w0, buf, len); d5dc77bfeeab0b03 Al Viro 2013-02-25 219 #endif d5dc77bfeeab0b03 Al Viro 2013-02-25 220 } d5dc77bfeeab0b03 Al Viro 2013-02-25 221 #endif d5dc77bfeeab0b03 Al Viro 2013-02-25 222 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 223 static int dcookie_init(void) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 224 { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 225 struct list_head * d; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 226 unsigned int i, hash_bits; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 227 int err = -ENOMEM; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 228 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 229 dcookie_cache = kmem_cache_create("dcookie_cache", ^1da177e4c3f4152 Linus Torvalds 2005-04-16 230 sizeof(struct dcookie_struct), 20c2df83d25c6a95 Paul Mundt 2007-07-20 231 0, 0, NULL); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 232 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 233 if (!dcookie_cache) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 234 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 235 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 236 dcookie_hashtable = kmalloc(PAGE_SIZE, GFP_KERNEL); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 237 if (!dcookie_hashtable) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 238 goto out_kmem; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 239 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 240 err = 0; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 241 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 242 /* ^1da177e4c3f4152 Linus Torvalds 2005-04-16 243 * Find the power-of-two list-heads that can fit into the allocation.. ^1da177e4c3f4152 Linus Torvalds 2005-04-16 244 * We don't guarantee that "sizeof(struct list_head)" is necessarily ^1da177e4c3f4152 Linus Torvalds 2005-04-16 245 * a power-of-two. ^1da177e4c3f4152 Linus Torvalds 2005-04-16 246 */ ^1da177e4c3f4152 Linus Torvalds 2005-04-16 247 hash_size = PAGE_SIZE / sizeof(struct list_head); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 248 hash_bits = 0; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 249 do { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 250 hash_bits++; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 251 } while ((hash_size >> hash_bits) != 0); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 252 hash_bits--; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 253 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 254 /* ^1da177e4c3f4152 Linus Torvalds 2005-04-16 255 * Re-calculate the actual number of entries and the mask ^1da177e4c3f4152 Linus Torvalds 2005-04-16 256 * from the number of bits we can fit. ^1da177e4c3f4152 Linus Torvalds 2005-04-16 257 */ ^1da177e4c3f4152 Linus Torvalds 2005-04-16 258 hash_size = 1UL << hash_bits; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 259 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 260 /* And initialize the newly allocated array */ ^1da177e4c3f4152 Linus Torvalds 2005-04-16 261 d = dcookie_hashtable; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 262 i = hash_size; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 263 do { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 264 INIT_LIST_HEAD(d); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 265 d++; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 266 i--; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 267 } while (i); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 268 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 269 out: ^1da177e4c3f4152 Linus Torvalds 2005-04-16 270 return err; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 271 out_kmem: ^1da177e4c3f4152 Linus Torvalds 2005-04-16 272 kmem_cache_destroy(dcookie_cache); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 273 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 274 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 275 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 276 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 277 static void free_dcookie(struct dcookie_struct * dcs) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 278 { c2452f32786159ed Nick Piggin 2008-12-01 279 struct dentry *d = dcs->path.dentry; c2452f32786159ed Nick Piggin 2008-12-01 280 c2452f32786159ed Nick Piggin 2008-12-01 281 spin_lock(&d->d_lock); c2452f32786159ed Nick Piggin 2008-12-01 282 d->d_flags &= ~DCACHE_COOKIE; c2452f32786159ed Nick Piggin 2008-12-01 283 spin_unlock(&d->d_lock); c2452f32786159ed Nick Piggin 2008-12-01 284 448678a0f3cdd015 Jan Blunck 2008-02-14 285 path_put(&dcs->path); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 286 kmem_cache_free(dcookie_cache, dcs); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 287 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 288 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 289 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 290 static void dcookie_exit(void) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 291 { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 292 struct list_head * list; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 293 struct list_head * pos; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 294 struct list_head * pos2; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 295 struct dcookie_struct * dcs; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 296 size_t i; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 297 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 298 for (i = 0; i < hash_size; ++i) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 299 list = dcookie_hashtable + i; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 300 list_for_each_safe(pos, pos2, list) { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 301 dcs = list_entry(pos, struct dcookie_struct, hash_list); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 302 list_del(&dcs->hash_list); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 303 free_dcookie(dcs); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 304 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 305 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 306 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 307 kfree(dcookie_hashtable); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 308 kmem_cache_destroy(dcookie_cache); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 309 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 310 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 311 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 312 struct dcookie_user { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 313 struct list_head next; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 314 }; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 315 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 @316 struct dcookie_user * dcookie_register(void) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 317 { ^1da177e4c3f4152 Linus Torvalds 2005-04-16 318 struct dcookie_user * user; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 319 353ab6e97b8f209d Ingo Molnar 2006-03-26 320 mutex_lock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 321 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 322 user = kmalloc(sizeof(struct dcookie_user), GFP_KERNEL); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 323 if (!user) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 324 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 325 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 326 if (!is_live() && dcookie_init()) ^1da177e4c3f4152 Linus Torvalds 2005-04-16 327 goto out_free; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 328 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 329 list_add(&user->next, &dcookie_users); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 330 ^1da177e4c3f4152 Linus Torvalds 2005-04-16 331 out: 353ab6e97b8f209d Ingo Molnar 2006-03-26 332 mutex_unlock(&dcookie_mutex); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 333 return user; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 334 out_free: ^1da177e4c3f4152 Linus Torvalds 2005-04-16 335 kfree(user); ^1da177e4c3f4152 Linus Torvalds 2005-04-16 336 user = NULL; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 337 goto out; ^1da177e4c3f4152 Linus Torvalds 2005-04-16 338 } ^1da177e4c3f4152 Linus Torvalds 2005-04-16 339 --- 0-DAY CI Kernel Test Service, Intel Corporation https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx
Attachment:
.config.gz
Description: application/gzip