Changes since last update:

Fix a regression which uses potential uninitialized
 high 32-bit value unexpectedly recently observed with
 specific compiler options.
 -----BEGIN PGP SIGNATURE-----
 
 iIsEABYIADMWIQThPAmQN9sSA0DVxtI5NzHcH7XmBAUCXvO6thUcaHNpYW5na2Fv
 QHJlZGhhdC5jb20ACgkQOTcx3B+15gT8eQEA/W9d/II6pqD1KD7Oh7K8AIt7kU46
 JTBY6bA/lmMC/GkA/1cqAOxDfEGmWzH5Y/Hz7CLgnsRQYo90i9JZ1tcFAWkK
 =kUeU
 -----END PGP SIGNATURE-----

Merge tag 'erofs-for-5.8-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs

Pull erofs fix from Gao Xiang:
 "Fix a regression which uses potential uninitialized high 32-bit value
  unexpectedly recently observed with specific compiler options"

* tag 'erofs-for-5.8-rc3-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs:
  erofs: fix partially uninitialized misuse in z_erofs_onlinepage_fixup
This commit is contained in:
Linus Torvalds 2020-06-24 17:39:30 -07:00
commit 8be3a53e18
1 changed files with 10 additions and 10 deletions

View File

@ -144,22 +144,22 @@ static inline void z_erofs_onlinepage_init(struct page *page)
static inline void z_erofs_onlinepage_fixup(struct page *page, static inline void z_erofs_onlinepage_fixup(struct page *page,
uintptr_t index, bool down) uintptr_t index, bool down)
{ {
unsigned long *p, o, v, id; union z_erofs_onlinepage_converter u = { .v = &page_private(page) };
repeat: int orig, orig_index, val;
p = &page_private(page);
o = READ_ONCE(*p);
id = o >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT; repeat:
if (id) { orig = atomic_read(u.o);
orig_index = orig >> Z_EROFS_ONLINEPAGE_INDEX_SHIFT;
if (orig_index) {
if (!index) if (!index)
return; return;
DBG_BUGON(id != index); DBG_BUGON(orig_index != index);
} }
v = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) | val = (index << Z_EROFS_ONLINEPAGE_INDEX_SHIFT) |
((o & Z_EROFS_ONLINEPAGE_COUNT_MASK) + (unsigned int)down); ((orig & Z_EROFS_ONLINEPAGE_COUNT_MASK) + (unsigned int)down);
if (cmpxchg(p, o, v) != o) if (atomic_cmpxchg(u.o, orig, val) != orig)
goto repeat; goto repeat;
} }