提交 18781385 编写于 作者: M Miklos Szeredi 提交者: Xie XiuQi

bitops: protect variables in bit_clear_unless() macro

mainline inclusion
from mainline-4.20-rc1
commit edfa87281f4fa1b78a21f6db999935a2faa2f6b8
category: bugfix
bugzilla: 5544
CVE: NA

---------------------------

Unprotected naming of local variables within bit_clear_unless() can easily
lead to using the wrong scope.

Noticed this by code review after having hit this issue in set_mask_bits()
Signed-off-by: NMiklos Szeredi <mszeredi@redhat.com>
Fixes: 85ad1d13 ("md: set MD_CHANGE_PENDING in a atomic region")
Cc: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: NJason Yan <yanaijie@huawei.com>
Reviewed-by: Nzhengbin <zhengbin13@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 40ddf945
...@@ -251,18 +251,18 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr, ...@@ -251,18 +251,18 @@ static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
#endif #endif
#ifndef bit_clear_unless #ifndef bit_clear_unless
#define bit_clear_unless(ptr, _clear, _test) \ #define bit_clear_unless(ptr, clear, test) \
({ \ ({ \
const typeof(*ptr) clear = (_clear), test = (_test); \ const typeof(*(ptr)) clear__ = (clear), test__ = (test);\
typeof(*ptr) old, new; \ typeof(*(ptr)) old__, new__; \
\ \
do { \ do { \
old = READ_ONCE(*ptr); \ old__ = READ_ONCE(*(ptr)); \
new = old & ~clear; \ new__ = old__ & ~clear__; \
} while (!(old & test) && \ } while (!(old__ & test__) && \
cmpxchg(ptr, old, new) != old); \ cmpxchg(ptr, old__, new__) != old__); \
\ \
!(old & test); \ !(old__ & test__); \
}) })
#endif #endif
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册