lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202505100206.85k3mymM-lkp@intel.com>
Date: Sat, 10 May 2025 03:10:50 +0800
From: kernel test robot <lkp@...el.com>
To: Dan Williams <dan.j.williams@...el.com>, linux-cxl@...r.kernel.org
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	David Lechner <dlechner@...libre.com>,
	Peter Zijlstra <peterz@...radead.org>,
	Ingo Molnar <mingo@...nel.org>,
	"Fabio M. De Francesco" <fabio.maria.de.francesco@...ux.intel.com>,
	Davidlohr Bueso <dave@...olabs.net>,
	Jonathan Cameron <jonathan.cameron@...wei.com>,
	Dave Jiang <dave.jiang@...el.com>,
	Alison Schofield <alison.schofield@...el.com>,
	Vishal Verma <vishal.l.verma@...el.com>,
	Ira Weiny <ira.weiny@...el.com>
Subject: Re: [PATCH 1/7] cleanup: Introduce DEFINE_ACQUIRE() a CLASS() for
 conditional locking

Hi Dan,

kernel test robot noticed the following build errors:

[auto build test ERROR on b4432656b36e5cc1d50a1f2dc15357543add530e]

url:    https://github.com/intel-lab-lkp/linux/commits/Dan-Williams/cleanup-Introduce-DEFINE_ACQUIRE-a-CLASS-for-conditional-locking/20250507-152728
base:   b4432656b36e5cc1d50a1f2dc15357543add530e
patch link:    https://lore.kernel.org/r/20250507072145.3614298-2-dan.j.williams%40intel.com
patch subject: [PATCH 1/7] cleanup: Introduce DEFINE_ACQUIRE() a CLASS() for conditional locking
config: arm-randconfig-001-20250509 (https://download.01.org/0day-ci/archive/20250510/202505100206.85k3mymM-lkp@intel.com/config)
compiler: arm-linux-gnueabi-gcc (GCC) 8.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250510/202505100206.85k3mymM-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@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202505100206.85k3mymM-lkp@intel.com/

All error/warnings (new ones prefixed by >>):

   In file included from include/linux/irqflags.h:17,
                    from arch/arm/include/asm/bitops.h:28,
                    from include/linux/bitops.h:68,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4defs.h:40,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:36,
                    from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:10,
                    from arch/arm/boot/compressed/decompress.c:60:
   include/linux/mutex.h: In function 'class_mutex_intr_acquire_destructor':
>> include/linux/cleanup.h:476:13: error: implicit declaration of function 'IS_ERR_OR_NULL' [-Werror=implicit-function-declaration]
           if (!IS_ERR_OR_NULL(_T)) _unlock(&_T->_locktype), ({    \
                ^~~~~~~~~~~~~~
   include/linux/cleanup.h:246:18: note: in definition of macro 'DEFINE_CLASS'
    { _type _T = *p; _exit; }      \
                     ^~~~~
   include/linux/mutex.h:216:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
   include/linux/mutex.h: In function 'class_mutex_intr_acquire_constructor':
>> include/linux/cleanup.h:481:24: error: implicit declaration of function 'ERR_PTR'; did you mean 'PERCPU_PTR'? [-Werror=implicit-function-declaration]
             lock_result = ERR_PTR(ret);             \
                           ^~~~~~~
   include/linux/cleanup.h:248:13: note: in definition of macro 'DEFINE_CLASS'
    { _type t = _init; return t; }
                ^~~~~
   include/linux/mutex.h:216:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
>> include/linux/cleanup.h:481:22: warning: assignment to 'struct mutex_acquire *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
             lock_result = ERR_PTR(ret);             \
                         ^
   include/linux/cleanup.h:248:13: note: in definition of macro 'DEFINE_CLASS'
    { _type t = _init; return t; }
                ^~~~~
   include/linux/mutex.h:216:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
   include/linux/mutex.h: In function 'class_mutex_try_acquire_constructor':
>> include/linux/cleanup.h:481:22: warning: assignment to 'struct mutex_acquire *' from 'int' makes pointer from integer without a cast [-Wint-conversion]
             lock_result = ERR_PTR(ret);             \
                         ^
   include/linux/cleanup.h:248:13: note: in definition of macro 'DEFINE_CLASS'
    { _type t = _init; return t; }
                ^~~~~
   include/linux/mutex.h:226:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_try_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
   In file included from include/linux/rwsem.h:17,
                    from include/linux/mm_types.h:13,
                    from include/linux/mmzone.h:22,
                    from include/linux/gfp.h:7,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:17,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:38,
                    from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:10,
                    from arch/arm/boot/compressed/decompress.c:60:
   include/linux/err.h: At top level:
>> include/linux/err.h:39:35: error: conflicting types for 'ERR_PTR'
    static inline void * __must_check ERR_PTR(long error)
                                      ^~~~~~~
   In file included from include/linux/irqflags.h:17,
                    from arch/arm/include/asm/bitops.h:28,
                    from include/linux/bitops.h:68,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4defs.h:40,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:36,
                    from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:10,
                    from arch/arm/boot/compressed/decompress.c:60:
   include/linux/cleanup.h:481:24: note: previous implicit declaration of 'ERR_PTR' was here
             lock_result = ERR_PTR(ret);             \
                           ^~~~~~~
   include/linux/cleanup.h:248:13: note: in definition of macro 'DEFINE_CLASS'
    { _type t = _init; return t; }
                ^~~~~
   include/linux/mutex.h:216:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
   In file included from include/linux/rwsem.h:17,
                    from include/linux/mm_types.h:13,
                    from include/linux/mmzone.h:22,
                    from include/linux/gfp.h:7,
                    from include/linux/umh.h:4,
                    from include/linux/kmod.h:9,
                    from include/linux/module.h:17,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:38,
                    from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:10,
                    from arch/arm/boot/compressed/decompress.c:60:
>> include/linux/err.h:82:33: error: conflicting types for 'IS_ERR_OR_NULL'
    static inline bool __must_check IS_ERR_OR_NULL(__force const void *ptr)
                                    ^~~~~~~~~~~~~~
   In file included from include/linux/irqflags.h:17,
                    from arch/arm/include/asm/bitops.h:28,
                    from include/linux/bitops.h:68,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4defs.h:40,
                    from arch/arm/boot/compressed/../../../../lib/lz4/lz4_decompress.c:36,
                    from arch/arm/boot/compressed/../../../../lib/decompress_unlz4.c:10,
                    from arch/arm/boot/compressed/decompress.c:60:
   include/linux/cleanup.h:476:13: note: previous implicit declaration of 'IS_ERR_OR_NULL' was here
           if (!IS_ERR_OR_NULL(_T)) _unlock(&_T->_locktype), ({    \
                ^~~~~~~~~~~~~~
   include/linux/cleanup.h:246:18: note: in definition of macro 'DEFINE_CLASS'
    { _type _T = *p; _exit; }      \
                     ^~~~~
   include/linux/mutex.h:216:1: note: in expansion of macro 'DEFINE_ACQUIRE'
    DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
    ^~~~~~~~~~~~~~
   cc1: some warnings being treated as errors


vim +/IS_ERR_OR_NULL +476 include/linux/cleanup.h

   416	
   417	#define DEFINE_LOCK_GUARD_1_COND(_name, _ext, _condlock)		\
   418		__DEFINE_CLASS_IS_CONDITIONAL(_name##_ext, true);		\
   419		EXTEND_CLASS(_name, _ext,					\
   420			     ({ class_##_name##_t _t = { .lock = l }, *_T = &_t;\
   421			        if (_T->lock && !(_condlock)) _T->lock = NULL;	\
   422				_t; }),						\
   423			     typeof_member(class_##_name##_t, lock) l)		\
   424		static inline void * class_##_name##_ext##_lock_ptr(class_##_name##_t *_T) \
   425		{ return class_##_name##_lock_ptr(_T); }
   426	
   427	/*
   428	 * DEFINE_ACQUIRE(acquire_class_name, lock_type, unlock, cond_lock):
   429	 *	Define a CLASS() that instantiates and acquires a conditional lock
   430	 *	within an existing scope. In contrast to DEFINE_GUARD[_COND](), which
   431	 *	hides the variable tracking the lock scope, CLASS(@acquire_class_name,
   432	 *	@lock) instantiates @lock as either an ERR_PTR() or a cookie that drops
   433	 *	the lock when it goes out of scope. An "_acquire" suffix is appended to
   434	 *	@lock_type to provide type-safety against mixing explicit and implicit
   435	 *	(scope-based) cleanup.
   436	 *
   437	 * Ex.
   438	 *
   439	 * DEFINE_ACQUIRE(mutex_intr_acquire, mutex, mutex_unlock,
   440	 *                mutex_lock_interruptible)
   441	 *
   442	 *	int interruptible_operation(...)
   443	 *	{
   444	 *		...
   445	 *		CLASS(mutex_intr_acquire, lock)(&obj->lock);
   446	 *	     if (IS_ERR(lock))
   447	 *			return PTR_ERR(lock);
   448	 *		...
   449	 *	} <= obj->lock dropped here.
   450	 *
   451	 * Attempts to perform:
   452	 *
   453	 * mutex_unlock(&obj->lock);
   454	 *
   455	 * ...fail because obj->lock is a 'struct mutex_acquire' not 'struct mutex'
   456	 * instance.
   457	 *
   458	 * Also, attempts to use the CLASS() conditionally require the ambiguous
   459	 * scope to be clarified (compiler enforced):
   460	 *
   461	 *	if (...)
   462	 *		CLASS(mutex_intr_acquire, lock)(&obj->lock); // <-- "error: expected expression"
   463	 *		if (IS_ERR(lock))
   464	 *			return PTR_ERR(lock);
   465	 *
   466	 * vs:
   467	 *
   468	 *	if (...) {
   469	 *		CLASS(mutex_intr_acquire, lock)(&obj->lock);
   470	 *		if (IS_ERR(lock))
   471	 *			return PTR_ERR(lock);
   472	 *	} // <-- lock released here
   473	 */
   474	#define DEFINE_ACQUIRE(_name, _locktype, _unlock, _cond_lock)                \
   475		DEFINE_CLASS(_name, struct _locktype##_acquire *,                    \
 > 476			     if (!IS_ERR_OR_NULL(_T)) _unlock(&_T->_locktype), ({    \
   477				     struct _locktype##_acquire *lock_result;        \
   478				     int ret = _cond_lock(&to_lock->_locktype);      \
   479	                                                                             \
   480				     if (ret)                                        \
 > 481					     lock_result = ERR_PTR(ret);             \
   482				     else                                            \
   483					     lock_result =                           \
   484						     (struct _locktype##_acquire     \
   485							      *)&to_lock->_locktype; \
   486				     lock_result;                                    \
   487			     }),                                                     \
   488			     struct _locktype##_acquire *to_lock)
   489	

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ