Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a2706b39 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mm: slub: reinitialize random sequence cache on slab object update"

parents 674aec04 21fa9258
Loading
Loading
Loading
Loading
+27 −0
Original line number Original line Diff line number Diff line
@@ -1487,6 +1487,25 @@ static int init_cache_random_seq(struct kmem_cache *s)
	return 0;
	return 0;
}
}


/* re-initialize the random sequence cache */
static int reinit_cache_random_seq(struct kmem_cache *s)
{
	int err;

	if (s->random_seq) {
		cache_random_seq_destroy(s);
		err = init_cache_random_seq(s);

		if (err) {
			pr_err("SLUB: Unable to re-initialize random sequence cache for %s\n",
				s->name);
			return err;
		}
	}

	return 0;
}

/* Initialize each random sequence freelist per cache */
/* Initialize each random sequence freelist per cache */
static void __init init_freelist_randomization(void)
static void __init init_freelist_randomization(void)
{
{
@@ -1561,6 +1580,10 @@ static inline int init_cache_random_seq(struct kmem_cache *s)
{
{
	return 0;
	return 0;
}
}
static inline int reinit_cache_random_seq(struct kmem_cache *s)
{
	return 0;
}
static inline void init_freelist_randomization(void) { }
static inline void init_freelist_randomization(void) { }
static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page)
static inline bool shuffle_freelist(struct kmem_cache *s, struct page *page)
{
{
@@ -4935,6 +4958,7 @@ static ssize_t order_store(struct kmem_cache *s,
		return -EINVAL;
		return -EINVAL;


	calculate_sizes(s, order);
	calculate_sizes(s, order);
	reinit_cache_random_seq(s);
	return length;
	return length;
}
}


@@ -5172,6 +5196,7 @@ static ssize_t red_zone_store(struct kmem_cache *s,
		s->flags |= SLAB_RED_ZONE;
		s->flags |= SLAB_RED_ZONE;
	}
	}
	calculate_sizes(s, -1);
	calculate_sizes(s, -1);
	reinit_cache_random_seq(s);
	return length;
	return length;
}
}
SLAB_ATTR(red_zone);
SLAB_ATTR(red_zone);
@@ -5192,6 +5217,7 @@ static ssize_t poison_store(struct kmem_cache *s,
		s->flags |= SLAB_POISON;
		s->flags |= SLAB_POISON;
	}
	}
	calculate_sizes(s, -1);
	calculate_sizes(s, -1);
	reinit_cache_random_seq(s);
	return length;
	return length;
}
}
SLAB_ATTR(poison);
SLAB_ATTR(poison);
@@ -5213,6 +5239,7 @@ static ssize_t store_user_store(struct kmem_cache *s,
		s->flags |= SLAB_STORE_USER;
		s->flags |= SLAB_STORE_USER;
	}
	}
	calculate_sizes(s, -1);
	calculate_sizes(s, -1);
	reinit_cache_random_seq(s);
	return length;
	return length;
}
}
SLAB_ATTR(store_user);
SLAB_ATTR(store_user);