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

Commit 9ac5f3cf authored by Vivek Kumar's avatar Vivek Kumar Committed by Gerrit - the friendly Code Review server
Browse files

mm: swap: Add randomization check for swapon/off calls



Add addtional check on swapon/swapoff sycalls to disable
randomization of swap offsets if GENHD_FL_NO_RANDOMIZE
flag is passed.

Change-Id: I6f5ce7275f09b812a8954328331545eee0aa77ef
Signed-off-by: default avatarVivek Kumar <vivekuma@codeaurora.org>
parent 696fe917
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2645,7 +2645,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
	if (p->flags & SWP_CONTINUED)
		free_swap_count_continuations(p);

	if (!p->bdev || !blk_queue_nonrot(bdev_get_queue(p->bdev)))
	if (!p->bdev || (p->bdev->bd_disk->flags & GENHD_FL_NO_RANDOMIZE) ||
			!blk_queue_nonrot(bdev_get_queue(p->bdev)))
		atomic_dec(&nr_rotate_swap);

	mutex_lock(&swapon_mutex);
@@ -3220,7 +3221,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
	if (bdi_cap_synchronous_io(inode_to_bdi(inode)))
		p->flags |= SWP_SYNCHRONOUS_IO;

	if (p->bdev && blk_queue_nonrot(bdev_get_queue(p->bdev))) {
	if (p->bdev && !(p->bdev->bd_disk->flags & GENHD_FL_NO_RANDOMIZE) &&
				blk_queue_nonrot(bdev_get_queue(p->bdev))) {
		int cpu;
		unsigned long ci, nr_cluster;