|
@@ -1022,7 +1022,11 @@ static int shmem_setattr(struct dentry *dentry, struct iattr *attr)
|
|
|
*/
|
|
|
if (IS_ENABLED(CONFIG_TRANSPARENT_HUGE_PAGECACHE)) {
|
|
|
spin_lock(&sbinfo->shrinklist_lock);
|
|
|
- if (list_empty(&info->shrinklist)) {
|
|
|
+ /*
|
|
|
+ * _careful to defend against unlocked access to
|
|
|
+ * ->shrink_list in shmem_unused_huge_shrink()
|
|
|
+ */
|
|
|
+ if (list_empty_careful(&info->shrinklist)) {
|
|
|
list_add_tail(&info->shrinklist,
|
|
|
&sbinfo->shrinklist);
|
|
|
sbinfo->shrinklist_len++;
|
|
@@ -1817,7 +1821,11 @@ alloc_nohuge: page = shmem_alloc_and_acct_page(gfp, info, sbinfo,
|
|
|
* to shrink under memory pressure.
|
|
|
*/
|
|
|
spin_lock(&sbinfo->shrinklist_lock);
|
|
|
- if (list_empty(&info->shrinklist)) {
|
|
|
+ /*
|
|
|
+ * _careful to defend against unlocked access to
|
|
|
+ * ->shrink_list in shmem_unused_huge_shrink()
|
|
|
+ */
|
|
|
+ if (list_empty_careful(&info->shrinklist)) {
|
|
|
list_add_tail(&info->shrinklist,
|
|
|
&sbinfo->shrinklist);
|
|
|
sbinfo->shrinklist_len++;
|