aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/linux/swap.h3
-rw-r--r--mm/swapfile.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/include/linux/swap.h b/include/linux/swap.h
index b86b5c20617d..8dc0ea7caf02 100644
--- a/include/linux/swap.h
+++ b/include/linux/swap.h
@@ -21,6 +21,9 @@ struct bio;
21#define SWAP_FLAG_PRIO_SHIFT 0 21#define SWAP_FLAG_PRIO_SHIFT 0
22#define SWAP_FLAG_DISCARD 0x10000 /* discard swap cluster after use */ 22#define SWAP_FLAG_DISCARD 0x10000 /* discard swap cluster after use */
23 23
24#define SWAP_FLAGS_VALID (SWAP_FLAG_PRIO_MASK | SWAP_FLAG_PREFER | \
25 SWAP_FLAG_DISCARD)
26
24static inline int current_is_kswapd(void) 27static inline int current_is_kswapd(void)
25{ 28{
26 return current->flags & PF_KSWAPD; 29 return current->flags & PF_KSWAPD;
diff --git a/mm/swapfile.c b/mm/swapfile.c
index dae42f380d6e..fafc26d1b1dc 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -2022,6 +2022,9 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags)
2022 struct page *page = NULL; 2022 struct page *page = NULL;
2023 struct inode *inode = NULL; 2023 struct inode *inode = NULL;
2024 2024
2025 if (swap_flags & ~SWAP_FLAGS_VALID)
2026 return -EINVAL;
2027
2025 if (!capable(CAP_SYS_ADMIN)) 2028 if (!capable(CAP_SYS_ADMIN))
2026 return -EPERM; 2029 return -EPERM;
2027 2030