aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Holzheu <holzheu@de.ibm.com>2007-08-10 08:32:34 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2007-08-10 08:32:39 -0400
commit3eed13cc3beaa9ee07b126a662def88f7281394e (patch)
tree61a127b09b0c6ec7bace4a121a046a895710a77d
parent4eac34529bce2b4cca9be90a6903c965baa8193c (diff)
[S390] vmur: diag14 only works with buffers below 2GB
If memory buffers above 2GB are used, diagnose 14 raises a specification exception. This fix ensures that buffer allocation is done below the 2GB boundary. Signed-off-by: Michael Holzheu <holzheu@de.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/char/vmur.c106
1 files changed, 70 insertions, 36 deletions
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c
index a9d58629e795..04b19bdc09da 100644
--- a/drivers/s390/char/vmur.c
+++ b/drivers/s390/char/vmur.c
@@ -472,7 +472,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
472 return rc; 472 return rc;
473 473
474 len = min((size_t) PAGE_SIZE, count); 474 len = min((size_t) PAGE_SIZE, count);
475 buf = kmalloc(PAGE_SIZE, GFP_KERNEL); 475 buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
476 if (!buf) 476 if (!buf)
477 return -ENOMEM; 477 return -ENOMEM;
478 478
@@ -499,7 +499,7 @@ static ssize_t diag14_read(struct file *file, char __user *ubuf, size_t count,
499 *offs += copied; 499 *offs += copied;
500 rc = copied; 500 rc = copied;
501fail: 501fail:
502 kfree(buf); 502 free_page((unsigned long) buf);
503 return rc; 503 return rc;
504} 504}
505 505
@@ -542,63 +542,97 @@ static int diag_read_next_file_info(struct file_control_block *buf, int spid)
542 } 542 }
543} 543}
544 544
545static int verify_device(struct urdev *urd) 545static int verify_uri_device(struct urdev *urd)
546{ 546{
547 struct file_control_block fcb; 547 struct file_control_block *fcb;
548 char *buf; 548 char *buf;
549 int rc; 549 int rc;
550 550
551 fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA);
552 if (!fcb)
553 return -ENOMEM;
554
555 /* check for empty reader device (beginning of chain) */
556 rc = diag_read_next_file_info(fcb, 0);
557 if (rc)
558 goto fail_free_fcb;
559
560 /* if file is in hold status, we do not read it */
561 if (fcb->file_stat & (FLG_SYSTEM_HOLD | FLG_USER_HOLD)) {
562 rc = -EPERM;
563 goto fail_free_fcb;
564 }
565
566 /* open file on virtual reader */
567 buf = (char *) __get_free_page(GFP_KERNEL | GFP_DMA);
568 if (!buf) {
569 rc = -ENOMEM;
570 goto fail_free_fcb;
571 }
572 rc = diag_read_file(urd->dev_id.devno, buf);
573 if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */
574 goto fail_free_buf;
575
576 /* check if the file on top of the queue is open now */
577 rc = diag_read_next_file_info(fcb, 0);
578 if (rc)
579 goto fail_free_buf;
580 if (!(fcb->file_stat & FLG_IN_USE)) {
581 rc = -EMFILE;
582 goto fail_free_buf;
583 }
584 rc = 0;
585
586fail_free_buf:
587 free_page((unsigned long) buf);
588fail_free_fcb:
589 kfree(fcb);
590 return rc;
591}
592
593static int verify_device(struct urdev *urd)
594{
551 switch (urd->class) { 595 switch (urd->class) {
552 case DEV_CLASS_UR_O: 596 case DEV_CLASS_UR_O:
553 return 0; /* no check needed here */ 597 return 0; /* no check needed here */
554 case DEV_CLASS_UR_I: 598 case DEV_CLASS_UR_I:
555 /* check for empty reader device (beginning of chain) */ 599 return verify_uri_device(urd);
556 rc = diag_read_next_file_info(&fcb, 0);
557 if (rc)
558 return rc;
559 /* if file is in hold status, we do not read it */
560 if (fcb.file_stat & (FLG_SYSTEM_HOLD | FLG_USER_HOLD))
561 return -EPERM;
562 /* open file on virtual reader */
563 buf = kmalloc(PAGE_SIZE, GFP_KERNEL);
564 if (!buf)
565 return -ENOMEM;
566 rc = diag_read_file(urd->dev_id.devno, buf);
567 kfree(buf);
568 if ((rc != 0) && (rc != -ENODATA)) /* EOF does not hurt */
569 return rc;
570 /* check if the file on top of the queue is open now */
571 rc = diag_read_next_file_info(&fcb, 0);
572 if (rc)
573 return rc;
574 if (!(fcb.file_stat & FLG_IN_USE))
575 return -EMFILE;
576 return 0;
577 default: 600 default:
578 return -ENOTSUPP; 601 return -ENOTSUPP;
579 } 602 }
580} 603}
581 604
582static int get_file_reclen(struct urdev *urd) 605static int get_uri_file_reclen(struct urdev *urd)
583{ 606{
584 struct file_control_block fcb; 607 struct file_control_block *fcb;
585 int rc; 608 int rc;
586 609
610 fcb = kmalloc(sizeof(*fcb), GFP_KERNEL | GFP_DMA);
611 if (!fcb)
612 return -ENOMEM;
613 rc = diag_read_next_file_info(fcb, 0);
614 if (rc)
615 goto fail_free;
616 if (fcb->file_stat & FLG_CP_DUMP)
617 rc = 0;
618 else
619 rc = fcb->rec_len;
620
621fail_free:
622 kfree(fcb);
623 return rc;
624}
625
626static int get_file_reclen(struct urdev *urd)
627{
587 switch (urd->class) { 628 switch (urd->class) {
588 case DEV_CLASS_UR_O: 629 case DEV_CLASS_UR_O:
589 return 0; 630 return 0;
590 case DEV_CLASS_UR_I: 631 case DEV_CLASS_UR_I:
591 rc = diag_read_next_file_info(&fcb, 0); 632 return get_uri_file_reclen(urd);
592 if (rc)
593 return rc;
594 break;
595 default: 633 default:
596 return -ENOTSUPP; 634 return -ENOTSUPP;
597 } 635 }
598 if (fcb.file_stat & FLG_CP_DUMP)
599 return 0;
600
601 return fcb.rec_len;
602} 636}
603 637
604static int ur_open(struct inode *inode, struct file *file) 638static int ur_open(struct inode *inode, struct file *file)