CHROMIUM: Restrict swapon() to "zram" devices / lock down zram
This cl contains three distinct changes collapsed into
one CL as per semenzato's request:
1. Restrict CONFIG_SWAP to ensure that only zram devices
may be used.
2. Restrict zram to disallow open calls, even from root, if
the device is claimed (e.g., by sys_swapon)
3. Add swapoff fallback when filp_open fails to use the path lookup.
I don't believe swapoff needs filp_open() since kern_path()
provides the data needed without a file object.
4. Add an open counter to zram to ensure that it is not opened more
times than swapon(2) will claim it -- twice:
- blkdev_get and filp_open (for swap_file)
Signed-off-by: Will Drewry <wad@chromium.org>
TEST=tested on lumpy; swapon, swapoff, change zram during swapon fails, change withotu swapon succeeds.
BUG=chromium:220974
Change-Id: Ic281a7004a81b2897cf0bf1c5d334351061261f1
Reviewed-on: https://gerrit.chromium.org/gerrit/46168
Tested-by: Will Drewry <wad@chromium.org>
Reviewed-by: Luigi Semenzato <semenzato@chromium.org>
Commit-Queue: Will Drewry <wad@chromium.org>