diff options
Diffstat (limited to 'security/selinux/selinuxfs.c')
-rw-r--r-- | security/selinux/selinuxfs.c | 50 |
1 files changed, 20 insertions, 30 deletions
diff --git a/security/selinux/selinuxfs.c b/security/selinux/selinuxfs.c index a45cc971e735..fdc382389720 100644 --- a/security/selinux/selinuxfs.c +++ b/security/selinux/selinuxfs.c | |||
@@ -105,7 +105,7 @@ static ssize_t sel_write_enforce(struct file * file, const char __user * buf, | |||
105 | ssize_t length; | 105 | ssize_t length; |
106 | int new_value; | 106 | int new_value; |
107 | 107 | ||
108 | if (count < 0 || count >= PAGE_SIZE) | 108 | if (count >= PAGE_SIZE) |
109 | return -ENOMEM; | 109 | return -ENOMEM; |
110 | if (*ppos != 0) { | 110 | if (*ppos != 0) { |
111 | /* No partial writes. */ | 111 | /* No partial writes. */ |
@@ -155,7 +155,7 @@ static ssize_t sel_write_disable(struct file * file, const char __user * buf, | |||
155 | int new_value; | 155 | int new_value; |
156 | extern int selinux_disable(void); | 156 | extern int selinux_disable(void); |
157 | 157 | ||
158 | if (count < 0 || count >= PAGE_SIZE) | 158 | if (count >= PAGE_SIZE) |
159 | return -ENOMEM; | 159 | return -ENOMEM; |
160 | if (*ppos != 0) { | 160 | if (*ppos != 0) { |
161 | /* No partial writes. */ | 161 | /* No partial writes. */ |
@@ -242,7 +242,7 @@ static ssize_t sel_write_load(struct file * file, const char __user * buf, | |||
242 | goto out; | 242 | goto out; |
243 | } | 243 | } |
244 | 244 | ||
245 | if ((count < 0) || (count > 64 * 1024 * 1024) | 245 | if ((count > 64 * 1024 * 1024) |
246 | || (data = vmalloc(count)) == NULL) { | 246 | || (data = vmalloc(count)) == NULL) { |
247 | length = -ENOMEM; | 247 | length = -ENOMEM; |
248 | goto out; | 248 | goto out; |
@@ -284,7 +284,7 @@ static ssize_t sel_write_context(struct file * file, const char __user * buf, | |||
284 | if (length) | 284 | if (length) |
285 | return length; | 285 | return length; |
286 | 286 | ||
287 | if (count < 0 || count >= PAGE_SIZE) | 287 | if (count >= PAGE_SIZE) |
288 | return -ENOMEM; | 288 | return -ENOMEM; |
289 | if (*ppos != 0) { | 289 | if (*ppos != 0) { |
290 | /* No partial writes. */ | 290 | /* No partial writes. */ |
@@ -332,7 +332,7 @@ static ssize_t sel_write_checkreqprot(struct file * file, const char __user * bu | |||
332 | if (length) | 332 | if (length) |
333 | return length; | 333 | return length; |
334 | 334 | ||
335 | if (count < 0 || count >= PAGE_SIZE) | 335 | if (count >= PAGE_SIZE) |
336 | return -ENOMEM; | 336 | return -ENOMEM; |
337 | if (*ppos != 0) { | 337 | if (*ppos != 0) { |
338 | /* No partial writes. */ | 338 | /* No partial writes. */ |
@@ -424,15 +424,13 @@ static ssize_t sel_write_access(struct file * file, char *buf, size_t size) | |||
424 | return length; | 424 | return length; |
425 | 425 | ||
426 | length = -ENOMEM; | 426 | length = -ENOMEM; |
427 | scon = kmalloc(size+1, GFP_KERNEL); | 427 | scon = kzalloc(size+1, GFP_KERNEL); |
428 | if (!scon) | 428 | if (!scon) |
429 | return length; | 429 | return length; |
430 | memset(scon, 0, size+1); | ||
431 | 430 | ||
432 | tcon = kmalloc(size+1, GFP_KERNEL); | 431 | tcon = kzalloc(size+1, GFP_KERNEL); |
433 | if (!tcon) | 432 | if (!tcon) |
434 | goto out; | 433 | goto out; |
435 | memset(tcon, 0, size+1); | ||
436 | 434 | ||
437 | length = -EINVAL; | 435 | length = -EINVAL; |
438 | if (sscanf(buf, "%s %s %hu %x", scon, tcon, &tclass, &req) != 4) | 436 | if (sscanf(buf, "%s %s %hu %x", scon, tcon, &tclass, &req) != 4) |
@@ -475,15 +473,13 @@ static ssize_t sel_write_create(struct file * file, char *buf, size_t size) | |||
475 | return length; | 473 | return length; |
476 | 474 | ||
477 | length = -ENOMEM; | 475 | length = -ENOMEM; |
478 | scon = kmalloc(size+1, GFP_KERNEL); | 476 | scon = kzalloc(size+1, GFP_KERNEL); |
479 | if (!scon) | 477 | if (!scon) |
480 | return length; | 478 | return length; |
481 | memset(scon, 0, size+1); | ||
482 | 479 | ||
483 | tcon = kmalloc(size+1, GFP_KERNEL); | 480 | tcon = kzalloc(size+1, GFP_KERNEL); |
484 | if (!tcon) | 481 | if (!tcon) |
485 | goto out; | 482 | goto out; |
486 | memset(tcon, 0, size+1); | ||
487 | 483 | ||
488 | length = -EINVAL; | 484 | length = -EINVAL; |
489 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) | 485 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) |
@@ -536,15 +532,13 @@ static ssize_t sel_write_relabel(struct file * file, char *buf, size_t size) | |||
536 | return length; | 532 | return length; |
537 | 533 | ||
538 | length = -ENOMEM; | 534 | length = -ENOMEM; |
539 | scon = kmalloc(size+1, GFP_KERNEL); | 535 | scon = kzalloc(size+1, GFP_KERNEL); |
540 | if (!scon) | 536 | if (!scon) |
541 | return length; | 537 | return length; |
542 | memset(scon, 0, size+1); | ||
543 | 538 | ||
544 | tcon = kmalloc(size+1, GFP_KERNEL); | 539 | tcon = kzalloc(size+1, GFP_KERNEL); |
545 | if (!tcon) | 540 | if (!tcon) |
546 | goto out; | 541 | goto out; |
547 | memset(tcon, 0, size+1); | ||
548 | 542 | ||
549 | length = -EINVAL; | 543 | length = -EINVAL; |
550 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) | 544 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) |
@@ -595,15 +589,13 @@ static ssize_t sel_write_user(struct file * file, char *buf, size_t size) | |||
595 | return length; | 589 | return length; |
596 | 590 | ||
597 | length = -ENOMEM; | 591 | length = -ENOMEM; |
598 | con = kmalloc(size+1, GFP_KERNEL); | 592 | con = kzalloc(size+1, GFP_KERNEL); |
599 | if (!con) | 593 | if (!con) |
600 | return length; | 594 | return length; |
601 | memset(con, 0, size+1); | ||
602 | 595 | ||
603 | user = kmalloc(size+1, GFP_KERNEL); | 596 | user = kzalloc(size+1, GFP_KERNEL); |
604 | if (!user) | 597 | if (!user) |
605 | goto out; | 598 | goto out; |
606 | memset(user, 0, size+1); | ||
607 | 599 | ||
608 | length = -EINVAL; | 600 | length = -EINVAL; |
609 | if (sscanf(buf, "%s %s", con, user) != 2) | 601 | if (sscanf(buf, "%s %s", con, user) != 2) |
@@ -658,15 +650,13 @@ static ssize_t sel_write_member(struct file * file, char *buf, size_t size) | |||
658 | return length; | 650 | return length; |
659 | 651 | ||
660 | length = -ENOMEM; | 652 | length = -ENOMEM; |
661 | scon = kmalloc(size+1, GFP_KERNEL); | 653 | scon = kzalloc(size+1, GFP_KERNEL); |
662 | if (!scon) | 654 | if (!scon) |
663 | return length; | 655 | return length; |
664 | memset(scon, 0, size+1); | ||
665 | 656 | ||
666 | tcon = kmalloc(size+1, GFP_KERNEL); | 657 | tcon = kzalloc(size+1, GFP_KERNEL); |
667 | if (!tcon) | 658 | if (!tcon) |
668 | goto out; | 659 | goto out; |
669 | memset(tcon, 0, size+1); | ||
670 | 660 | ||
671 | length = -EINVAL; | 661 | length = -EINVAL; |
672 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) | 662 | if (sscanf(buf, "%s %s %hu", scon, tcon, &tclass) != 3) |
@@ -739,7 +729,7 @@ static ssize_t sel_read_bool(struct file *filep, char __user *buf, | |||
739 | if (!filep->f_op) | 729 | if (!filep->f_op) |
740 | goto out; | 730 | goto out; |
741 | 731 | ||
742 | if (count < 0 || count > PAGE_SIZE) { | 732 | if (count > PAGE_SIZE) { |
743 | ret = -EINVAL; | 733 | ret = -EINVAL; |
744 | goto out; | 734 | goto out; |
745 | } | 735 | } |
@@ -800,7 +790,7 @@ static ssize_t sel_write_bool(struct file *filep, const char __user *buf, | |||
800 | if (!filep->f_op) | 790 | if (!filep->f_op) |
801 | goto out; | 791 | goto out; |
802 | 792 | ||
803 | if (count < 0 || count >= PAGE_SIZE) { | 793 | if (count >= PAGE_SIZE) { |
804 | length = -ENOMEM; | 794 | length = -ENOMEM; |
805 | goto out; | 795 | goto out; |
806 | } | 796 | } |
@@ -858,7 +848,7 @@ static ssize_t sel_commit_bools_write(struct file *filep, | |||
858 | if (!filep->f_op) | 848 | if (!filep->f_op) |
859 | goto out; | 849 | goto out; |
860 | 850 | ||
861 | if (count < 0 || count >= PAGE_SIZE) { | 851 | if (count >= PAGE_SIZE) { |
862 | length = -ENOMEM; | 852 | length = -ENOMEM; |
863 | goto out; | 853 | goto out; |
864 | } | 854 | } |
@@ -924,7 +914,7 @@ static void sel_remove_bools(struct dentry *de) | |||
924 | 914 | ||
925 | file_list_lock(); | 915 | file_list_lock(); |
926 | list_for_each(p, &sb->s_files) { | 916 | list_for_each(p, &sb->s_files) { |
927 | struct file * filp = list_entry(p, struct file, f_list); | 917 | struct file * filp = list_entry(p, struct file, f_u.fu_list); |
928 | struct dentry * dentry = filp->f_dentry; | 918 | struct dentry * dentry = filp->f_dentry; |
929 | 919 | ||
930 | if (dentry->d_parent != de) { | 920 | if (dentry->d_parent != de) { |
@@ -1032,7 +1022,7 @@ static ssize_t sel_write_avc_cache_threshold(struct file * file, | |||
1032 | ssize_t ret; | 1022 | ssize_t ret; |
1033 | int new_value; | 1023 | int new_value; |
1034 | 1024 | ||
1035 | if (count < 0 || count >= PAGE_SIZE) { | 1025 | if (count >= PAGE_SIZE) { |
1036 | ret = -ENOMEM; | 1026 | ret = -ENOMEM; |
1037 | goto out; | 1027 | goto out; |
1038 | } | 1028 | } |