[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1652860121-24092-5-git-send-email-quic_vivekuma@quicinc.com>
Date: Wed, 18 May 2022 13:18:39 +0530
From: Vivek Kumar <quic_vivekuma@...cinc.com>
To: <corbet@....net>, <catalin.marinas@....com>, <will@...nel.org>,
<tglx@...utronix.de>, <maz@...nel.org>, <axboe@...nel.dk>,
<rafael@...nel.org>, <akpm@...ux-foundation.org>,
<linux-doc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<linux-arm-kernel@...ts.infradead.org>,
<linux-block@...r.kernel.org>, <linux-pm@...r.kernel.org>,
<linux-mm@...ck.org>
CC: <len.brown@...el.com>, <pavel@....cz>, <paulmck@...nel.org>,
<bp@...e.de>, <keescook@...omium.org>, <songmuchun@...edance.com>,
<rdunlap@...radead.org>, <damien.lemoal@...nsource.wdc.com>,
<pasha.tatashin@...een.com>, <tabba@...gle.com>, <ardb@...nel.org>,
<tsoni@...cinc.com>, <quic_psodagud@...cinc.com>,
<quic_svaddagi@...cinc.com>,
Vivek Kumar <quic_vivekuma@...cinc.com>,
Prasanna Kumar <quic_kprasan@...cinc.com>
Subject: [RFC 4/6] 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.
Signed-off-by: Vivek Kumar <quic_vivekuma@...cinc.com>
Signed-off-by: Prasanna Kumar <quic_kprasan@...cinc.com>
---
mm/swapfile.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/mm/swapfile.c b/mm/swapfile.c
index 1c3d5b9..a3eeab6 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2474,7 +2474,8 @@ SYSCALL_DEFINE1(swapoff, const char __user *, specialfile)
if (p->flags & SWP_CONTINUED)
free_swap_count_continuations(p);
- if (!p->bdev || !bdev_nonrot(p->bdev))
+ if (!p->bdev || (p->bdev->bd_disk->flags & GENHD_FL_NO_RANDOMIZE)
+ || !bdev_nonrot(p->bdev))
atomic_dec(&nr_rotate_swap);
mutex_lock(&swapon_mutex);
@@ -3065,7 +3066,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
if (p->bdev && p->bdev->bd_disk->fops->rw_page)
p->flags |= SWP_SYNCHRONOUS_IO;
- if (p->bdev && bdev_nonrot(p->bdev)) {
+ if (p->bdev && !(p->bdev->bd_disk->flags & GENHD_FL_NO_RANDOMIZE) &&
+ bdev_nonrot(p->bdev)) {
int cpu;
unsigned long ci, nr_cluster;
--
2.7.4
Powered by blists - more mailing lists