diff options
author | Chris Wright <chrisw@sous-sol.org> | 2010-05-12 21:28:57 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2010-05-21 12:37:31 -0400 |
commit | 2c3c8bea608866d8bd9dcf92657d57fdcac011c5 (patch) | |
tree | f509b958d0a65c46c831dbdd447a81e706dd995a /drivers/pci/pci-sysfs.c | |
parent | 68d75ed4b84a0806ecd4bc14da4759713b23a532 (diff) |
sysfs: add struct file* to bin_attr callbacks
This allows bin_attr->read,write,mmap callbacks to check file specific data
(such as inode owner) as part of any privilege validation.
Signed-off-by: Chris Wright <chrisw@sous-sol.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/pci/pci-sysfs.c')
-rw-r--r-- | drivers/pci/pci-sysfs.c | 42 |
1 files changed, 30 insertions, 12 deletions
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index fad93983bfed..ad44557e65c4 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -357,7 +357,8 @@ boot_vga_show(struct device *dev, struct device_attribute *attr, char *buf) | |||
357 | struct device_attribute vga_attr = __ATTR_RO(boot_vga); | 357 | struct device_attribute vga_attr = __ATTR_RO(boot_vga); |
358 | 358 | ||
359 | static ssize_t | 359 | static ssize_t |
360 | pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 360 | pci_read_config(struct file *filp, struct kobject *kobj, |
361 | struct bin_attribute *bin_attr, | ||
361 | char *buf, loff_t off, size_t count) | 362 | char *buf, loff_t off, size_t count) |
362 | { | 363 | { |
363 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); | 364 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
@@ -430,7 +431,8 @@ pci_read_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
430 | } | 431 | } |
431 | 432 | ||
432 | static ssize_t | 433 | static ssize_t |
433 | pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, | 434 | pci_write_config(struct file* filp, struct kobject *kobj, |
435 | struct bin_attribute *bin_attr, | ||
434 | char *buf, loff_t off, size_t count) | 436 | char *buf, loff_t off, size_t count) |
435 | { | 437 | { |
436 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); | 438 | struct pci_dev *dev = to_pci_dev(container_of(kobj,struct device,kobj)); |
@@ -487,7 +489,8 @@ pci_write_config(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
487 | } | 489 | } |
488 | 490 | ||
489 | static ssize_t | 491 | static ssize_t |
490 | read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | 492 | read_vpd_attr(struct file *filp, struct kobject *kobj, |
493 | struct bin_attribute *bin_attr, | ||
491 | char *buf, loff_t off, size_t count) | 494 | char *buf, loff_t off, size_t count) |
492 | { | 495 | { |
493 | struct pci_dev *dev = | 496 | struct pci_dev *dev = |
@@ -502,7 +505,8 @@ read_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
502 | } | 505 | } |
503 | 506 | ||
504 | static ssize_t | 507 | static ssize_t |
505 | write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | 508 | write_vpd_attr(struct file *filp, struct kobject *kobj, |
509 | struct bin_attribute *bin_attr, | ||
506 | char *buf, loff_t off, size_t count) | 510 | char *buf, loff_t off, size_t count) |
507 | { | 511 | { |
508 | struct pci_dev *dev = | 512 | struct pci_dev *dev = |
@@ -519,6 +523,7 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
519 | #ifdef HAVE_PCI_LEGACY | 523 | #ifdef HAVE_PCI_LEGACY |
520 | /** | 524 | /** |
521 | * pci_read_legacy_io - read byte(s) from legacy I/O port space | 525 | * pci_read_legacy_io - read byte(s) from legacy I/O port space |
526 | * @filp: open sysfs file | ||
522 | * @kobj: kobject corresponding to file to read from | 527 | * @kobj: kobject corresponding to file to read from |
523 | * @bin_attr: struct bin_attribute for this file | 528 | * @bin_attr: struct bin_attribute for this file |
524 | * @buf: buffer to store results | 529 | * @buf: buffer to store results |
@@ -529,7 +534,8 @@ write_vpd_attr(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
529 | * callback routine (pci_legacy_read). | 534 | * callback routine (pci_legacy_read). |
530 | */ | 535 | */ |
531 | static ssize_t | 536 | static ssize_t |
532 | pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 537 | pci_read_legacy_io(struct file *filp, struct kobject *kobj, |
538 | struct bin_attribute *bin_attr, | ||
533 | char *buf, loff_t off, size_t count) | 539 | char *buf, loff_t off, size_t count) |
534 | { | 540 | { |
535 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 541 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -545,6 +551,7 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
545 | 551 | ||
546 | /** | 552 | /** |
547 | * pci_write_legacy_io - write byte(s) to legacy I/O port space | 553 | * pci_write_legacy_io - write byte(s) to legacy I/O port space |
554 | * @filp: open sysfs file | ||
548 | * @kobj: kobject corresponding to file to read from | 555 | * @kobj: kobject corresponding to file to read from |
549 | * @bin_attr: struct bin_attribute for this file | 556 | * @bin_attr: struct bin_attribute for this file |
550 | * @buf: buffer containing value to be written | 557 | * @buf: buffer containing value to be written |
@@ -555,7 +562,8 @@ pci_read_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
555 | * callback routine (pci_legacy_write). | 562 | * callback routine (pci_legacy_write). |
556 | */ | 563 | */ |
557 | static ssize_t | 564 | static ssize_t |
558 | pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | 565 | pci_write_legacy_io(struct file *filp, struct kobject *kobj, |
566 | struct bin_attribute *bin_attr, | ||
559 | char *buf, loff_t off, size_t count) | 567 | char *buf, loff_t off, size_t count) |
560 | { | 568 | { |
561 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 569 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -570,6 +578,7 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
570 | 578 | ||
571 | /** | 579 | /** |
572 | * pci_mmap_legacy_mem - map legacy PCI memory into user memory space | 580 | * pci_mmap_legacy_mem - map legacy PCI memory into user memory space |
581 | * @filp: open sysfs file | ||
573 | * @kobj: kobject corresponding to device to be mapped | 582 | * @kobj: kobject corresponding to device to be mapped |
574 | * @attr: struct bin_attribute for this file | 583 | * @attr: struct bin_attribute for this file |
575 | * @vma: struct vm_area_struct passed to mmap | 584 | * @vma: struct vm_area_struct passed to mmap |
@@ -579,7 +588,8 @@ pci_write_legacy_io(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
579 | * memory space. | 588 | * memory space. |
580 | */ | 589 | */ |
581 | static int | 590 | static int |
582 | pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | 591 | pci_mmap_legacy_mem(struct file *filp, struct kobject *kobj, |
592 | struct bin_attribute *attr, | ||
583 | struct vm_area_struct *vma) | 593 | struct vm_area_struct *vma) |
584 | { | 594 | { |
585 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 595 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -591,6 +601,7 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
591 | 601 | ||
592 | /** | 602 | /** |
593 | * pci_mmap_legacy_io - map legacy PCI IO into user memory space | 603 | * pci_mmap_legacy_io - map legacy PCI IO into user memory space |
604 | * @filp: open sysfs file | ||
594 | * @kobj: kobject corresponding to device to be mapped | 605 | * @kobj: kobject corresponding to device to be mapped |
595 | * @attr: struct bin_attribute for this file | 606 | * @attr: struct bin_attribute for this file |
596 | * @vma: struct vm_area_struct passed to mmap | 607 | * @vma: struct vm_area_struct passed to mmap |
@@ -600,7 +611,8 @@ pci_mmap_legacy_mem(struct kobject *kobj, struct bin_attribute *attr, | |||
600 | * memory space. Returns -ENOSYS if the operation isn't supported | 611 | * memory space. Returns -ENOSYS if the operation isn't supported |
601 | */ | 612 | */ |
602 | static int | 613 | static int |
603 | pci_mmap_legacy_io(struct kobject *kobj, struct bin_attribute *attr, | 614 | pci_mmap_legacy_io(struct file *filp, struct kobject *kobj, |
615 | struct bin_attribute *attr, | ||
604 | struct vm_area_struct *vma) | 616 | struct vm_area_struct *vma) |
605 | { | 617 | { |
606 | struct pci_bus *bus = to_pci_bus(container_of(kobj, | 618 | struct pci_bus *bus = to_pci_bus(container_of(kobj, |
@@ -750,14 +762,16 @@ pci_mmap_resource(struct kobject *kobj, struct bin_attribute *attr, | |||
750 | } | 762 | } |
751 | 763 | ||
752 | static int | 764 | static int |
753 | pci_mmap_resource_uc(struct kobject *kobj, struct bin_attribute *attr, | 765 | pci_mmap_resource_uc(struct file *filp, struct kobject *kobj, |
766 | struct bin_attribute *attr, | ||
754 | struct vm_area_struct *vma) | 767 | struct vm_area_struct *vma) |
755 | { | 768 | { |
756 | return pci_mmap_resource(kobj, attr, vma, 0); | 769 | return pci_mmap_resource(kobj, attr, vma, 0); |
757 | } | 770 | } |
758 | 771 | ||
759 | static int | 772 | static int |
760 | pci_mmap_resource_wc(struct kobject *kobj, struct bin_attribute *attr, | 773 | pci_mmap_resource_wc(struct file *filp, struct kobject *kobj, |
774 | struct bin_attribute *attr, | ||
761 | struct vm_area_struct *vma) | 775 | struct vm_area_struct *vma) |
762 | { | 776 | { |
763 | return pci_mmap_resource(kobj, attr, vma, 1); | 777 | return pci_mmap_resource(kobj, attr, vma, 1); |
@@ -861,6 +875,7 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; } | |||
861 | 875 | ||
862 | /** | 876 | /** |
863 | * pci_write_rom - used to enable access to the PCI ROM display | 877 | * pci_write_rom - used to enable access to the PCI ROM display |
878 | * @filp: sysfs file | ||
864 | * @kobj: kernel object handle | 879 | * @kobj: kernel object handle |
865 | * @bin_attr: struct bin_attribute for this file | 880 | * @bin_attr: struct bin_attribute for this file |
866 | * @buf: user input | 881 | * @buf: user input |
@@ -870,7 +885,8 @@ void __weak pci_remove_resource_files(struct pci_dev *dev) { return; } | |||
870 | * writing anything except 0 enables it | 885 | * writing anything except 0 enables it |
871 | */ | 886 | */ |
872 | static ssize_t | 887 | static ssize_t |
873 | pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | 888 | pci_write_rom(struct file *filp, struct kobject *kobj, |
889 | struct bin_attribute *bin_attr, | ||
874 | char *buf, loff_t off, size_t count) | 890 | char *buf, loff_t off, size_t count) |
875 | { | 891 | { |
876 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 892 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |
@@ -885,6 +901,7 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
885 | 901 | ||
886 | /** | 902 | /** |
887 | * pci_read_rom - read a PCI ROM | 903 | * pci_read_rom - read a PCI ROM |
904 | * @filp: sysfs file | ||
888 | * @kobj: kernel object handle | 905 | * @kobj: kernel object handle |
889 | * @bin_attr: struct bin_attribute for this file | 906 | * @bin_attr: struct bin_attribute for this file |
890 | * @buf: where to put the data we read from the ROM | 907 | * @buf: where to put the data we read from the ROM |
@@ -895,7 +912,8 @@ pci_write_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | |||
895 | * device corresponding to @kobj. | 912 | * device corresponding to @kobj. |
896 | */ | 913 | */ |
897 | static ssize_t | 914 | static ssize_t |
898 | pci_read_rom(struct kobject *kobj, struct bin_attribute *bin_attr, | 915 | pci_read_rom(struct file *filp, struct kobject *kobj, |
916 | struct bin_attribute *bin_attr, | ||
899 | char *buf, loff_t off, size_t count) | 917 | char *buf, loff_t off, size_t count) |
900 | { | 918 | { |
901 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); | 919 | struct pci_dev *pdev = to_pci_dev(container_of(kobj, struct device, kobj)); |