[Devel,vz7,vz7.29.6-mfuse] fuse: ioctl(FUSE_DEV_IOC_SETAFF): add cpu_possible check

Submitted by Maxim Patlasov on March 29, 2017, 9:06 p.m.

Details

Message ID 149082153365.9436.10829530917292522106.stgit@maxim-thinkpad
State New
Series "fuse: ioctl(FUSE_DEV_IOC_SETAFF): add cpu_possible check"
Headers show

Commit Message

Maxim Patlasov March 29, 2017, 9:06 p.m.
It's not enough to check that arg < num_online_cpus() because
cpu mask may be not contiguous. Thanks to AK for pointing out.

https://jira.sw.ru/browse/PSBM-60210

Signed-off-by: Maxim Patlasov <mpatlasov@virtuozzo.com>
---
 fs/fuse/dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c
index 8dd5154..216093d 100644
--- a/fs/fuse/dev.c
+++ b/fs/fuse/dev.c
@@ -2273,7 +2273,7 @@  static long fuse_dev_ioctl(struct file *file, unsigned int cmd,
 			}
 		}
 	} else if (cmd == FUSE_DEV_IOC_SETAFF) {
-		if (arg >= num_online_cpus()) {
+		if (arg >= NR_CPUS || !cpu_possible(arg)) {
 			err = -EINVAL;
 		} else {
 			struct fuse_dev *fud = fuse_get_dev(file);