diff options
123 files changed, 1402 insertions, 1437 deletions
diff --git a/Documentation/Changes b/Documentation/Changes index 5eaab0441d76..27232be26e1a 100644 --- a/Documentation/Changes +++ b/Documentation/Changes | |||
@@ -237,6 +237,12 @@ udev | |||
237 | udev is a userspace application for populating /dev dynamically with | 237 | udev is a userspace application for populating /dev dynamically with |
238 | only entries for devices actually present. udev replaces devfs. | 238 | only entries for devices actually present. udev replaces devfs. |
239 | 239 | ||
240 | FUSE | ||
241 | ---- | ||
242 | |||
243 | Needs libfuse 2.4.0 or later. Absolute minimum is 2.3.0 but mount | ||
244 | options 'direct_io' and 'kernel_cache' won't work. | ||
245 | |||
240 | Networking | 246 | Networking |
241 | ========== | 247 | ========== |
242 | 248 | ||
@@ -390,6 +396,10 @@ udev | |||
390 | ---- | 396 | ---- |
391 | o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html> | 397 | o <http://www.kernel.org/pub/linux/utils/kernel/hotplug/udev.html> |
392 | 398 | ||
399 | FUSE | ||
400 | ---- | ||
401 | o <http://sourceforge.net/projects/fuse> | ||
402 | |||
393 | Networking | 403 | Networking |
394 | ********** | 404 | ********** |
395 | 405 | ||
diff --git a/Documentation/keys.txt b/Documentation/keys.txt index 0321ded4b9ae..b22e7c8d059a 100644 --- a/Documentation/keys.txt +++ b/Documentation/keys.txt | |||
@@ -195,8 +195,8 @@ KEY ACCESS PERMISSIONS | |||
195 | ====================== | 195 | ====================== |
196 | 196 | ||
197 | Keys have an owner user ID, a group access ID, and a permissions mask. The mask | 197 | Keys have an owner user ID, a group access ID, and a permissions mask. The mask |
198 | has up to eight bits each for user, group and other access. Only five of each | 198 | has up to eight bits each for possessor, user, group and other access. Only |
199 | set of eight bits are defined. These permissions granted are: | 199 | five of each set of eight bits are defined. These permissions granted are: |
200 | 200 | ||
201 | (*) View | 201 | (*) View |
202 | 202 | ||
@@ -241,16 +241,16 @@ about the status of the key service: | |||
241 | type, description and permissions. The payload of the key is not available | 241 | type, description and permissions. The payload of the key is not available |
242 | this way: | 242 | this way: |
243 | 243 | ||
244 | SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY | 244 | SERIAL FLAGS USAGE EXPY PERM UID GID TYPE DESCRIPTION: SUMMARY |
245 | 00000001 I----- 39 perm 1f0000 0 0 keyring _uid_ses.0: 1/4 | 245 | 00000001 I----- 39 perm 1f1f0000 0 0 keyring _uid_ses.0: 1/4 |
246 | 00000002 I----- 2 perm 1f0000 0 0 keyring _uid.0: empty | 246 | 00000002 I----- 2 perm 1f1f0000 0 0 keyring _uid.0: empty |
247 | 00000007 I----- 1 perm 1f0000 0 0 keyring _pid.1: empty | 247 | 00000007 I----- 1 perm 1f1f0000 0 0 keyring _pid.1: empty |
248 | 0000018d I----- 1 perm 1f0000 0 0 keyring _pid.412: empty | 248 | 0000018d I----- 1 perm 1f1f0000 0 0 keyring _pid.412: empty |
249 | 000004d2 I--Q-- 1 perm 1f0000 32 -1 keyring _uid.32: 1/4 | 249 | 000004d2 I--Q-- 1 perm 1f1f0000 32 -1 keyring _uid.32: 1/4 |
250 | 000004d3 I--Q-- 3 perm 1f0000 32 -1 keyring _uid_ses.32: empty | 250 | 000004d3 I--Q-- 3 perm 1f1f0000 32 -1 keyring _uid_ses.32: empty |
251 | 00000892 I--QU- 1 perm 1f0000 0 0 user metal:copper: 0 | 251 | 00000892 I--QU- 1 perm 1f000000 0 0 user metal:copper: 0 |
252 | 00000893 I--Q-N 1 35s 1f0000 0 0 user metal:silver: 0 | 252 | 00000893 I--Q-N 1 35s 1f1f0000 0 0 user metal:silver: 0 |
253 | 00000894 I--Q-- 1 10h 1f0000 0 0 user metal:gold: 0 | 253 | 00000894 I--Q-- 1 10h 001f0000 0 0 user metal:gold: 0 |
254 | 254 | ||
255 | The flags are: | 255 | The flags are: |
256 | 256 | ||
@@ -637,6 +637,34 @@ call, and the key released upon close. How to deal with conflicting keys due to | |||
637 | two different users opening the same file is left to the filesystem author to | 637 | two different users opening the same file is left to the filesystem author to |
638 | solve. | 638 | solve. |
639 | 639 | ||
640 | Note that there are two different types of pointers to keys that may be | ||
641 | encountered: | ||
642 | |||
643 | (*) struct key * | ||
644 | |||
645 | This simply points to the key structure itself. Key structures will be at | ||
646 | least four-byte aligned. | ||
647 | |||
648 | (*) key_ref_t | ||
649 | |||
650 | This is equivalent to a struct key *, but the least significant bit is set | ||
651 | if the caller "possesses" the key. By "possession" it is meant that the | ||
652 | calling processes has a searchable link to the key from one of its | ||
653 | keyrings. There are three functions for dealing with these: | ||
654 | |||
655 | key_ref_t make_key_ref(const struct key *key, | ||
656 | unsigned long possession); | ||
657 | |||
658 | struct key *key_ref_to_ptr(const key_ref_t key_ref); | ||
659 | |||
660 | unsigned long is_key_possessed(const key_ref_t key_ref); | ||
661 | |||
662 | The first function constructs a key reference from a key pointer and | ||
663 | possession information (which must be 0 or 1 and not any other value). | ||
664 | |||
665 | The second function retrieves the key pointer from a reference and the | ||
666 | third retrieves the possession flag. | ||
667 | |||
640 | When accessing a key's payload contents, certain precautions must be taken to | 668 | When accessing a key's payload contents, certain precautions must be taken to |
641 | prevent access vs modification races. See the section "Notes on accessing | 669 | prevent access vs modification races. See the section "Notes on accessing |
642 | payload contents" for more information. | 670 | payload contents" for more information. |
@@ -665,7 +693,11 @@ payload contents" for more information. | |||
665 | 693 | ||
666 | void key_put(struct key *key); | 694 | void key_put(struct key *key); |
667 | 695 | ||
668 | This can be called from interrupt context. If CONFIG_KEYS is not set then | 696 | Or: |
697 | |||
698 | void key_ref_put(key_ref_t key_ref); | ||
699 | |||
700 | These can be called from interrupt context. If CONFIG_KEYS is not set then | ||
669 | the argument will not be parsed. | 701 | the argument will not be parsed. |
670 | 702 | ||
671 | 703 | ||
@@ -689,13 +721,17 @@ payload contents" for more information. | |||
689 | 721 | ||
690 | (*) If a keyring was found in the search, this can be further searched by: | 722 | (*) If a keyring was found in the search, this can be further searched by: |
691 | 723 | ||
692 | struct key *keyring_search(struct key *keyring, | 724 | key_ref_t keyring_search(key_ref_t keyring_ref, |
693 | const struct key_type *type, | 725 | const struct key_type *type, |
694 | const char *description) | 726 | const char *description) |
695 | 727 | ||
696 | This searches the keyring tree specified for a matching key. Error ENOKEY | 728 | This searches the keyring tree specified for a matching key. Error ENOKEY |
697 | is returned upon failure. If successful, the returned key will need to be | 729 | is returned upon failure (use IS_ERR/PTR_ERR to determine). If successful, |
698 | released. | 730 | the returned key will need to be released. |
731 | |||
732 | The possession attribute from the keyring reference is used to control | ||
733 | access through the permissions mask and is propagated to the returned key | ||
734 | reference pointer if successful. | ||
699 | 735 | ||
700 | 736 | ||
701 | (*) To check the validity of a key, this function can be called: | 737 | (*) To check the validity of a key, this function can be called: |
@@ -732,7 +768,7 @@ More complex payload contents must be allocated and a pointer to them set in | |||
732 | key->payload.data. One of the following ways must be selected to access the | 768 | key->payload.data. One of the following ways must be selected to access the |
733 | data: | 769 | data: |
734 | 770 | ||
735 | (1) Unmodifyable key type. | 771 | (1) Unmodifiable key type. |
736 | 772 | ||
737 | If the key type does not have a modify method, then the key's payload can | 773 | If the key type does not have a modify method, then the key's payload can |
738 | be accessed without any form of locking, provided that it's known to be | 774 | be accessed without any form of locking, provided that it's known to be |
diff --git a/MAINTAINERS b/MAINTAINERS index 7d1dd5bad39a..c1bc9a86a99d 100644 --- a/MAINTAINERS +++ b/MAINTAINERS | |||
@@ -604,6 +604,15 @@ P: H. Peter Anvin | |||
604 | M: hpa@zytor.com | 604 | M: hpa@zytor.com |
605 | S: Maintained | 605 | S: Maintained |
606 | 606 | ||
607 | CPUSETS | ||
608 | P: Paul Jackson | ||
609 | P: Simon Derr | ||
610 | M: pj@sgi.com | ||
611 | M: simon.derr@bull.net | ||
612 | L: linux-kernel@vger.kernel.org | ||
613 | W: http://www.bullopensource.org/cpuset/ | ||
614 | S: Supported | ||
615 | |||
607 | CRAMFS FILESYSTEM | 616 | CRAMFS FILESYSTEM |
608 | W: http://sourceforge.net/projects/cramfs/ | 617 | W: http://sourceforge.net/projects/cramfs/ |
609 | S: Orphan | 618 | S: Orphan |
@@ -1906,6 +1915,13 @@ M: joern@wh.fh-wedel.de | |||
1906 | L: linux-mtd@lists.infradead.org | 1915 | L: linux-mtd@lists.infradead.org |
1907 | S: Maintained | 1916 | S: Maintained |
1908 | 1917 | ||
1918 | PKTCDVD DRIVER | ||
1919 | P: Peter Osterlund | ||
1920 | M: petero2@telia.com | ||
1921 | L: linux-kernel@vger.kernel.org | ||
1922 | L: packet-writing@suse.com | ||
1923 | S: Maintained | ||
1924 | |||
1909 | POSIX CLOCKS and TIMERS | 1925 | POSIX CLOCKS and TIMERS |
1910 | P: George Anzinger | 1926 | P: George Anzinger |
1911 | M: george@mvista.com | 1927 | M: george@mvista.com |
diff --git a/arch/arm/mach-versatile/core.c b/arch/arm/mach-versatile/core.c index 3c8862fde51a..58c1330d8638 100644 --- a/arch/arm/mach-versatile/core.c +++ b/arch/arm/mach-versatile/core.c | |||
@@ -52,8 +52,9 @@ | |||
52 | * | 52 | * |
53 | * Setup a VA for the Versatile Vectored Interrupt Controller. | 53 | * Setup a VA for the Versatile Vectored Interrupt Controller. |
54 | */ | 54 | */ |
55 | #define VA_VIC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) | 55 | #define __io_address(n) __io(IO_ADDRESS(n)) |
56 | #define VA_SIC_BASE IO_ADDRESS(VERSATILE_SIC_BASE) | 56 | #define VA_VIC_BASE __io_address(VERSATILE_VIC_BASE) |
57 | #define VA_SIC_BASE __io_address(VERSATILE_SIC_BASE) | ||
57 | 58 | ||
58 | static void vic_mask_irq(unsigned int irq) | 59 | static void vic_mask_irq(unsigned int irq) |
59 | { | 60 | { |
@@ -214,7 +215,7 @@ void __init versatile_map_io(void) | |||
214 | iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc)); | 215 | iotable_init(versatile_io_desc, ARRAY_SIZE(versatile_io_desc)); |
215 | } | 216 | } |
216 | 217 | ||
217 | #define VERSATILE_REFCOUNTER (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) | 218 | #define VERSATILE_REFCOUNTER (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_24MHz_OFFSET) |
218 | 219 | ||
219 | /* | 220 | /* |
220 | * This is the Versatile sched_clock implementation. This has | 221 | * This is the Versatile sched_clock implementation. This has |
@@ -231,7 +232,7 @@ unsigned long long sched_clock(void) | |||
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
234 | #define VERSATILE_FLASHCTRL (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET) | 235 | #define VERSATILE_FLASHCTRL (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_FLASH_OFFSET) |
235 | 236 | ||
236 | static int versatile_flash_init(void) | 237 | static int versatile_flash_init(void) |
237 | { | 238 | { |
@@ -309,7 +310,7 @@ static struct platform_device smc91x_device = { | |||
309 | .resource = smc91x_resources, | 310 | .resource = smc91x_resources, |
310 | }; | 311 | }; |
311 | 312 | ||
312 | #define VERSATILE_SYSMCI (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) | 313 | #define VERSATILE_SYSMCI (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_MCI_OFFSET) |
313 | 314 | ||
314 | unsigned int mmc_status(struct device *dev) | 315 | unsigned int mmc_status(struct device *dev) |
315 | { | 316 | { |
@@ -343,11 +344,11 @@ static const struct icst307_params versatile_oscvco_params = { | |||
343 | 344 | ||
344 | static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco) | 345 | static void versatile_oscvco_set(struct clk *clk, struct icst307_vco vco) |
345 | { | 346 | { |
346 | unsigned long sys_lock = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET; | 347 | void __iomem *sys_lock = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LOCK_OFFSET; |
347 | #if defined(CONFIG_ARCH_VERSATILE_PB) | 348 | #if defined(CONFIG_ARCH_VERSATILE_PB) |
348 | unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET; | 349 | void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC4_OFFSET; |
349 | #elif defined(CONFIG_MACH_VERSATILE_AB) | 350 | #elif defined(CONFIG_MACH_VERSATILE_AB) |
350 | unsigned long sys_osc = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET; | 351 | void __iomem *sys_osc = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_OSC1_OFFSET; |
351 | #endif | 352 | #endif |
352 | u32 val; | 353 | u32 val; |
353 | 354 | ||
@@ -483,7 +484,7 @@ static struct clcd_panel epson_2_2_in = { | |||
483 | */ | 484 | */ |
484 | static struct clcd_panel *versatile_clcd_panel(void) | 485 | static struct clcd_panel *versatile_clcd_panel(void) |
485 | { | 486 | { |
486 | unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; | 487 | void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; |
487 | struct clcd_panel *panel = &vga; | 488 | struct clcd_panel *panel = &vga; |
488 | u32 val; | 489 | u32 val; |
489 | 490 | ||
@@ -510,7 +511,7 @@ static struct clcd_panel *versatile_clcd_panel(void) | |||
510 | */ | 511 | */ |
511 | static void versatile_clcd_disable(struct clcd_fb *fb) | 512 | static void versatile_clcd_disable(struct clcd_fb *fb) |
512 | { | 513 | { |
513 | unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; | 514 | void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; |
514 | u32 val; | 515 | u32 val; |
515 | 516 | ||
516 | val = readl(sys_clcd); | 517 | val = readl(sys_clcd); |
@@ -522,7 +523,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb) | |||
522 | * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off | 523 | * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light off |
523 | */ | 524 | */ |
524 | if (fb->panel == &sanyo_2_5_in) { | 525 | if (fb->panel == &sanyo_2_5_in) { |
525 | unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); | 526 | void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL); |
526 | unsigned long ctrl; | 527 | unsigned long ctrl; |
527 | 528 | ||
528 | ctrl = readl(versatile_ib2_ctrl); | 529 | ctrl = readl(versatile_ib2_ctrl); |
@@ -537,7 +538,7 @@ static void versatile_clcd_disable(struct clcd_fb *fb) | |||
537 | */ | 538 | */ |
538 | static void versatile_clcd_enable(struct clcd_fb *fb) | 539 | static void versatile_clcd_enable(struct clcd_fb *fb) |
539 | { | 540 | { |
540 | unsigned long sys_clcd = IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; | 541 | void __iomem *sys_clcd = __io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_CLCD_OFFSET; |
541 | u32 val; | 542 | u32 val; |
542 | 543 | ||
543 | val = readl(sys_clcd); | 544 | val = readl(sys_clcd); |
@@ -571,7 +572,7 @@ static void versatile_clcd_enable(struct clcd_fb *fb) | |||
571 | * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on | 572 | * If the LCD is Sanyo 2x5 in on the IB2 board, turn the back-light on |
572 | */ | 573 | */ |
573 | if (fb->panel == &sanyo_2_5_in) { | 574 | if (fb->panel == &sanyo_2_5_in) { |
574 | unsigned long versatile_ib2_ctrl = IO_ADDRESS(VERSATILE_IB2_CTRL); | 575 | void __iomem *versatile_ib2_ctrl = __io_address(VERSATILE_IB2_CTRL); |
575 | unsigned long ctrl; | 576 | unsigned long ctrl; |
576 | 577 | ||
577 | ctrl = readl(versatile_ib2_ctrl); | 578 | ctrl = readl(versatile_ib2_ctrl); |
@@ -720,7 +721,7 @@ static struct amba_device *amba_devs[] __initdata = { | |||
720 | }; | 721 | }; |
721 | 722 | ||
722 | #ifdef CONFIG_LEDS | 723 | #ifdef CONFIG_LEDS |
723 | #define VA_LEDS_BASE (IO_ADDRESS(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) | 724 | #define VA_LEDS_BASE (__io_address(VERSATILE_SYS_BASE) + VERSATILE_SYS_LED_OFFSET) |
724 | 725 | ||
725 | static void versatile_leds_event(led_event_t ledevt) | 726 | static void versatile_leds_event(led_event_t ledevt) |
726 | { | 727 | { |
@@ -778,11 +779,11 @@ void __init versatile_init(void) | |||
778 | /* | 779 | /* |
779 | * Where is the timer (VA)? | 780 | * Where is the timer (VA)? |
780 | */ | 781 | */ |
781 | #define TIMER0_VA_BASE IO_ADDRESS(VERSATILE_TIMER0_1_BASE) | 782 | #define TIMER0_VA_BASE __io_address(VERSATILE_TIMER0_1_BASE) |
782 | #define TIMER1_VA_BASE (IO_ADDRESS(VERSATILE_TIMER0_1_BASE) + 0x20) | 783 | #define TIMER1_VA_BASE (__io_address(VERSATILE_TIMER0_1_BASE) + 0x20) |
783 | #define TIMER2_VA_BASE IO_ADDRESS(VERSATILE_TIMER2_3_BASE) | 784 | #define TIMER2_VA_BASE __io_address(VERSATILE_TIMER2_3_BASE) |
784 | #define TIMER3_VA_BASE (IO_ADDRESS(VERSATILE_TIMER2_3_BASE) + 0x20) | 785 | #define TIMER3_VA_BASE (__io_address(VERSATILE_TIMER2_3_BASE) + 0x20) |
785 | #define VA_IC_BASE IO_ADDRESS(VERSATILE_VIC_BASE) | 786 | #define VA_IC_BASE __io_address(VERSATILE_VIC_BASE) |
786 | 787 | ||
787 | /* | 788 | /* |
788 | * How long is the timer interval? | 789 | * How long is the timer interval? |
@@ -877,12 +878,12 @@ static void __init versatile_timer_init(void) | |||
877 | * VERSATILE_REFCLK is 32KHz | 878 | * VERSATILE_REFCLK is 32KHz |
878 | * VERSATILE_TIMCLK is 1MHz | 879 | * VERSATILE_TIMCLK is 1MHz |
879 | */ | 880 | */ |
880 | val = readl(IO_ADDRESS(VERSATILE_SCTL_BASE)); | 881 | val = readl(__io_address(VERSATILE_SCTL_BASE)); |
881 | writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | | 882 | writel((VERSATILE_TIMCLK << VERSATILE_TIMER1_EnSel) | |
882 | (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | | 883 | (VERSATILE_TIMCLK << VERSATILE_TIMER2_EnSel) | |
883 | (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | | 884 | (VERSATILE_TIMCLK << VERSATILE_TIMER3_EnSel) | |
884 | (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, | 885 | (VERSATILE_TIMCLK << VERSATILE_TIMER4_EnSel) | val, |
885 | IO_ADDRESS(VERSATILE_SCTL_BASE)); | 886 | __io_address(VERSATILE_SCTL_BASE)); |
886 | 887 | ||
887 | /* | 888 | /* |
888 | * Initialise to a known state (all timers off) | 889 | * Initialise to a known state (all timers off) |
diff --git a/arch/ppc/boot/ld.script b/arch/ppc/boot/ld.script index 9362193742ac..d4dd8f15395e 100644 --- a/arch/ppc/boot/ld.script +++ b/arch/ppc/boot/ld.script | |||
@@ -1,4 +1,4 @@ | |||
1 | OUTPUT_ARCH(powerpc) | 1 | OUTPUT_ARCH(powerpc:common) |
2 | SECTIONS | 2 | SECTIONS |
3 | { | 3 | { |
4 | /* Read-only sections, merged into text segment: */ | 4 | /* Read-only sections, merged into text segment: */ |
diff --git a/arch/ppc/kernel/perfmon.c b/arch/ppc/kernel/perfmon.c index 04c18788e85f..22df9a596a0f 100644 --- a/arch/ppc/kernel/perfmon.c +++ b/arch/ppc/kernel/perfmon.c | |||
@@ -45,9 +45,8 @@ static void dummy_perf(struct pt_regs *regs) | |||
45 | mtpmr(PMRN_PMGC0, pmgc0); | 45 | mtpmr(PMRN_PMGC0, pmgc0); |
46 | } | 46 | } |
47 | 47 | ||
48 | #elif CONFIG_6xx | 48 | #elif defined(CONFIG_6xx) |
49 | /* Ensure exceptions are disabled */ | 49 | /* Ensure exceptions are disabled */ |
50 | |||
51 | static void dummy_perf(struct pt_regs *regs) | 50 | static void dummy_perf(struct pt_regs *regs) |
52 | { | 51 | { |
53 | unsigned int mmcr0 = mfspr(SPRN_MMCR0); | 52 | unsigned int mmcr0 = mfspr(SPRN_MMCR0); |
diff --git a/arch/ppc/syslib/mv64x60.c b/arch/ppc/syslib/mv64x60.c index 839f8872826f..4849850a59ed 100644 --- a/arch/ppc/syslib/mv64x60.c +++ b/arch/ppc/syslib/mv64x60.c | |||
@@ -34,7 +34,7 @@ u8 mv64x60_pci_exclude_bridge = 1; | |||
34 | DEFINE_SPINLOCK(mv64x60_lock); | 34 | DEFINE_SPINLOCK(mv64x60_lock); |
35 | 35 | ||
36 | static phys_addr_t mv64x60_bridge_pbase; | 36 | static phys_addr_t mv64x60_bridge_pbase; |
37 | static void *mv64x60_bridge_vbase; | 37 | static void __iomem *mv64x60_bridge_vbase; |
38 | static u32 mv64x60_bridge_type = MV64x60_TYPE_INVALID; | 38 | static u32 mv64x60_bridge_type = MV64x60_TYPE_INVALID; |
39 | static u32 mv64x60_bridge_rev; | 39 | static u32 mv64x60_bridge_rev; |
40 | #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) | 40 | #if defined(CONFIG_SYSFS) && !defined(CONFIG_GT64260) |
@@ -938,7 +938,7 @@ mv64x60_setup_for_chip(struct mv64x60_handle *bh) | |||
938 | * | 938 | * |
939 | * Return the virtual address of the bridge's registers. | 939 | * Return the virtual address of the bridge's registers. |
940 | */ | 940 | */ |
941 | void * | 941 | void __iomem * |
942 | mv64x60_get_bridge_vbase(void) | 942 | mv64x60_get_bridge_vbase(void) |
943 | { | 943 | { |
944 | return mv64x60_bridge_vbase; | 944 | return mv64x60_bridge_vbase; |
diff --git a/arch/ppc64/kernel/machine_kexec.c b/arch/ppc64/kernel/machine_kexec.c index 4775f12a013c..bf7cc4f8210f 100644 --- a/arch/ppc64/kernel/machine_kexec.c +++ b/arch/ppc64/kernel/machine_kexec.c | |||
@@ -205,6 +205,7 @@ static void kexec_prepare_cpus(void) | |||
205 | continue; | 205 | continue; |
206 | 206 | ||
207 | while (paca[i].hw_cpu_id != -1) { | 207 | while (paca[i].hw_cpu_id != -1) { |
208 | barrier(); | ||
208 | if (!cpu_possible(i)) { | 209 | if (!cpu_possible(i)) { |
209 | printk("kexec: cpu %d hw_cpu_id %d is not" | 210 | printk("kexec: cpu %d hw_cpu_id %d is not" |
210 | " possible, ignoring\n", | 211 | " possible, ignoring\n", |
diff --git a/arch/ppc64/mm/hash_native.c b/arch/ppc64/mm/hash_native.c index eb1bbb5b6c16..bfd385b7713c 100644 --- a/arch/ppc64/mm/hash_native.c +++ b/arch/ppc64/mm/hash_native.c | |||
@@ -343,7 +343,7 @@ static void native_flush_hash_range(unsigned long context, | |||
343 | hpte_t *hptep; | 343 | hpte_t *hptep; |
344 | unsigned long hpte_v; | 344 | unsigned long hpte_v; |
345 | struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); | 345 | struct ppc64_tlb_batch *batch = &__get_cpu_var(ppc64_tlb_batch); |
346 | unsigned long large; | 346 | unsigned long large = batch->large; |
347 | 347 | ||
348 | local_irq_save(flags); | 348 | local_irq_save(flags); |
349 | 349 | ||
@@ -356,7 +356,6 @@ static void native_flush_hash_range(unsigned long context, | |||
356 | 356 | ||
357 | va = (vsid << 28) | (batch->addr[i] & 0x0fffffff); | 357 | va = (vsid << 28) | (batch->addr[i] & 0x0fffffff); |
358 | batch->vaddr[j] = va; | 358 | batch->vaddr[j] = va; |
359 | large = pte_huge(batch->pte[i]); | ||
360 | if (large) | 359 | if (large) |
361 | vpn = va >> HPAGE_SHIFT; | 360 | vpn = va >> HPAGE_SHIFT; |
362 | else | 361 | else |
@@ -406,7 +405,7 @@ static void native_flush_hash_range(unsigned long context, | |||
406 | asm volatile("ptesync":::"memory"); | 405 | asm volatile("ptesync":::"memory"); |
407 | 406 | ||
408 | for (i = 0; i < j; i++) | 407 | for (i = 0; i < j; i++) |
409 | __tlbie(batch->vaddr[i], 0); | 408 | __tlbie(batch->vaddr[i], large); |
410 | 409 | ||
411 | asm volatile("eieio; tlbsync; ptesync":::"memory"); | 410 | asm volatile("eieio; tlbsync; ptesync":::"memory"); |
412 | 411 | ||
diff --git a/arch/ppc64/mm/tlb.c b/arch/ppc64/mm/tlb.c index d8a6593a13f0..21fbffb23a43 100644 --- a/arch/ppc64/mm/tlb.c +++ b/arch/ppc64/mm/tlb.c | |||
@@ -143,7 +143,8 @@ void hpte_update(struct mm_struct *mm, unsigned long addr, | |||
143 | * up scanning and resetting referenced bits then our batch context | 143 | * up scanning and resetting referenced bits then our batch context |
144 | * will change mid stream. | 144 | * will change mid stream. |
145 | */ | 145 | */ |
146 | if (unlikely(i != 0 && context != batch->context)) { | 146 | if (i != 0 && (context != batch->context || |
147 | batch->large != pte_huge(pte))) { | ||
147 | flush_tlb_pending(); | 148 | flush_tlb_pending(); |
148 | i = 0; | 149 | i = 0; |
149 | } | 150 | } |
@@ -151,6 +152,7 @@ void hpte_update(struct mm_struct *mm, unsigned long addr, | |||
151 | if (i == 0) { | 152 | if (i == 0) { |
152 | batch->context = context; | 153 | batch->context = context; |
153 | batch->mm = mm; | 154 | batch->mm = mm; |
155 | batch->large = pte_huge(pte); | ||
154 | } | 156 | } |
155 | batch->pte[i] = __pte(pte); | 157 | batch->pte[i] = __pte(pte); |
156 | batch->addr[i] = addr; | 158 | batch->addr[i] = addr; |
diff --git a/arch/s390/kernel/compat_signal.c b/arch/s390/kernel/compat_signal.c index 7358cdb8441f..4ff6808456ea 100644 --- a/arch/s390/kernel/compat_signal.c +++ b/arch/s390/kernel/compat_signal.c | |||
@@ -143,7 +143,7 @@ int copy_siginfo_from_user32(siginfo_t *to, compat_siginfo_t __user *from) | |||
143 | break; | 143 | break; |
144 | case __SI_FAULT >> 16: | 144 | case __SI_FAULT >> 16: |
145 | err |= __get_user(tmp, &from->si_addr); | 145 | err |= __get_user(tmp, &from->si_addr); |
146 | to->si_addr = (void *)(u64) (tmp & PSW32_ADDR_INSN); | 146 | to->si_addr = (void __user *)(u64) (tmp & PSW32_ADDR_INSN); |
147 | break; | 147 | break; |
148 | case __SI_POLL >> 16: | 148 | case __SI_POLL >> 16: |
149 | err |= __get_user(to->si_band, &from->si_band); | 149 | err |= __get_user(to->si_band, &from->si_band); |
@@ -338,7 +338,7 @@ sys32_sigaltstack(const stack_t32 __user *uss, stack_t32 __user *uoss, | |||
338 | err |= __get_user(kss.ss_flags, &uss->ss_flags); | 338 | err |= __get_user(kss.ss_flags, &uss->ss_flags); |
339 | if (err) | 339 | if (err) |
340 | return -EFAULT; | 340 | return -EFAULT; |
341 | kss.ss_sp = (void *) ss_sp; | 341 | kss.ss_sp = (void __user *) ss_sp; |
342 | } | 342 | } |
343 | 343 | ||
344 | set_fs (KERNEL_DS); | 344 | set_fs (KERNEL_DS); |
@@ -461,7 +461,7 @@ asmlinkage long sys32_rt_sigreturn(struct pt_regs *regs) | |||
461 | goto badframe; | 461 | goto badframe; |
462 | 462 | ||
463 | err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp); | 463 | err = __get_user(ss_sp, &frame->uc.uc_stack.ss_sp); |
464 | st.ss_sp = (void *) A((unsigned long)ss_sp); | 464 | st.ss_sp = compat_ptr(ss_sp); |
465 | err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size); | 465 | err |= __get_user(st.ss_size, &frame->uc.uc_stack.ss_size); |
466 | err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags); | 466 | err |= __get_user(st.ss_flags, &frame->uc.uc_stack.ss_flags); |
467 | if (err) | 467 | if (err) |
diff --git a/arch/s390/kernel/signal.c b/arch/s390/kernel/signal.c index 6a3f5b7473a9..6e0110d71191 100644 --- a/arch/s390/kernel/signal.c +++ b/arch/s390/kernel/signal.c | |||
@@ -376,8 +376,8 @@ static void setup_rt_frame(int sig, struct k_sigaction *ka, siginfo_t *info, | |||
376 | 376 | ||
377 | /* Create the ucontext. */ | 377 | /* Create the ucontext. */ |
378 | err |= __put_user(0, &frame->uc.uc_flags); | 378 | err |= __put_user(0, &frame->uc.uc_flags); |
379 | err |= __put_user(0, &frame->uc.uc_link); | 379 | err |= __put_user(NULL, &frame->uc.uc_link); |
380 | err |= __put_user((void *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); | 380 | err |= __put_user((void __user *)current->sas_ss_sp, &frame->uc.uc_stack.ss_sp); |
381 | err |= __put_user(sas_ss_flags(regs->gprs[15]), | 381 | err |= __put_user(sas_ss_flags(regs->gprs[15]), |
382 | &frame->uc.uc_stack.ss_flags); | 382 | &frame->uc.uc_stack.ss_flags); |
383 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); | 383 | err |= __put_user(current->sas_ss_size, &frame->uc.uc_stack.ss_size); |
diff --git a/arch/um/Makefile b/arch/um/Makefile index 5b5af95721ab..7af37e342e33 100644 --- a/arch/um/Makefile +++ b/arch/um/Makefile | |||
@@ -28,8 +28,6 @@ SYMLINK_HEADERS := $(foreach header,$(SYMLINK_HEADERS),include/asm-um/$(header)) | |||
28 | ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ | 28 | ARCH_SYMLINKS = include/asm-um/arch $(ARCH_DIR)/include/sysdep $(ARCH_DIR)/os \ |
29 | $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h | 29 | $(SYMLINK_HEADERS) $(ARCH_DIR)/include/uml-config.h |
30 | 30 | ||
31 | GEN_HEADERS += $(ARCH_DIR)/include/task.h $(ARCH_DIR)/include/kern_constants.h | ||
32 | |||
33 | um-modes-$(CONFIG_MODE_TT) += tt | 31 | um-modes-$(CONFIG_MODE_TT) += tt |
34 | um-modes-$(CONFIG_MODE_SKAS) += skas | 32 | um-modes-$(CONFIG_MODE_SKAS) += skas |
35 | 33 | ||
@@ -45,9 +43,7 @@ endif | |||
45 | 43 | ||
46 | ARCH_INCLUDE := -I$(ARCH_DIR)/include | 44 | ARCH_INCLUDE := -I$(ARCH_DIR)/include |
47 | ifneq ($(KBUILD_SRC),) | 45 | ifneq ($(KBUILD_SRC),) |
48 | ARCH_INCLUDE += -I$(ARCH_DIR)/include2 | ||
49 | ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include | 46 | ARCH_INCLUDE += -I$(srctree)/$(ARCH_DIR)/include |
50 | MRPROPER_DIRS += $(ARCH_DIR)/include2 | ||
51 | endif | 47 | endif |
52 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) | 48 | SYS_DIR := $(ARCH_DIR)/include/sysdep-$(SUBARCH) |
53 | 49 | ||
@@ -87,10 +83,6 @@ CONFIG_KERNEL_HALF_GIGS ?= 0 | |||
87 | 83 | ||
88 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) | 84 | SIZE = (($(CONFIG_NEST_LEVEL) + $(CONFIG_KERNEL_HALF_GIGS)) * 0x20000000) |
89 | 85 | ||
90 | ifeq ($(CONFIG_MODE_SKAS), y) | ||
91 | $(SYS_HEADERS) : $(ARCH_DIR)/include/skas_ptregs.h | ||
92 | endif | ||
93 | |||
94 | .PHONY: linux | 86 | .PHONY: linux |
95 | 87 | ||
96 | all: linux | 88 | all: linux |
@@ -111,7 +103,8 @@ else | |||
111 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) | 103 | $(shell cd $(ARCH_DIR) && ln -sf Kconfig.$(SUBARCH) Kconfig.arch) |
112 | endif | 104 | endif |
113 | 105 | ||
114 | archprepare: $(ARCH_SYMLINKS) $(SYS_HEADERS) $(GEN_HEADERS) | 106 | archprepare: $(ARCH_SYMLINKS) $(ARCH_DIR)/include/user_constants.h |
107 | prepare: $(ARCH_DIR)/include/kern_constants.h | ||
115 | 108 | ||
116 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static | 109 | LINK-$(CONFIG_LD_SCRIPT_STATIC) += -static |
117 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib | 110 | LINK-$(CONFIG_LD_SCRIPT_DYN) += -Wl,-rpath,/lib |
@@ -146,15 +139,13 @@ endef | |||
146 | #When cleaning we don't include .config, so we don't include | 139 | #When cleaning we don't include .config, so we don't include |
147 | #TT or skas makefiles and don't clean skas_ptregs.h. | 140 | #TT or skas makefiles and don't clean skas_ptregs.h. |
148 | CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ | 141 | CLEAN_FILES += linux x.i gmon.out $(ARCH_DIR)/include/uml-config.h \ |
149 | $(GEN_HEADERS) $(ARCH_DIR)/include/skas_ptregs.h \ | 142 | $(ARCH_DIR)/include/user_constants.h \ |
150 | $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/Kconfig.arch | 143 | $(ARCH_DIR)/include/kern_constants.h $(ARCH_DIR)/Kconfig.arch |
151 | 144 | ||
152 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ | 145 | MRPROPER_FILES += $(SYMLINK_HEADERS) $(ARCH_SYMLINKS) \ |
153 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os | 146 | $(addprefix $(ARCH_DIR)/kernel/,$(KERN_SYMLINKS)) $(ARCH_DIR)/os |
154 | 147 | ||
155 | archclean: | 148 | archclean: |
156 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/util | ||
157 | $(Q)$(MAKE) $(clean)=$(ARCH_DIR)/os-$(OS)/util | ||
158 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ | 149 | @find . \( -name '*.bb' -o -name '*.bbg' -o -name '*.da' \ |
159 | -o -name '*.gcov' \) -type f -print | xargs rm -f | 150 | -o -name '*.gcov' \) -type f -print | xargs rm -f |
160 | 151 | ||
@@ -180,9 +171,7 @@ $(ARCH_DIR)/include/sysdep: | |||
180 | @echo ' SYMLINK $@' | 171 | @echo ' SYMLINK $@' |
181 | ifneq ($(KBUILD_SRC),) | 172 | ifneq ($(KBUILD_SRC),) |
182 | $(Q)mkdir -p $(ARCH_DIR)/include | 173 | $(Q)mkdir -p $(ARCH_DIR)/include |
183 | $(Q)mkdir -p $(ARCH_DIR)/include2 | 174 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep |
184 | $(Q)ln -fsn sysdep-$(SUBARCH) $(ARCH_DIR)/include/sysdep | ||
185 | $(Q)ln -fsn $(srctree)/$(ARCH_DIR)/include/sysdep-$(SUBARCH) $(ARCH_DIR)/include2/sysdep | ||
186 | else | 175 | else |
187 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep | 176 | $(Q)cd $(ARCH_DIR)/include && ln -sf sysdep-$(SUBARCH) sysdep |
188 | endif | 177 | endif |
@@ -202,8 +191,6 @@ endef | |||
202 | 191 | ||
203 | define filechk_gen-asm-offsets | 192 | define filechk_gen-asm-offsets |
204 | (set -e; \ | 193 | (set -e; \ |
205 | echo "#ifndef __ASM_OFFSETS_H__"; \ | ||
206 | echo "#define __ASM_OFFSETS_H__"; \ | ||
207 | echo "/*"; \ | 194 | echo "/*"; \ |
208 | echo " * DO NOT MODIFY."; \ | 195 | echo " * DO NOT MODIFY."; \ |
209 | echo " *"; \ | 196 | echo " *"; \ |
@@ -212,8 +199,7 @@ define filechk_gen-asm-offsets | |||
212 | echo " */"; \ | 199 | echo " */"; \ |
213 | echo ""; \ | 200 | echo ""; \ |
214 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ | 201 | sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \ |
215 | echo ""; \ | 202 | echo ""; ) |
216 | echo "#endif" ) | ||
217 | endef | 203 | endef |
218 | 204 | ||
219 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | 205 | $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h |
@@ -222,50 +208,18 @@ $(ARCH_DIR)/include/uml-config.h : include/linux/autoconf.h | |||
222 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c | 208 | $(ARCH_DIR)/user-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/user-offsets.c |
223 | $(CC) $(USER_CFLAGS) -S -o $@ $< | 209 | $(CC) $(USER_CFLAGS) -S -o $@ $< |
224 | 210 | ||
225 | $(ARCH_DIR)/user-offsets.h: $(ARCH_DIR)/user-offsets.s | 211 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/user-offsets.s |
226 | $(call filechk,gen-asm-offsets) | 212 | $(call filechk,gen-asm-offsets) |
227 | 213 | ||
228 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s $(ARCH_DIR)/user-offsets.h | 214 | CLEAN_FILES += $(ARCH_DIR)/user-offsets.s |
229 | 215 | ||
230 | $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ | 216 | $(ARCH_DIR)/kernel-offsets.s: $(ARCH_DIR)/sys-$(SUBARCH)/kernel-offsets.c \ |
231 | $(ARCH_SYMLINKS) \ | 217 | archprepare |
232 | $(SYS_DIR)/sc.h \ | ||
233 | include/asm include/linux/version.h \ | ||
234 | include/config/MARKER \ | ||
235 | $(ARCH_DIR)/include/user_constants.h | ||
236 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< | 218 | $(CC) $(CFLAGS) $(NOSTDINC_FLAGS) $(CPPFLAGS) -S -o $@ $< |
237 | 219 | ||
238 | $(ARCH_DIR)/kernel-offsets.h: $(ARCH_DIR)/kernel-offsets.s | 220 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/kernel-offsets.s |
239 | $(call filechk,gen-asm-offsets) | 221 | $(call filechk,gen-asm-offsets) |
240 | 222 | ||
241 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s $(ARCH_DIR)/kernel-offsets.h | 223 | CLEAN_FILES += $(ARCH_DIR)/kernel-offsets.s |
242 | |||
243 | $(ARCH_DIR)/include/task.h: $(ARCH_DIR)/util/mk_task | ||
244 | $(call filechk,gen_header) | ||
245 | |||
246 | $(ARCH_DIR)/include/user_constants.h: $(ARCH_DIR)/os-$(OS)/util/mk_user_constants | ||
247 | $(call filechk,gen_header) | ||
248 | |||
249 | $(ARCH_DIR)/include/kern_constants.h: $(ARCH_DIR)/util/mk_constants | ||
250 | $(call filechk,gen_header) | ||
251 | |||
252 | $(ARCH_DIR)/include/skas_ptregs.h: $(ARCH_DIR)/kernel/skas/util/mk_ptregs | ||
253 | $(call filechk,gen_header) | ||
254 | |||
255 | $(ARCH_DIR)/os-$(OS)/util/mk_user_constants: $(ARCH_DIR)/os-$(OS)/util FORCE ; | ||
256 | |||
257 | $(ARCH_DIR)/util/mk_task $(ARCH_DIR)/util/mk_constants: $(ARCH_DIR)/include/user_constants.h $(ARCH_DIR)/util \ | ||
258 | FORCE ; | ||
259 | |||
260 | $(ARCH_DIR)/kernel/skas/util/mk_ptregs: $(ARCH_DIR)/kernel/skas/util FORCE ; | ||
261 | |||
262 | $(ARCH_DIR)/util: scripts_basic $(SYS_DIR)/sc.h $(ARCH_DIR)/kernel-offsets.h FORCE | ||
263 | $(Q)$(MAKE) $(build)=$@ | ||
264 | |||
265 | $(ARCH_DIR)/kernel/skas/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
266 | $(Q)$(MAKE) $(build)=$@ | ||
267 | |||
268 | $(ARCH_DIR)/os-$(OS)/util: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
269 | $(Q)$(MAKE) $(build)=$@ | ||
270 | 224 | ||
271 | export SUBARCH USER_CFLAGS OS | 225 | export SUBARCH USER_CFLAGS OS |
diff --git a/arch/um/Makefile-i386 b/arch/um/Makefile-i386 index 1ab431a53ac3..2ee8a2858117 100644 --- a/arch/um/Makefile-i386 +++ b/arch/um/Makefile-i386 | |||
@@ -32,25 +32,3 @@ CFLAGS += -U__$(SUBARCH)__ -U$(SUBARCH) | |||
32 | ifneq ($(CONFIG_GPROF),y) | 32 | ifneq ($(CONFIG_GPROF),y) |
33 | ARCH_CFLAGS += -DUM_FASTCALL | 33 | ARCH_CFLAGS += -DUM_FASTCALL |
34 | endif | 34 | endif |
35 | |||
36 | SYS_UTIL_DIR := $(ARCH_DIR)/sys-i386/util | ||
37 | SYS_HEADERS := $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h | ||
38 | |||
39 | prepare: $(SYS_HEADERS) | ||
40 | |||
41 | $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | ||
42 | $(call filechk,gen_header) | ||
43 | |||
44 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | ||
45 | $(call filechk,gen_header) | ||
46 | |||
47 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
48 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
49 | |||
50 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(ARCH_DIR)/kernel-offsets.h FORCE | ||
51 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
52 | |||
53 | $(SYS_UTIL_DIR): scripts_basic include/asm FORCE | ||
54 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) | ||
55 | |||
56 | CLEAN_FILES += $(SYS_HEADERS) | ||
diff --git a/arch/um/Makefile-skas b/arch/um/Makefile-skas index fd18ec572271..ac35de5316a6 100644 --- a/arch/um/Makefile-skas +++ b/arch/um/Makefile-skas | |||
@@ -10,5 +10,3 @@ CFLAGS-$(CONFIG_GCOV) += $(GCOV_OPT) | |||
10 | CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) | 10 | CFLAGS-$(CONFIG_GPROF) += $(GPROF_OPT) |
11 | LINK-$(CONFIG_GCOV) += $(GCOV_OPT) | 11 | LINK-$(CONFIG_GCOV) += $(GCOV_OPT) |
12 | LINK-$(CONFIG_GPROF) += $(GPROF_OPT) | 12 | LINK-$(CONFIG_GPROF) += $(GPROF_OPT) |
13 | |||
14 | GEN_HEADERS += $(ARCH_DIR)/include/skas_ptregs.h | ||
diff --git a/arch/um/Makefile-x86_64 b/arch/um/Makefile-x86_64 index 436abbba409b..4f118d5cc2ee 100644 --- a/arch/um/Makefile-x86_64 +++ b/arch/um/Makefile-x86_64 | |||
@@ -12,24 +12,3 @@ CHECKFLAGS += -m64 | |||
12 | 12 | ||
13 | ELF_ARCH := i386:x86-64 | 13 | ELF_ARCH := i386:x86-64 |
14 | ELF_FORMAT := elf64-x86-64 | 14 | ELF_FORMAT := elf64-x86-64 |
15 | |||
16 | SYS_UTIL_DIR := $(ARCH_DIR)/sys-x86_64/util | ||
17 | SYS_DIR := $(ARCH_DIR)/include/sysdep-x86_64 | ||
18 | |||
19 | SYS_HEADERS = $(SYS_DIR)/sc.h $(SYS_DIR)/thread.h | ||
20 | |||
21 | prepare: $(SYS_HEADERS) | ||
22 | |||
23 | $(SYS_DIR)/sc.h: $(SYS_UTIL_DIR)/mk_sc | ||
24 | $(call filechk,gen_header) | ||
25 | |||
26 | $(SYS_DIR)/thread.h: $(SYS_UTIL_DIR)/mk_thread | ||
27 | $(call filechk,gen_header) | ||
28 | |||
29 | $(SYS_UTIL_DIR)/mk_sc: scripts_basic $(ARCH_DIR)/user-offsets.h FORCE | ||
30 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
31 | |||
32 | $(SYS_UTIL_DIR)/mk_thread: scripts_basic $(GEN_HEADERS) $(ARCH_DIR)/kernel-offsets.h FORCE | ||
33 | $(Q)$(MAKE) $(build)=$(SYS_UTIL_DIR) $@ | ||
34 | |||
35 | CLEAN_FILES += $(SYS_HEADERS) | ||
diff --git a/arch/um/include/common-offsets.h b/arch/um/include/common-offsets.h index 782ac3a3baf9..356390d1f8b9 100644 --- a/arch/um/include/common-offsets.h +++ b/arch/um/include/common-offsets.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ | 1 | /* for use by sys-$SUBARCH/kernel-offsets.c */ |
2 | 2 | ||
3 | OFFSET(TASK_REGS, task_struct, thread.regs); | 3 | OFFSET(HOST_TASK_REGS, task_struct, thread.regs); |
4 | OFFSET(TASK_PID, task_struct, pid); | 4 | OFFSET(HOST_TASK_PID, task_struct, pid); |
5 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); | 5 | DEFINE(UM_KERN_PAGE_SIZE, PAGE_SIZE); |
6 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); | 6 | DEFINE(UM_NSEC_PER_SEC, NSEC_PER_SEC); |
7 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); | 7 | DEFINE_STR(UM_KERN_EMERG, KERN_EMERG); |
diff --git a/arch/um/include/skas_ptregs.h b/arch/um/include/skas_ptregs.h new file mode 100644 index 000000000000..73db19e9c077 --- /dev/null +++ b/arch/um/include/skas_ptregs.h | |||
@@ -0,0 +1,6 @@ | |||
1 | #ifndef __SKAS_PT_REGS_ | ||
2 | #define __SKAS_PT_REGS_ | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/sc.h b/arch/um/include/sysdep-i386/sc.h new file mode 100644 index 000000000000..c57d1780ad37 --- /dev/null +++ b/arch/um/include/sysdep-i386/sc.h | |||
@@ -0,0 +1,44 @@ | |||
1 | #ifndef __SYSDEP_I386_SC_H | ||
2 | #define __SYSDEP_I386_SC_H | ||
3 | |||
4 | #include <user_constants.h> | ||
5 | |||
6 | #define SC_OFFSET(sc, field) \ | ||
7 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
8 | #define SC_FP_OFFSET(sc, field) \ | ||
9 | *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
10 | #define SC_FP_OFFSET_PTR(sc, field, type) \ | ||
11 | ((type *) &(((char *) (SC_FPSTATE(sc)))[HOST_##field])) | ||
12 | |||
13 | #define SC_IP(sc) SC_OFFSET(sc, SC_IP) | ||
14 | #define SC_SP(sc) SC_OFFSET(sc, SC_SP) | ||
15 | #define SC_FS(sc) SC_OFFSET(sc, SC_FS) | ||
16 | #define SC_GS(sc) SC_OFFSET(sc, SC_GS) | ||
17 | #define SC_DS(sc) SC_OFFSET(sc, SC_DS) | ||
18 | #define SC_ES(sc) SC_OFFSET(sc, SC_ES) | ||
19 | #define SC_SS(sc) SC_OFFSET(sc, SC_SS) | ||
20 | #define SC_CS(sc) SC_OFFSET(sc, SC_CS) | ||
21 | #define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) | ||
22 | #define SC_EAX(sc) SC_OFFSET(sc, SC_EAX) | ||
23 | #define SC_EBX(sc) SC_OFFSET(sc, SC_EBX) | ||
24 | #define SC_ECX(sc) SC_OFFSET(sc, SC_ECX) | ||
25 | #define SC_EDX(sc) SC_OFFSET(sc, SC_EDX) | ||
26 | #define SC_EDI(sc) SC_OFFSET(sc, SC_EDI) | ||
27 | #define SC_ESI(sc) SC_OFFSET(sc, SC_ESI) | ||
28 | #define SC_EBP(sc) SC_OFFSET(sc, SC_EBP) | ||
29 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
30 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
31 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
32 | #define SC_FPSTATE(sc) SC_OFFSET(sc, SC_FPSTATE) | ||
33 | #define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) | ||
34 | #define SC_FP_CW(sc) SC_FP_OFFSET(sc, SC_FP_CW) | ||
35 | #define SC_FP_SW(sc) SC_FP_OFFSET(sc, SC_FP_SW) | ||
36 | #define SC_FP_TAG(sc) SC_FP_OFFSET(sc, SC_FP_TAG) | ||
37 | #define SC_FP_IPOFF(sc) SC_FP_OFFSET(sc, SC_FP_IPOFF) | ||
38 | #define SC_FP_CSSEL(sc) SC_FP_OFFSET(sc, SC_FP_CSSEL) | ||
39 | #define SC_FP_DATAOFF(sc) SC_FP_OFFSET(sc, SC_FP_DATAOFF) | ||
40 | #define SC_FP_DATASEL(sc) SC_FP_OFFSET(sc, SC_FP_DATASEL) | ||
41 | #define SC_FP_ST(sc) SC_FP_OFFSET_PTR(sc, SC_FP_ST, struct _fpstate) | ||
42 | #define SC_FXSR_ENV(sc) SC_FP_OFFSET_PTR(sc, SC_FXSR_ENV, void) | ||
43 | |||
44 | #endif | ||
diff --git a/arch/um/include/sysdep-i386/thread.h b/arch/um/include/sysdep-i386/thread.h new file mode 100644 index 000000000000..e2bd6bae8b8a --- /dev/null +++ b/arch/um/include/sysdep-i386/thread.h | |||
@@ -0,0 +1,11 @@ | |||
1 | #ifndef __UM_THREAD_H | ||
2 | #define __UM_THREAD_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_DEBUGREGS(task) ((unsigned long *) &(((char *) (task))[HOST_TASK_DEBUGREGS])) | ||
7 | #ifdef CONFIG_MODE_TT | ||
8 | #define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) | ||
9 | #endif | ||
10 | |||
11 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/sc.h b/arch/um/include/sysdep-x86_64/sc.h new file mode 100644 index 000000000000..a160d9fcc596 --- /dev/null +++ b/arch/um/include/sysdep-x86_64/sc.h | |||
@@ -0,0 +1,45 @@ | |||
1 | #ifndef __SYSDEP_X86_64_SC_H | ||
2 | #define __SYSDEP_X86_64_SC_H | ||
3 | |||
4 | /* Copyright (C) 2003 - 2004 PathScale, Inc | ||
5 | * Released under the GPL | ||
6 | */ | ||
7 | |||
8 | #include <user_constants.h> | ||
9 | |||
10 | #define SC_OFFSET(sc, field) \ | ||
11 | *((unsigned long *) &(((char *) (sc))[HOST_##field])) | ||
12 | |||
13 | #define SC_RBX(sc) SC_OFFSET(sc, SC_RBX) | ||
14 | #define SC_RCX(sc) SC_OFFSET(sc, SC_RCX) | ||
15 | #define SC_RDX(sc) SC_OFFSET(sc, SC_RDX) | ||
16 | #define SC_RSI(sc) SC_OFFSET(sc, SC_RSI) | ||
17 | #define SC_RDI(sc) SC_OFFSET(sc, SC_RDI) | ||
18 | #define SC_RBP(sc) SC_OFFSET(sc, SC_RBP) | ||
19 | #define SC_RAX(sc) SC_OFFSET(sc, SC_RAX) | ||
20 | #define SC_R8(sc) SC_OFFSET(sc, SC_R8) | ||
21 | #define SC_R9(sc) SC_OFFSET(sc, SC_R9) | ||
22 | #define SC_R10(sc) SC_OFFSET(sc, SC_R10) | ||
23 | #define SC_R11(sc) SC_OFFSET(sc, SC_R11) | ||
24 | #define SC_R12(sc) SC_OFFSET(sc, SC_R12) | ||
25 | #define SC_R13(sc) SC_OFFSET(sc, SC_R13) | ||
26 | #define SC_R14(sc) SC_OFFSET(sc, SC_R14) | ||
27 | #define SC_R15(sc) SC_OFFSET(sc, SC_R15) | ||
28 | #define SC_IP(sc) SC_OFFSET(sc, SC_IP) | ||
29 | #define SC_SP(sc) SC_OFFSET(sc, SC_SP) | ||
30 | #define SC_CR2(sc) SC_OFFSET(sc, SC_CR2) | ||
31 | #define SC_ERR(sc) SC_OFFSET(sc, SC_ERR) | ||
32 | #define SC_TRAPNO(sc) SC_OFFSET(sc, SC_TRAPNO) | ||
33 | #define SC_CS(sc) SC_OFFSET(sc, SC_CS) | ||
34 | #define SC_FS(sc) SC_OFFSET(sc, SC_FS) | ||
35 | #define SC_GS(sc) SC_OFFSET(sc, SC_GS) | ||
36 | #define SC_EFLAGS(sc) SC_OFFSET(sc, SC_EFLAGS) | ||
37 | #define SC_SIGMASK(sc) SC_OFFSET(sc, SC_SIGMASK) | ||
38 | #if 0 | ||
39 | #define SC_ORIG_RAX(sc) SC_OFFSET(sc, SC_ORIG_RAX) | ||
40 | #define SC_DS(sc) SC_OFFSET(sc, SC_DS) | ||
41 | #define SC_ES(sc) SC_OFFSET(sc, SC_ES) | ||
42 | #define SC_SS(sc) SC_OFFSET(sc, SC_SS) | ||
43 | #endif | ||
44 | |||
45 | #endif | ||
diff --git a/arch/um/include/sysdep-x86_64/thread.h b/arch/um/include/sysdep-x86_64/thread.h new file mode 100644 index 000000000000..6a76a7f3683f --- /dev/null +++ b/arch/um/include/sysdep-x86_64/thread.h | |||
@@ -0,0 +1,10 @@ | |||
1 | #ifndef __UM_THREAD_H | ||
2 | #define __UM_THREAD_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #ifdef CONFIG_MODE_TT | ||
7 | #define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[HOST_TASK_EXTERN_PID])) | ||
8 | #endif | ||
9 | |||
10 | #endif | ||
diff --git a/arch/um/include/task.h b/arch/um/include/task.h new file mode 100644 index 000000000000..6375ba7203c9 --- /dev/null +++ b/arch/um/include/task.h | |||
@@ -0,0 +1,9 @@ | |||
1 | #ifndef __TASK_H | ||
2 | #define __TASK_H | ||
3 | |||
4 | #include <kern_constants.h> | ||
5 | |||
6 | #define TASK_REGS(task) ((union uml_pt_regs *) &(((char *) (task))[HOST_TASK_REGS])) | ||
7 | #define TASK_PID(task) *((int *) &(((char *) (task))[HOST_TASK_PID])) | ||
8 | |||
9 | #endif | ||
diff --git a/arch/um/kernel/skas/Makefile b/arch/um/kernel/skas/Makefile index db36c7c95940..8de471b59c1c 100644 --- a/arch/um/kernel/skas/Makefile +++ b/arch/um/kernel/skas/Makefile | |||
@@ -6,8 +6,6 @@ | |||
6 | obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ | 6 | obj-y := clone.o exec_kern.o mem.o mem_user.o mmu.o process.o process_kern.o \ |
7 | syscall.o tlb.o trap_user.o uaccess.o | 7 | syscall.o tlb.o trap_user.o uaccess.o |
8 | 8 | ||
9 | subdir- := util | ||
10 | |||
11 | USER_OBJS := process.o clone.o | 9 | USER_OBJS := process.o clone.o |
12 | 10 | ||
13 | include arch/um/scripts/Makefile.rules | 11 | include arch/um/scripts/Makefile.rules |
diff --git a/arch/um/kernel/skas/util/Makefile b/arch/um/kernel/skas/util/Makefile deleted file mode 100644 index f7b7eba83340..000000000000 --- a/arch/um/kernel/skas/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_ptregs | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | mk_ptregs-objs := mk_ptregs-$(SUBARCH).o | ||
5 | HOSTCFLAGS_mk_ptregs-$(SUBARCH).o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/kernel/skas/util/mk_ptregs-i386.c b/arch/um/kernel/skas/util/mk_ptregs-i386.c deleted file mode 100644 index 1f96e1eeb8a7..000000000000 --- a/arch/um/kernel/skas/util/mk_ptregs-i386.c +++ /dev/null | |||
@@ -1,49 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | #define SHOW(name) printf("#define %s %d\n", #name, name) | ||
5 | |||
6 | int main(int argc, char **argv) | ||
7 | { | ||
8 | printf("/* Automatically generated by " | ||
9 | "arch/um/kernel/skas/util/mk_ptregs */\n"); | ||
10 | printf("\n"); | ||
11 | printf("#ifndef __SKAS_PT_REGS_\n"); | ||
12 | printf("#define __SKAS_PT_REGS_\n"); | ||
13 | printf("\n"); | ||
14 | SHOW(HOST_FRAME_SIZE); | ||
15 | SHOW(HOST_FP_SIZE); | ||
16 | SHOW(HOST_XFP_SIZE); | ||
17 | |||
18 | SHOW(HOST_IP); | ||
19 | SHOW(HOST_SP); | ||
20 | SHOW(HOST_EFLAGS); | ||
21 | SHOW(HOST_EAX); | ||
22 | SHOW(HOST_EBX); | ||
23 | SHOW(HOST_ECX); | ||
24 | SHOW(HOST_EDX); | ||
25 | SHOW(HOST_ESI); | ||
26 | SHOW(HOST_EDI); | ||
27 | SHOW(HOST_EBP); | ||
28 | SHOW(HOST_CS); | ||
29 | SHOW(HOST_SS); | ||
30 | SHOW(HOST_DS); | ||
31 | SHOW(HOST_FS); | ||
32 | SHOW(HOST_ES); | ||
33 | SHOW(HOST_GS); | ||
34 | |||
35 | printf("\n"); | ||
36 | printf("#endif\n"); | ||
37 | return(0); | ||
38 | } | ||
39 | |||
40 | /* | ||
41 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
42 | * Emacs will notice this stuff at the end of the file and automatically | ||
43 | * adjust the settings for this buffer only. This must remain at the end | ||
44 | * of the file. | ||
45 | * --------------------------------------------------------------------------- | ||
46 | * Local variables: | ||
47 | * c-file-style: "linux" | ||
48 | * End: | ||
49 | */ | ||
diff --git a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c b/arch/um/kernel/skas/util/mk_ptregs-x86_64.c deleted file mode 100644 index 5fccbfe35f78..000000000000 --- a/arch/um/kernel/skas/util/mk_ptregs-x86_64.c +++ /dev/null | |||
@@ -1,66 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright 2003 PathScale, Inc. | ||
3 | * | ||
4 | * Licensed under the GPL | ||
5 | */ | ||
6 | |||
7 | #include <stdio.h> | ||
8 | #include <user-offsets.h> | ||
9 | |||
10 | #define SHOW(name) \ | ||
11 | printf("#define %s (%d / sizeof(unsigned long))\n", #name, name) | ||
12 | |||
13 | int main(int argc, char **argv) | ||
14 | { | ||
15 | printf("/* Automatically generated by " | ||
16 | "arch/um/kernel/skas/util/mk_ptregs */\n"); | ||
17 | printf("\n"); | ||
18 | printf("#ifndef __SKAS_PT_REGS_\n"); | ||
19 | printf("#define __SKAS_PT_REGS_\n"); | ||
20 | SHOW(HOST_FRAME_SIZE); | ||
21 | SHOW(HOST_RBX); | ||
22 | SHOW(HOST_RCX); | ||
23 | SHOW(HOST_RDI); | ||
24 | SHOW(HOST_RSI); | ||
25 | SHOW(HOST_RDX); | ||
26 | SHOW(HOST_RBP); | ||
27 | SHOW(HOST_RAX); | ||
28 | SHOW(HOST_R8); | ||
29 | SHOW(HOST_R9); | ||
30 | SHOW(HOST_R10); | ||
31 | SHOW(HOST_R11); | ||
32 | SHOW(HOST_R12); | ||
33 | SHOW(HOST_R13); | ||
34 | SHOW(HOST_R14); | ||
35 | SHOW(HOST_R15); | ||
36 | SHOW(HOST_ORIG_RAX); | ||
37 | SHOW(HOST_CS); | ||
38 | SHOW(HOST_SS); | ||
39 | SHOW(HOST_EFLAGS); | ||
40 | #if 0 | ||
41 | SHOW(HOST_FS); | ||
42 | SHOW(HOST_GS); | ||
43 | SHOW(HOST_DS); | ||
44 | SHOW(HOST_ES); | ||
45 | #endif | ||
46 | |||
47 | SHOW(HOST_IP); | ||
48 | SHOW(HOST_SP); | ||
49 | printf("#define HOST_FP_SIZE 0\n"); | ||
50 | printf("#define HOST_XFP_SIZE 0\n"); | ||
51 | printf("\n"); | ||
52 | printf("\n"); | ||
53 | printf("#endif\n"); | ||
54 | return(0); | ||
55 | } | ||
56 | |||
57 | /* | ||
58 | * Overrides for Emacs so that we follow Linus's tabbing style. | ||
59 | * Emacs will notice this stuff at the end of the file and automatically | ||
60 | * adjust the settings for this buffer only. This must remain at the end | ||
61 | * of the file. | ||
62 | * --------------------------------------------------------------------------- | ||
63 | * Local variables: | ||
64 | * c-file-style: "linux" | ||
65 | * End: | ||
66 | */ | ||
diff --git a/arch/um/os-Linux/elf_aux.c b/arch/um/os-Linux/elf_aux.c index ab33cb3c74ec..5a99dd3fbed0 100644 --- a/arch/um/os-Linux/elf_aux.c +++ b/arch/um/os-Linux/elf_aux.c | |||
@@ -12,7 +12,7 @@ | |||
12 | #include "init.h" | 12 | #include "init.h" |
13 | #include "elf_user.h" | 13 | #include "elf_user.h" |
14 | #include "mem_user.h" | 14 | #include "mem_user.h" |
15 | #include <kernel-offsets.h> | 15 | #include <kern_constants.h> |
16 | 16 | ||
17 | /* Use the one from the kernel - the host may miss it, if having old headers. */ | 17 | /* Use the one from the kernel - the host may miss it, if having old headers. */ |
18 | #if UM_ELF_CLASS == UM_ELFCLASS32 | 18 | #if UM_ELF_CLASS == UM_ELFCLASS32 |
diff --git a/arch/um/os-Linux/util/Makefile b/arch/um/os-Linux/util/Makefile deleted file mode 100644 index 9778aed0c314..000000000000 --- a/arch/um/os-Linux/util/Makefile +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | hostprogs-y := mk_user_constants | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | HOSTCFLAGS_mk_user_constants.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/os-Linux/util/mk_user_constants.c b/arch/um/os-Linux/util/mk_user_constants.c deleted file mode 100644 index 4838f30eecf0..000000000000 --- a/arch/um/os-Linux/util/mk_user_constants.c +++ /dev/null | |||
@@ -1,23 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_user_constants\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_USER_CONSTANTS_H\n"); | ||
11 | printf("#define __UM_USER_CONSTANTS_H\n"); | ||
12 | printf("\n"); | ||
13 | /* I'd like to use FRAME_SIZE from ptrace.h here, but that's wrong on | ||
14 | * x86_64 (216 vs 168 bytes). user_regs_struct is the correct size on | ||
15 | * both x86_64 and i386. | ||
16 | */ | ||
17 | printf("#define UM_FRAME_SIZE %d\n", __UM_FRAME_SIZE); | ||
18 | |||
19 | printf("\n"); | ||
20 | printf("#endif\n"); | ||
21 | |||
22 | return(0); | ||
23 | } | ||
diff --git a/arch/um/sys-i386/Makefile b/arch/um/sys-i386/Makefile index 4ca2a229da49..6dfeb70f6957 100644 --- a/arch/um/sys-i386/Makefile +++ b/arch/um/sys-i386/Makefile | |||
@@ -18,6 +18,4 @@ module.c-dir = kernel | |||
18 | 18 | ||
19 | $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) | 19 | $(obj)/stub_segv.o : _c_flags = $(call unprofile,$(CFLAGS)) |
20 | 20 | ||
21 | subdir- := util | ||
22 | |||
23 | include arch/um/scripts/Makefile.unmap | 21 | include arch/um/scripts/Makefile.unmap |
diff --git a/arch/um/sys-i386/kernel-offsets.c b/arch/um/sys-i386/kernel-offsets.c index a1070af2bcd8..35db85057506 100644 --- a/arch/um/sys-i386/kernel-offsets.c +++ b/arch/um/sys-i386/kernel-offsets.c | |||
@@ -18,9 +18,9 @@ | |||
18 | 18 | ||
19 | void foo(void) | 19 | void foo(void) |
20 | { | 20 | { |
21 | OFFSET(TASK_DEBUGREGS, task_struct, thread.arch.debugregs); | 21 | OFFSET(HOST_TASK_DEBUGREGS, task_struct, thread.arch.debugregs); |
22 | #ifdef CONFIG_MODE_TT | 22 | #ifdef CONFIG_MODE_TT |
23 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | 23 | OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); |
24 | #endif | 24 | #endif |
25 | #include <common-offsets.h> | 25 | #include <common-offsets.h> |
26 | } | 26 | } |
diff --git a/arch/um/sys-i386/user-offsets.c b/arch/um/sys-i386/user-offsets.c index 3ceaabceb3d7..677fc26a9bbe 100644 --- a/arch/um/sys-i386/user-offsets.c +++ b/arch/um/sys-i386/user-offsets.c | |||
@@ -7,47 +7,48 @@ | |||
7 | #define DEFINE(sym, val) \ | 7 | #define DEFINE(sym, val) \ |
8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | 8 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
9 | 9 | ||
10 | #define DEFINE_LONGS(sym, val) \ | ||
11 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) | ||
12 | |||
10 | #define OFFSET(sym, str, mem) \ | 13 | #define OFFSET(sym, str, mem) \ |
11 | DEFINE(sym, offsetof(struct str, mem)); | 14 | DEFINE(sym, offsetof(struct str, mem)); |
12 | 15 | ||
13 | void foo(void) | 16 | void foo(void) |
14 | { | 17 | { |
15 | OFFSET(SC_IP, sigcontext, eip); | 18 | OFFSET(HOST_SC_IP, sigcontext, eip); |
16 | OFFSET(SC_SP, sigcontext, esp); | 19 | OFFSET(HOST_SC_SP, sigcontext, esp); |
17 | OFFSET(SC_FS, sigcontext, fs); | 20 | OFFSET(HOST_SC_FS, sigcontext, fs); |
18 | OFFSET(SC_GS, sigcontext, gs); | 21 | OFFSET(HOST_SC_GS, sigcontext, gs); |
19 | OFFSET(SC_DS, sigcontext, ds); | 22 | OFFSET(HOST_SC_DS, sigcontext, ds); |
20 | OFFSET(SC_ES, sigcontext, es); | 23 | OFFSET(HOST_SC_ES, sigcontext, es); |
21 | OFFSET(SC_SS, sigcontext, ss); | 24 | OFFSET(HOST_SC_SS, sigcontext, ss); |
22 | OFFSET(SC_CS, sigcontext, cs); | 25 | OFFSET(HOST_SC_CS, sigcontext, cs); |
23 | OFFSET(SC_EFLAGS, sigcontext, eflags); | 26 | OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); |
24 | OFFSET(SC_EAX, sigcontext, eax); | 27 | OFFSET(HOST_SC_EAX, sigcontext, eax); |
25 | OFFSET(SC_EBX, sigcontext, ebx); | 28 | OFFSET(HOST_SC_EBX, sigcontext, ebx); |
26 | OFFSET(SC_ECX, sigcontext, ecx); | 29 | OFFSET(HOST_SC_ECX, sigcontext, ecx); |
27 | OFFSET(SC_EDX, sigcontext, edx); | 30 | OFFSET(HOST_SC_EDX, sigcontext, edx); |
28 | OFFSET(SC_EDI, sigcontext, edi); | 31 | OFFSET(HOST_SC_EDI, sigcontext, edi); |
29 | OFFSET(SC_ESI, sigcontext, esi); | 32 | OFFSET(HOST_SC_ESI, sigcontext, esi); |
30 | OFFSET(SC_EBP, sigcontext, ebp); | 33 | OFFSET(HOST_SC_EBP, sigcontext, ebp); |
31 | OFFSET(SC_TRAPNO, sigcontext, trapno); | 34 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
32 | OFFSET(SC_ERR, sigcontext, err); | 35 | OFFSET(HOST_SC_ERR, sigcontext, err); |
33 | OFFSET(SC_CR2, sigcontext, cr2); | 36 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
34 | OFFSET(SC_FPSTATE, sigcontext, fpstate); | 37 | OFFSET(HOST_SC_FPSTATE, sigcontext, fpstate); |
35 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | 38 | OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); |
36 | OFFSET(SC_FP_CW, _fpstate, cw); | 39 | OFFSET(HOST_SC_FP_CW, _fpstate, cw); |
37 | OFFSET(SC_FP_SW, _fpstate, sw); | 40 | OFFSET(HOST_SC_FP_SW, _fpstate, sw); |
38 | OFFSET(SC_FP_TAG, _fpstate, tag); | 41 | OFFSET(HOST_SC_FP_TAG, _fpstate, tag); |
39 | OFFSET(SC_FP_IPOFF, _fpstate, ipoff); | 42 | OFFSET(HOST_SC_FP_IPOFF, _fpstate, ipoff); |
40 | OFFSET(SC_FP_CSSEL, _fpstate, cssel); | 43 | OFFSET(HOST_SC_FP_CSSEL, _fpstate, cssel); |
41 | OFFSET(SC_FP_DATAOFF, _fpstate, dataoff); | 44 | OFFSET(HOST_SC_FP_DATAOFF, _fpstate, dataoff); |
42 | OFFSET(SC_FP_DATASEL, _fpstate, datasel); | 45 | OFFSET(HOST_SC_FP_DATASEL, _fpstate, datasel); |
43 | OFFSET(SC_FP_ST, _fpstate, _st); | 46 | OFFSET(HOST_SC_FP_ST, _fpstate, _st); |
44 | OFFSET(SC_FXSR_ENV, _fpstate, _fxsr_env); | 47 | OFFSET(HOST_SC_FXSR_ENV, _fpstate, _fxsr_env); |
45 | 48 | ||
46 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | 49 | DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); |
47 | DEFINE(HOST_FP_SIZE, | 50 | DEFINE_LONGS(HOST_FP_SIZE, sizeof(struct user_i387_struct)); |
48 | sizeof(struct user_i387_struct) / sizeof(unsigned long)); | 51 | DEFINE_LONGS(HOST_XFP_SIZE, sizeof(struct user_fxsr_struct)); |
49 | DEFINE(HOST_XFP_SIZE, | ||
50 | sizeof(struct user_fxsr_struct) / sizeof(unsigned long)); | ||
51 | 52 | ||
52 | DEFINE(HOST_IP, EIP); | 53 | DEFINE(HOST_IP, EIP); |
53 | DEFINE(HOST_SP, UESP); | 54 | DEFINE(HOST_SP, UESP); |
@@ -65,5 +66,5 @@ void foo(void) | |||
65 | DEFINE(HOST_FS, FS); | 66 | DEFINE(HOST_FS, FS); |
66 | DEFINE(HOST_ES, ES); | 67 | DEFINE(HOST_ES, ES); |
67 | DEFINE(HOST_GS, GS); | 68 | DEFINE(HOST_GS, GS); |
68 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | 69 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
69 | } | 70 | } |
diff --git a/arch/um/sys-i386/util/Makefile b/arch/um/sys-i386/util/Makefile deleted file mode 100644 index bf61afd0b045..000000000000 --- a/arch/um/sys-i386/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_sc mk_thread | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um | ||
5 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/sys-i386/util/mk_sc.c b/arch/um/sys-i386/util/mk_sc.c deleted file mode 100644 index 04c0d73433aa..000000000000 --- a/arch/um/sys-i386/util/mk_sc.c +++ /dev/null | |||
@@ -1,51 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <user-offsets.h> | ||
3 | |||
4 | #define SC_OFFSET(name, field) \ | ||
5 | printf("#define " #name "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ | ||
6 | name) | ||
7 | |||
8 | #define SC_FP_OFFSET(name, field) \ | ||
9 | printf("#define " #name \ | ||
10 | "(sc) *((unsigned long *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | ||
11 | name) | ||
12 | |||
13 | #define SC_FP_OFFSET_PTR(name, field, type) \ | ||
14 | printf("#define " #name \ | ||
15 | "(sc) ((" type " *) &(((char *) (SC_FPSTATE(sc)))[%d]))\n",\ | ||
16 | name) | ||
17 | |||
18 | int main(int argc, char **argv) | ||
19 | { | ||
20 | SC_OFFSET(SC_IP, eip); | ||
21 | SC_OFFSET(SC_SP, esp); | ||
22 | SC_OFFSET(SC_FS, fs); | ||
23 | SC_OFFSET(SC_GS, gs); | ||
24 | SC_OFFSET(SC_DS, ds); | ||
25 | SC_OFFSET(SC_ES, es); | ||
26 | SC_OFFSET(SC_SS, ss); | ||
27 | SC_OFFSET(SC_CS, cs); | ||
28 | SC_OFFSET(SC_EFLAGS, eflags); | ||
29 | SC_OFFSET(SC_EAX, eax); | ||
30 | SC_OFFSET(SC_EBX, ebx); | ||
31 | SC_OFFSET(SC_ECX, ecx); | ||
32 | SC_OFFSET(SC_EDX, edx); | ||
33 | SC_OFFSET(SC_EDI, edi); | ||
34 | SC_OFFSET(SC_ESI, esi); | ||
35 | SC_OFFSET(SC_EBP, ebp); | ||
36 | SC_OFFSET(SC_TRAPNO, trapno); | ||
37 | SC_OFFSET(SC_ERR, err); | ||
38 | SC_OFFSET(SC_CR2, cr2); | ||
39 | SC_OFFSET(SC_FPSTATE, fpstate); | ||
40 | SC_OFFSET(SC_SIGMASK, oldmask); | ||
41 | SC_FP_OFFSET(SC_FP_CW, cw); | ||
42 | SC_FP_OFFSET(SC_FP_SW, sw); | ||
43 | SC_FP_OFFSET(SC_FP_TAG, tag); | ||
44 | SC_FP_OFFSET(SC_FP_IPOFF, ipoff); | ||
45 | SC_FP_OFFSET(SC_FP_CSSEL, cssel); | ||
46 | SC_FP_OFFSET(SC_FP_DATAOFF, dataoff); | ||
47 | SC_FP_OFFSET(SC_FP_DATASEL, datasel); | ||
48 | SC_FP_OFFSET_PTR(SC_FP_ST, _st, "struct _fpstate"); | ||
49 | SC_FP_OFFSET_PTR(SC_FXSR_ENV, _fxsr_env, "void"); | ||
50 | return(0); | ||
51 | } | ||
diff --git a/arch/um/sys-i386/util/mk_thread.c b/arch/um/sys-i386/util/mk_thread.c deleted file mode 100644 index 7470d0dda67e..000000000000 --- a/arch/um/sys-i386/util/mk_thread.c +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_thread\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_THREAD_H\n"); | ||
11 | printf("#define __UM_THREAD_H\n"); | ||
12 | printf("\n"); | ||
13 | printf("#define TASK_DEBUGREGS(task) ((unsigned long *) " | ||
14 | "&(((char *) (task))[%d]))\n", TASK_DEBUGREGS); | ||
15 | #ifdef TASK_EXTERN_PID | ||
16 | printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", | ||
17 | TASK_EXTERN_PID); | ||
18 | #endif | ||
19 | printf("\n"); | ||
20 | printf("#endif\n"); | ||
21 | return(0); | ||
22 | } | ||
diff --git a/arch/um/sys-x86_64/Makefile b/arch/um/sys-x86_64/Makefile index f0ab574d1e95..06c3633457a2 100644 --- a/arch/um/sys-x86_64/Makefile +++ b/arch/um/sys-x86_64/Makefile | |||
@@ -29,6 +29,4 @@ module.c-dir = kernel | |||
29 | 29 | ||
30 | $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) | 30 | $(obj)/stub_segv.o: _c_flags = $(call unprofile,$(CFLAGS)) |
31 | 31 | ||
32 | subdir- := util | ||
33 | |||
34 | include arch/um/scripts/Makefile.unmap | 32 | include arch/um/scripts/Makefile.unmap |
diff --git a/arch/um/sys-x86_64/kernel-offsets.c b/arch/um/sys-x86_64/kernel-offsets.c index 998541eade41..bfcb104b846e 100644 --- a/arch/um/sys-x86_64/kernel-offsets.c +++ b/arch/um/sys-x86_64/kernel-offsets.c | |||
@@ -19,7 +19,7 @@ | |||
19 | void foo(void) | 19 | void foo(void) |
20 | { | 20 | { |
21 | #ifdef CONFIG_MODE_TT | 21 | #ifdef CONFIG_MODE_TT |
22 | OFFSET(TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); | 22 | OFFSET(HOST_TASK_EXTERN_PID, task_struct, thread.mode.tt.extern_pid); |
23 | #endif | 23 | #endif |
24 | #include <common-offsets.h> | 24 | #include <common-offsets.h> |
25 | } | 25 | } |
diff --git a/arch/um/sys-x86_64/user-offsets.c b/arch/um/sys-x86_64/user-offsets.c index 513d17ceafd4..5a585bfbb8c2 100644 --- a/arch/um/sys-x86_64/user-offsets.c +++ b/arch/um/sys-x86_64/user-offsets.c | |||
@@ -16,71 +16,76 @@ typedef __u32 u32; | |||
16 | #define DEFINE(sym, val) \ | 16 | #define DEFINE(sym, val) \ |
17 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) | 17 | asm volatile("\n->" #sym " %0 " #val : : "i" (val)) |
18 | 18 | ||
19 | #define DEFINE_LONGS(sym, val) \ | ||
20 | asm volatile("\n->" #sym " %0 " #val : : "i" (val/sizeof(unsigned long))) | ||
21 | |||
19 | #define OFFSET(sym, str, mem) \ | 22 | #define OFFSET(sym, str, mem) \ |
20 | DEFINE(sym, offsetof(struct str, mem)); | 23 | DEFINE(sym, offsetof(struct str, mem)); |
21 | 24 | ||
22 | void foo(void) | 25 | void foo(void) |
23 | { | 26 | { |
24 | OFFSET(SC_RBX, sigcontext, rbx); | 27 | OFFSET(HOST_SC_RBX, sigcontext, rbx); |
25 | OFFSET(SC_RCX, sigcontext, rcx); | 28 | OFFSET(HOST_SC_RCX, sigcontext, rcx); |
26 | OFFSET(SC_RDX, sigcontext, rdx); | 29 | OFFSET(HOST_SC_RDX, sigcontext, rdx); |
27 | OFFSET(SC_RSI, sigcontext, rsi); | 30 | OFFSET(HOST_SC_RSI, sigcontext, rsi); |
28 | OFFSET(SC_RDI, sigcontext, rdi); | 31 | OFFSET(HOST_SC_RDI, sigcontext, rdi); |
29 | OFFSET(SC_RBP, sigcontext, rbp); | 32 | OFFSET(HOST_SC_RBP, sigcontext, rbp); |
30 | OFFSET(SC_RAX, sigcontext, rax); | 33 | OFFSET(HOST_SC_RAX, sigcontext, rax); |
31 | OFFSET(SC_R8, sigcontext, r8); | 34 | OFFSET(HOST_SC_R8, sigcontext, r8); |
32 | OFFSET(SC_R9, sigcontext, r9); | 35 | OFFSET(HOST_SC_R9, sigcontext, r9); |
33 | OFFSET(SC_R10, sigcontext, r10); | 36 | OFFSET(HOST_SC_R10, sigcontext, r10); |
34 | OFFSET(SC_R11, sigcontext, r11); | 37 | OFFSET(HOST_SC_R11, sigcontext, r11); |
35 | OFFSET(SC_R12, sigcontext, r12); | 38 | OFFSET(HOST_SC_R12, sigcontext, r12); |
36 | OFFSET(SC_R13, sigcontext, r13); | 39 | OFFSET(HOST_SC_R13, sigcontext, r13); |
37 | OFFSET(SC_R14, sigcontext, r14); | 40 | OFFSET(HOST_SC_R14, sigcontext, r14); |
38 | OFFSET(SC_R15, sigcontext, r15); | 41 | OFFSET(HOST_SC_R15, sigcontext, r15); |
39 | OFFSET(SC_IP, sigcontext, rip); | 42 | OFFSET(HOST_SC_IP, sigcontext, rip); |
40 | OFFSET(SC_SP, sigcontext, rsp); | 43 | OFFSET(HOST_SC_SP, sigcontext, rsp); |
41 | OFFSET(SC_CR2, sigcontext, cr2); | 44 | OFFSET(HOST_SC_CR2, sigcontext, cr2); |
42 | OFFSET(SC_ERR, sigcontext, err); | 45 | OFFSET(HOST_SC_ERR, sigcontext, err); |
43 | OFFSET(SC_TRAPNO, sigcontext, trapno); | 46 | OFFSET(HOST_SC_TRAPNO, sigcontext, trapno); |
44 | OFFSET(SC_CS, sigcontext, cs); | 47 | OFFSET(HOST_SC_CS, sigcontext, cs); |
45 | OFFSET(SC_FS, sigcontext, fs); | 48 | OFFSET(HOST_SC_FS, sigcontext, fs); |
46 | OFFSET(SC_GS, sigcontext, gs); | 49 | OFFSET(HOST_SC_GS, sigcontext, gs); |
47 | OFFSET(SC_EFLAGS, sigcontext, eflags); | 50 | OFFSET(HOST_SC_EFLAGS, sigcontext, eflags); |
48 | OFFSET(SC_SIGMASK, sigcontext, oldmask); | 51 | OFFSET(HOST_SC_SIGMASK, sigcontext, oldmask); |
49 | #if 0 | 52 | #if 0 |
50 | OFFSET(SC_ORIG_RAX, sigcontext, orig_rax); | 53 | OFFSET(HOST_SC_ORIG_RAX, sigcontext, orig_rax); |
51 | OFFSET(SC_DS, sigcontext, ds); | 54 | OFFSET(HOST_SC_DS, sigcontext, ds); |
52 | OFFSET(SC_ES, sigcontext, es); | 55 | OFFSET(HOST_SC_ES, sigcontext, es); |
53 | OFFSET(SC_SS, sigcontext, ss); | 56 | OFFSET(HOST_SC_SS, sigcontext, ss); |
54 | #endif | 57 | #endif |
55 | 58 | ||
56 | DEFINE(HOST_FRAME_SIZE, FRAME_SIZE); | 59 | DEFINE_LONGS(HOST_FRAME_SIZE, FRAME_SIZE); |
57 | DEFINE(HOST_RBX, RBX); | 60 | DEFINE(HOST_FP_SIZE, 0); |
58 | DEFINE(HOST_RCX, RCX); | 61 | DEFINE(HOST_XFP_SIZE, 0); |
59 | DEFINE(HOST_RDI, RDI); | 62 | DEFINE_LONGS(HOST_RBX, RBX); |
60 | DEFINE(HOST_RSI, RSI); | 63 | DEFINE_LONGS(HOST_RCX, RCX); |
61 | DEFINE(HOST_RDX, RDX); | 64 | DEFINE_LONGS(HOST_RDI, RDI); |
62 | DEFINE(HOST_RBP, RBP); | 65 | DEFINE_LONGS(HOST_RSI, RSI); |
63 | DEFINE(HOST_RAX, RAX); | 66 | DEFINE_LONGS(HOST_RDX, RDX); |
64 | DEFINE(HOST_R8, R8); | 67 | DEFINE_LONGS(HOST_RBP, RBP); |
65 | DEFINE(HOST_R9, R9); | 68 | DEFINE_LONGS(HOST_RAX, RAX); |
66 | DEFINE(HOST_R10, R10); | 69 | DEFINE_LONGS(HOST_R8, R8); |
67 | DEFINE(HOST_R11, R11); | 70 | DEFINE_LONGS(HOST_R9, R9); |
68 | DEFINE(HOST_R12, R12); | 71 | DEFINE_LONGS(HOST_R10, R10); |
69 | DEFINE(HOST_R13, R13); | 72 | DEFINE_LONGS(HOST_R11, R11); |
70 | DEFINE(HOST_R14, R14); | 73 | DEFINE_LONGS(HOST_R12, R12); |
71 | DEFINE(HOST_R15, R15); | 74 | DEFINE_LONGS(HOST_R13, R13); |
72 | DEFINE(HOST_ORIG_RAX, ORIG_RAX); | 75 | DEFINE_LONGS(HOST_R14, R14); |
73 | DEFINE(HOST_CS, CS); | 76 | DEFINE_LONGS(HOST_R15, R15); |
74 | DEFINE(HOST_SS, SS); | 77 | DEFINE_LONGS(HOST_ORIG_RAX, ORIG_RAX); |
75 | DEFINE(HOST_EFLAGS, EFLAGS); | 78 | DEFINE_LONGS(HOST_CS, CS); |
79 | DEFINE_LONGS(HOST_SS, SS); | ||
80 | DEFINE_LONGS(HOST_EFLAGS, EFLAGS); | ||
76 | #if 0 | 81 | #if 0 |
77 | DEFINE(HOST_FS, FS); | 82 | DEFINE_LONGS(HOST_FS, FS); |
78 | DEFINE(HOST_GS, GS); | 83 | DEFINE_LONGS(HOST_GS, GS); |
79 | DEFINE(HOST_DS, DS); | 84 | DEFINE_LONGS(HOST_DS, DS); |
80 | DEFINE(HOST_ES, ES); | 85 | DEFINE_LONGS(HOST_ES, ES); |
81 | #endif | 86 | #endif |
82 | 87 | ||
83 | DEFINE(HOST_IP, RIP); | 88 | DEFINE_LONGS(HOST_IP, RIP); |
84 | DEFINE(HOST_SP, RSP); | 89 | DEFINE_LONGS(HOST_SP, RSP); |
85 | DEFINE(__UM_FRAME_SIZE, sizeof(struct user_regs_struct)); | 90 | DEFINE(UM_FRAME_SIZE, sizeof(struct user_regs_struct)); |
86 | } | 91 | } |
diff --git a/arch/um/sys-x86_64/util/Makefile b/arch/um/sys-x86_64/util/Makefile deleted file mode 100644 index 75b052cfc206..000000000000 --- a/arch/um/sys-x86_64/util/Makefile +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | # Copyright 2003 - 2004 Pathscale, Inc | ||
2 | # Released under the GPL | ||
3 | |||
4 | hostprogs-y := mk_sc mk_thread | ||
5 | always := $(hostprogs-y) | ||
6 | |||
7 | HOSTCFLAGS_mk_sc.o := -I$(objtree)/arch/um | ||
8 | HOSTCFLAGS_mk_thread.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/sys-x86_64/util/mk_sc.c b/arch/um/sys-x86_64/util/mk_sc.c deleted file mode 100644 index 7619bc377c1f..000000000000 --- a/arch/um/sys-x86_64/util/mk_sc.c +++ /dev/null | |||
@@ -1,47 +0,0 @@ | |||
1 | /* Copyright (C) 2003 - 2004 PathScale, Inc | ||
2 | * Released under the GPL | ||
3 | */ | ||
4 | |||
5 | #include <stdio.h> | ||
6 | #include <user-offsets.h> | ||
7 | |||
8 | #define SC_OFFSET(name) \ | ||
9 | printf("#define " #name \ | ||
10 | "(sc) *((unsigned long *) &(((char *) (sc))[%d]))\n",\ | ||
11 | name) | ||
12 | |||
13 | int main(int argc, char **argv) | ||
14 | { | ||
15 | SC_OFFSET(SC_RBX); | ||
16 | SC_OFFSET(SC_RCX); | ||
17 | SC_OFFSET(SC_RDX); | ||
18 | SC_OFFSET(SC_RSI); | ||
19 | SC_OFFSET(SC_RDI); | ||
20 | SC_OFFSET(SC_RBP); | ||
21 | SC_OFFSET(SC_RAX); | ||
22 | SC_OFFSET(SC_R8); | ||
23 | SC_OFFSET(SC_R9); | ||
24 | SC_OFFSET(SC_R10); | ||
25 | SC_OFFSET(SC_R11); | ||
26 | SC_OFFSET(SC_R12); | ||
27 | SC_OFFSET(SC_R13); | ||
28 | SC_OFFSET(SC_R14); | ||
29 | SC_OFFSET(SC_R15); | ||
30 | SC_OFFSET(SC_IP); | ||
31 | SC_OFFSET(SC_SP); | ||
32 | SC_OFFSET(SC_CR2); | ||
33 | SC_OFFSET(SC_ERR); | ||
34 | SC_OFFSET(SC_TRAPNO); | ||
35 | SC_OFFSET(SC_CS); | ||
36 | SC_OFFSET(SC_FS); | ||
37 | SC_OFFSET(SC_GS); | ||
38 | SC_OFFSET(SC_EFLAGS); | ||
39 | SC_OFFSET(SC_SIGMASK); | ||
40 | #if 0 | ||
41 | SC_OFFSET(SC_ORIG_RAX); | ||
42 | SC_OFFSET(SC_DS); | ||
43 | SC_OFFSET(SC_ES); | ||
44 | SC_OFFSET(SC_SS); | ||
45 | #endif | ||
46 | return(0); | ||
47 | } | ||
diff --git a/arch/um/sys-x86_64/util/mk_thread.c b/arch/um/sys-x86_64/util/mk_thread.c deleted file mode 100644 index 15517396e9cf..000000000000 --- a/arch/um/sys-x86_64/util/mk_thread.c +++ /dev/null | |||
@@ -1,20 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | int main(int argc, char **argv) | ||
5 | { | ||
6 | printf("/*\n"); | ||
7 | printf(" * Generated by mk_thread\n"); | ||
8 | printf(" */\n"); | ||
9 | printf("\n"); | ||
10 | printf("#ifndef __UM_THREAD_H\n"); | ||
11 | printf("#define __UM_THREAD_H\n"); | ||
12 | printf("\n"); | ||
13 | #ifdef TASK_EXTERN_PID | ||
14 | printf("#define TASK_EXTERN_PID(task) *((int *) &(((char *) (task))[%d]))\n", | ||
15 | TASK_EXTERN_PID); | ||
16 | #endif | ||
17 | printf("\n"); | ||
18 | printf("#endif\n"); | ||
19 | return(0); | ||
20 | } | ||
diff --git a/arch/um/util/Makefile b/arch/um/util/Makefile deleted file mode 100644 index 4c7551c28033..000000000000 --- a/arch/um/util/Makefile +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | hostprogs-y := mk_task mk_constants | ||
2 | always := $(hostprogs-y) | ||
3 | |||
4 | HOSTCFLAGS_mk_task.o := -I$(objtree)/arch/um | ||
5 | HOSTCFLAGS_mk_constants.o := -I$(objtree)/arch/um | ||
diff --git a/arch/um/util/mk_constants.c b/arch/um/util/mk_constants.c deleted file mode 100644 index ab217becc36a..000000000000 --- a/arch/um/util/mk_constants.c +++ /dev/null | |||
@@ -1,32 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | #define SHOW_INT(sym) printf("#define %s %d\n", #sym, sym) | ||
5 | #define SHOW_STR(sym) printf("#define %s %s\n", #sym, sym) | ||
6 | |||
7 | int main(int argc, char **argv) | ||
8 | { | ||
9 | printf("/*\n"); | ||
10 | printf(" * Generated by mk_constants\n"); | ||
11 | printf(" */\n"); | ||
12 | printf("\n"); | ||
13 | printf("#ifndef __UM_CONSTANTS_H\n"); | ||
14 | printf("#define __UM_CONSTANTS_H\n"); | ||
15 | printf("\n"); | ||
16 | |||
17 | SHOW_INT(UM_KERN_PAGE_SIZE); | ||
18 | |||
19 | SHOW_STR(UM_KERN_EMERG); | ||
20 | SHOW_STR(UM_KERN_ALERT); | ||
21 | SHOW_STR(UM_KERN_CRIT); | ||
22 | SHOW_STR(UM_KERN_ERR); | ||
23 | SHOW_STR(UM_KERN_WARNING); | ||
24 | SHOW_STR(UM_KERN_NOTICE); | ||
25 | SHOW_STR(UM_KERN_INFO); | ||
26 | SHOW_STR(UM_KERN_DEBUG); | ||
27 | |||
28 | SHOW_INT(UM_NSEC_PER_SEC); | ||
29 | printf("\n"); | ||
30 | printf("#endif\n"); | ||
31 | return(0); | ||
32 | } | ||
diff --git a/arch/um/util/mk_task.c b/arch/um/util/mk_task.c deleted file mode 100644 index 36c9606505e2..000000000000 --- a/arch/um/util/mk_task.c +++ /dev/null | |||
@@ -1,30 +0,0 @@ | |||
1 | #include <stdio.h> | ||
2 | #include <kernel-offsets.h> | ||
3 | |||
4 | void print_ptr(char *name, char *type, int offset) | ||
5 | { | ||
6 | printf("#define %s(task) ((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
7 | offset); | ||
8 | } | ||
9 | |||
10 | void print(char *name, char *type, int offset) | ||
11 | { | ||
12 | printf("#define %s(task) *((%s *) &(((char *) (task))[%d]))\n", name, type, | ||
13 | offset); | ||
14 | } | ||
15 | |||
16 | int main(int argc, char **argv) | ||
17 | { | ||
18 | printf("/*\n"); | ||
19 | printf(" * Generated by mk_task\n"); | ||
20 | printf(" */\n"); | ||
21 | printf("\n"); | ||
22 | printf("#ifndef __TASK_H\n"); | ||
23 | printf("#define __TASK_H\n"); | ||
24 | printf("\n"); | ||
25 | print_ptr("TASK_REGS", "union uml_pt_regs", TASK_REGS); | ||
26 | print("TASK_PID", "int", TASK_PID); | ||
27 | printf("\n"); | ||
28 | printf("#endif\n"); | ||
29 | return(0); | ||
30 | } | ||
diff --git a/arch/x86_64/kernel/time.c b/arch/x86_64/kernel/time.c index 2373cb8b8625..703acde2a1a5 100644 --- a/arch/x86_64/kernel/time.c +++ b/arch/x86_64/kernel/time.c | |||
@@ -959,9 +959,6 @@ static __init int unsynchronized_tsc(void) | |||
959 | are handled in the OEM check above. */ | 959 | are handled in the OEM check above. */ |
960 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) | 960 | if (boot_cpu_data.x86_vendor == X86_VENDOR_INTEL) |
961 | return 0; | 961 | return 0; |
962 | /* All in a single socket - should be synchronized */ | ||
963 | if (cpus_weight(cpu_core_map[0]) == num_online_cpus()) | ||
964 | return 0; | ||
965 | #endif | 962 | #endif |
966 | /* Assume multi socket systems are not synchronized */ | 963 | /* Assume multi socket systems are not synchronized */ |
967 | return num_online_cpus() > 1; | 964 | return num_online_cpus() > 1; |
diff --git a/drivers/char/drm/drm_drv.c b/drivers/char/drm/drm_drv.c index 6ba48f346fcf..041bb47b5c39 100644 --- a/drivers/char/drm/drm_drv.c +++ b/drivers/char/drm/drm_drv.c | |||
@@ -376,7 +376,7 @@ static int __init drm_core_init(void) | |||
376 | goto err_p2; | 376 | goto err_p2; |
377 | } | 377 | } |
378 | 378 | ||
379 | drm_proc_root = create_proc_entry("dri", S_IFDIR, NULL); | 379 | drm_proc_root = proc_mkdir("dri", NULL); |
380 | if (!drm_proc_root) { | 380 | if (!drm_proc_root) { |
381 | DRM_ERROR("Cannot create /proc/dri\n"); | 381 | DRM_ERROR("Cannot create /proc/dri\n"); |
382 | ret = -1; | 382 | ret = -1; |
diff --git a/drivers/char/drm/drm_proc.c b/drivers/char/drm/drm_proc.c index 32d2bb99462c..977961002488 100644 --- a/drivers/char/drm/drm_proc.c +++ b/drivers/char/drm/drm_proc.c | |||
@@ -95,7 +95,7 @@ int drm_proc_init(drm_device_t *dev, int minor, | |||
95 | char name[64]; | 95 | char name[64]; |
96 | 96 | ||
97 | sprintf(name, "%d", minor); | 97 | sprintf(name, "%d", minor); |
98 | *dev_root = create_proc_entry(name, S_IFDIR, root); | 98 | *dev_root = proc_mkdir(name, root); |
99 | if (!*dev_root) { | 99 | if (!*dev_root) { |
100 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); | 100 | DRM_ERROR("Cannot create /proc/dri/%s\n", name); |
101 | return -1; | 101 | return -1; |
diff --git a/drivers/char/ipmi/ipmi_poweroff.c b/drivers/char/ipmi/ipmi_poweroff.c index e82a96ba396b..f66947722e12 100644 --- a/drivers/char/ipmi/ipmi_poweroff.c +++ b/drivers/char/ipmi/ipmi_poweroff.c | |||
@@ -55,7 +55,7 @@ extern void (*pm_power_off)(void); | |||
55 | static int poweroff_powercycle; | 55 | static int poweroff_powercycle; |
56 | 56 | ||
57 | /* parameter definition to allow user to flag power cycle */ | 57 | /* parameter definition to allow user to flag power cycle */ |
58 | module_param(poweroff_powercycle, int, 0); | 58 | module_param(poweroff_powercycle, int, 0644); |
59 | MODULE_PARM_DESC(poweroff_powercycles, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); | 59 | MODULE_PARM_DESC(poweroff_powercycles, " Set to non-zero to enable power cycle instead of power down. Power cycle is contingent on hardware support, otherwise it defaults back to power down."); |
60 | 60 | ||
61 | /* Stuff from the get device id command. */ | 61 | /* Stuff from the get device id command. */ |
diff --git a/drivers/char/n_r3964.c b/drivers/char/n_r3964.c index 2291a87e8ada..97d6dc24b800 100644 --- a/drivers/char/n_r3964.c +++ b/drivers/char/n_r3964.c | |||
@@ -229,8 +229,8 @@ static int __init r3964_init(void) | |||
229 | TRACE_L("line discipline %d registered", N_R3964); | 229 | TRACE_L("line discipline %d registered", N_R3964); |
230 | TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, | 230 | TRACE_L("flags=%x num=%x", tty_ldisc_N_R3964.flags, |
231 | tty_ldisc_N_R3964.num); | 231 | tty_ldisc_N_R3964.num); |
232 | TRACE_L("open=%x", (int)tty_ldisc_N_R3964.open); | 232 | TRACE_L("open=%p", tty_ldisc_N_R3964.open); |
233 | TRACE_L("tty_ldisc_N_R3964 = %x", (int)&tty_ldisc_N_R3964); | 233 | TRACE_L("tty_ldisc_N_R3964 = %p", &tty_ldisc_N_R3964); |
234 | } | 234 | } |
235 | else | 235 | else |
236 | { | 236 | { |
@@ -267,8 +267,8 @@ static void add_tx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH | |||
267 | 267 | ||
268 | spin_unlock_irqrestore(&pInfo->lock, flags); | 268 | spin_unlock_irqrestore(&pInfo->lock, flags); |
269 | 269 | ||
270 | TRACE_Q("add_tx_queue %x, length %d, tx_first = %x", | 270 | TRACE_Q("add_tx_queue %p, length %d, tx_first = %p", |
271 | (int)pHeader, pHeader->length, (int)pInfo->tx_first ); | 271 | pHeader, pHeader->length, pInfo->tx_first ); |
272 | } | 272 | } |
273 | 273 | ||
274 | static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) | 274 | static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) |
@@ -285,10 +285,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) | |||
285 | return; | 285 | return; |
286 | 286 | ||
287 | #ifdef DEBUG_QUEUE | 287 | #ifdef DEBUG_QUEUE |
288 | printk("r3964: remove_from_tx_queue: %x, length %d - ", | 288 | printk("r3964: remove_from_tx_queue: %p, length %u - ", |
289 | (int)pHeader, (int)pHeader->length ); | 289 | pHeader, pHeader->length ); |
290 | for(pDump=pHeader;pDump;pDump=pDump->next) | 290 | for(pDump=pHeader;pDump;pDump=pDump->next) |
291 | printk("%x ", (int)pDump); | 291 | printk("%p ", pDump); |
292 | printk("\n"); | 292 | printk("\n"); |
293 | #endif | 293 | #endif |
294 | 294 | ||
@@ -319,10 +319,10 @@ static void remove_from_tx_queue(struct r3964_info *pInfo, int error_code) | |||
319 | spin_unlock_irqrestore(&pInfo->lock, flags); | 319 | spin_unlock_irqrestore(&pInfo->lock, flags); |
320 | 320 | ||
321 | kfree(pHeader); | 321 | kfree(pHeader); |
322 | TRACE_M("remove_from_tx_queue - kfree %x",(int)pHeader); | 322 | TRACE_M("remove_from_tx_queue - kfree %p",pHeader); |
323 | 323 | ||
324 | TRACE_Q("remove_from_tx_queue: tx_first = %x, tx_last = %x", | 324 | TRACE_Q("remove_from_tx_queue: tx_first = %p, tx_last = %p", |
325 | (int)pInfo->tx_first, (int)pInfo->tx_last ); | 325 | pInfo->tx_first, pInfo->tx_last ); |
326 | } | 326 | } |
327 | 327 | ||
328 | static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) | 328 | static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pHeader) |
@@ -346,9 +346,9 @@ static void add_rx_queue(struct r3964_info *pInfo, struct r3964_block_header *pH | |||
346 | 346 | ||
347 | spin_unlock_irqrestore(&pInfo->lock, flags); | 347 | spin_unlock_irqrestore(&pInfo->lock, flags); |
348 | 348 | ||
349 | TRACE_Q("add_rx_queue: %x, length = %d, rx_first = %x, count = %d", | 349 | TRACE_Q("add_rx_queue: %p, length = %d, rx_first = %p, count = %d", |
350 | (int)pHeader, pHeader->length, | 350 | pHeader, pHeader->length, |
351 | (int)pInfo->rx_first, pInfo->blocks_in_rx_queue); | 351 | pInfo->rx_first, pInfo->blocks_in_rx_queue); |
352 | } | 352 | } |
353 | 353 | ||
354 | static void remove_from_rx_queue(struct r3964_info *pInfo, | 354 | static void remove_from_rx_queue(struct r3964_info *pInfo, |
@@ -360,10 +360,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo, | |||
360 | if(pHeader==NULL) | 360 | if(pHeader==NULL) |
361 | return; | 361 | return; |
362 | 362 | ||
363 | TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", | 363 | TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", |
364 | (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); | 364 | pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue ); |
365 | TRACE_Q("remove_from_rx_queue: %x, length %d", | 365 | TRACE_Q("remove_from_rx_queue: %p, length %u", |
366 | (int)pHeader, (int)pHeader->length ); | 366 | pHeader, pHeader->length ); |
367 | 367 | ||
368 | spin_lock_irqsave(&pInfo->lock, flags); | 368 | spin_lock_irqsave(&pInfo->lock, flags); |
369 | 369 | ||
@@ -401,10 +401,10 @@ static void remove_from_rx_queue(struct r3964_info *pInfo, | |||
401 | spin_unlock_irqrestore(&pInfo->lock, flags); | 401 | spin_unlock_irqrestore(&pInfo->lock, flags); |
402 | 402 | ||
403 | kfree(pHeader); | 403 | kfree(pHeader); |
404 | TRACE_M("remove_from_rx_queue - kfree %x",(int)pHeader); | 404 | TRACE_M("remove_from_rx_queue - kfree %p",pHeader); |
405 | 405 | ||
406 | TRACE_Q("remove_from_rx_queue: rx_first = %x, rx_last = %x, count = %d", | 406 | TRACE_Q("remove_from_rx_queue: rx_first = %p, rx_last = %p, count = %d", |
407 | (int)pInfo->rx_first, (int)pInfo->rx_last, pInfo->blocks_in_rx_queue ); | 407 | pInfo->rx_first, pInfo->rx_last, pInfo->blocks_in_rx_queue ); |
408 | } | 408 | } |
409 | 409 | ||
410 | static void put_char(struct r3964_info *pInfo, unsigned char ch) | 410 | static void put_char(struct r3964_info *pInfo, unsigned char ch) |
@@ -506,8 +506,8 @@ static void transmit_block(struct r3964_info *pInfo) | |||
506 | if(tty->driver->write_room) | 506 | if(tty->driver->write_room) |
507 | room=tty->driver->write_room(tty); | 507 | room=tty->driver->write_room(tty); |
508 | 508 | ||
509 | TRACE_PS("transmit_block %x, room %d, length %d", | 509 | TRACE_PS("transmit_block %p, room %d, length %d", |
510 | (int)pBlock, room, pBlock->length); | 510 | pBlock, room, pBlock->length); |
511 | 511 | ||
512 | while(pInfo->tx_position < pBlock->length) | 512 | while(pInfo->tx_position < pBlock->length) |
513 | { | 513 | { |
@@ -588,7 +588,7 @@ static void on_receive_block(struct r3964_info *pInfo) | |||
588 | 588 | ||
589 | /* prepare struct r3964_block_header: */ | 589 | /* prepare struct r3964_block_header: */ |
590 | pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL); | 590 | pBlock = kmalloc(length+sizeof(struct r3964_block_header), GFP_KERNEL); |
591 | TRACE_M("on_receive_block - kmalloc %x",(int)pBlock); | 591 | TRACE_M("on_receive_block - kmalloc %p",pBlock); |
592 | 592 | ||
593 | if(pBlock==NULL) | 593 | if(pBlock==NULL) |
594 | return; | 594 | return; |
@@ -868,11 +868,11 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
868 | if(pMsg) | 868 | if(pMsg) |
869 | { | 869 | { |
870 | kfree(pMsg); | 870 | kfree(pMsg); |
871 | TRACE_M("enable_signals - msg kfree %x",(int)pMsg); | 871 | TRACE_M("enable_signals - msg kfree %p",pMsg); |
872 | } | 872 | } |
873 | } | 873 | } |
874 | kfree(pClient); | 874 | kfree(pClient); |
875 | TRACE_M("enable_signals - kfree %x",(int)pClient); | 875 | TRACE_M("enable_signals - kfree %p",pClient); |
876 | return 0; | 876 | return 0; |
877 | } | 877 | } |
878 | } | 878 | } |
@@ -890,7 +890,7 @@ static int enable_signals(struct r3964_info *pInfo, pid_t pid, int arg) | |||
890 | { | 890 | { |
891 | /* add client to client list */ | 891 | /* add client to client list */ |
892 | pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL); | 892 | pClient=kmalloc(sizeof(struct r3964_client_info), GFP_KERNEL); |
893 | TRACE_M("enable_signals - kmalloc %x",(int)pClient); | 893 | TRACE_M("enable_signals - kmalloc %p",pClient); |
894 | if(pClient==NULL) | 894 | if(pClient==NULL) |
895 | return -ENOMEM; | 895 | return -ENOMEM; |
896 | 896 | ||
@@ -954,7 +954,7 @@ static void add_msg(struct r3964_client_info *pClient, int msg_id, int arg, | |||
954 | queue_the_message: | 954 | queue_the_message: |
955 | 955 | ||
956 | pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); | 956 | pMsg = kmalloc(sizeof(struct r3964_message), GFP_KERNEL); |
957 | TRACE_M("add_msg - kmalloc %x",(int)pMsg); | 957 | TRACE_M("add_msg - kmalloc %p",pMsg); |
958 | if(pMsg==NULL) { | 958 | if(pMsg==NULL) { |
959 | return; | 959 | return; |
960 | } | 960 | } |
@@ -1067,11 +1067,11 @@ static int r3964_open(struct tty_struct *tty) | |||
1067 | struct r3964_info *pInfo; | 1067 | struct r3964_info *pInfo; |
1068 | 1068 | ||
1069 | TRACE_L("open"); | 1069 | TRACE_L("open"); |
1070 | TRACE_L("tty=%x, PID=%d, disc_data=%x", | 1070 | TRACE_L("tty=%p, PID=%d, disc_data=%p", |
1071 | (int)tty, current->pid, (int)tty->disc_data); | 1071 | tty, current->pid, tty->disc_data); |
1072 | 1072 | ||
1073 | pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); | 1073 | pInfo=kmalloc(sizeof(struct r3964_info), GFP_KERNEL); |
1074 | TRACE_M("r3964_open - info kmalloc %x",(int)pInfo); | 1074 | TRACE_M("r3964_open - info kmalloc %p",pInfo); |
1075 | 1075 | ||
1076 | if(!pInfo) | 1076 | if(!pInfo) |
1077 | { | 1077 | { |
@@ -1080,26 +1080,26 @@ static int r3964_open(struct tty_struct *tty) | |||
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); | 1082 | pInfo->rx_buf = kmalloc(RX_BUF_SIZE, GFP_KERNEL); |
1083 | TRACE_M("r3964_open - rx_buf kmalloc %x",(int)pInfo->rx_buf); | 1083 | TRACE_M("r3964_open - rx_buf kmalloc %p",pInfo->rx_buf); |
1084 | 1084 | ||
1085 | if(!pInfo->rx_buf) | 1085 | if(!pInfo->rx_buf) |
1086 | { | 1086 | { |
1087 | printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); | 1087 | printk(KERN_ERR "r3964: failed to alloc receive buffer\n"); |
1088 | kfree(pInfo); | 1088 | kfree(pInfo); |
1089 | TRACE_M("r3964_open - info kfree %x",(int)pInfo); | 1089 | TRACE_M("r3964_open - info kfree %p",pInfo); |
1090 | return -ENOMEM; | 1090 | return -ENOMEM; |
1091 | } | 1091 | } |
1092 | 1092 | ||
1093 | pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); | 1093 | pInfo->tx_buf = kmalloc(TX_BUF_SIZE, GFP_KERNEL); |
1094 | TRACE_M("r3964_open - tx_buf kmalloc %x",(int)pInfo->tx_buf); | 1094 | TRACE_M("r3964_open - tx_buf kmalloc %p",pInfo->tx_buf); |
1095 | 1095 | ||
1096 | if(!pInfo->tx_buf) | 1096 | if(!pInfo->tx_buf) |
1097 | { | 1097 | { |
1098 | printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); | 1098 | printk(KERN_ERR "r3964: failed to alloc transmit buffer\n"); |
1099 | kfree(pInfo->rx_buf); | 1099 | kfree(pInfo->rx_buf); |
1100 | TRACE_M("r3964_open - rx_buf kfree %x",(int)pInfo->rx_buf); | 1100 | TRACE_M("r3964_open - rx_buf kfree %p",pInfo->rx_buf); |
1101 | kfree(pInfo); | 1101 | kfree(pInfo); |
1102 | TRACE_M("r3964_open - info kfree %x",(int)pInfo); | 1102 | TRACE_M("r3964_open - info kfree %p",pInfo); |
1103 | return -ENOMEM; | 1103 | return -ENOMEM; |
1104 | } | 1104 | } |
1105 | 1105 | ||
@@ -1154,11 +1154,11 @@ static void r3964_close(struct tty_struct *tty) | |||
1154 | if(pMsg) | 1154 | if(pMsg) |
1155 | { | 1155 | { |
1156 | kfree(pMsg); | 1156 | kfree(pMsg); |
1157 | TRACE_M("r3964_close - msg kfree %x",(int)pMsg); | 1157 | TRACE_M("r3964_close - msg kfree %p",pMsg); |
1158 | } | 1158 | } |
1159 | } | 1159 | } |
1160 | kfree(pClient); | 1160 | kfree(pClient); |
1161 | TRACE_M("r3964_close - client kfree %x",(int)pClient); | 1161 | TRACE_M("r3964_close - client kfree %p",pClient); |
1162 | pClient=pNext; | 1162 | pClient=pNext; |
1163 | } | 1163 | } |
1164 | /* Remove jobs from tx_queue: */ | 1164 | /* Remove jobs from tx_queue: */ |
@@ -1177,11 +1177,11 @@ static void r3964_close(struct tty_struct *tty) | |||
1177 | /* Free buffers: */ | 1177 | /* Free buffers: */ |
1178 | wake_up_interruptible(&pInfo->read_wait); | 1178 | wake_up_interruptible(&pInfo->read_wait); |
1179 | kfree(pInfo->rx_buf); | 1179 | kfree(pInfo->rx_buf); |
1180 | TRACE_M("r3964_close - rx_buf kfree %x",(int)pInfo->rx_buf); | 1180 | TRACE_M("r3964_close - rx_buf kfree %p",pInfo->rx_buf); |
1181 | kfree(pInfo->tx_buf); | 1181 | kfree(pInfo->tx_buf); |
1182 | TRACE_M("r3964_close - tx_buf kfree %x",(int)pInfo->tx_buf); | 1182 | TRACE_M("r3964_close - tx_buf kfree %p",pInfo->tx_buf); |
1183 | kfree(pInfo); | 1183 | kfree(pInfo); |
1184 | TRACE_M("r3964_close - info kfree %x",(int)pInfo); | 1184 | TRACE_M("r3964_close - info kfree %p",pInfo); |
1185 | } | 1185 | } |
1186 | 1186 | ||
1187 | static ssize_t r3964_read(struct tty_struct *tty, struct file *file, | 1187 | static ssize_t r3964_read(struct tty_struct *tty, struct file *file, |
@@ -1234,7 +1234,7 @@ repeat: | |||
1234 | count = sizeof(struct r3964_client_message); | 1234 | count = sizeof(struct r3964_client_message); |
1235 | 1235 | ||
1236 | kfree(pMsg); | 1236 | kfree(pMsg); |
1237 | TRACE_M("r3964_read - msg kfree %x",(int)pMsg); | 1237 | TRACE_M("r3964_read - msg kfree %p",pMsg); |
1238 | 1238 | ||
1239 | if (copy_to_user(buf,&theMsg, count)) | 1239 | if (copy_to_user(buf,&theMsg, count)) |
1240 | return -EFAULT; | 1240 | return -EFAULT; |
@@ -1279,7 +1279,7 @@ static ssize_t r3964_write(struct tty_struct * tty, struct file * file, | |||
1279 | * Allocate a buffer for the data and copy it from the buffer with header prepended | 1279 | * Allocate a buffer for the data and copy it from the buffer with header prepended |
1280 | */ | 1280 | */ |
1281 | new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL); | 1281 | new_data = kmalloc (count+sizeof(struct r3964_block_header), GFP_KERNEL); |
1282 | TRACE_M("r3964_write - kmalloc %x",(int)new_data); | 1282 | TRACE_M("r3964_write - kmalloc %p",new_data); |
1283 | if (new_data == NULL) { | 1283 | if (new_data == NULL) { |
1284 | if (pInfo->flags & R3964_DEBUG) | 1284 | if (pInfo->flags & R3964_DEBUG) |
1285 | { | 1285 | { |
diff --git a/drivers/char/watchdog/mv64x60_wdt.c b/drivers/char/watchdog/mv64x60_wdt.c index 1436aea3b28f..6d3ff0836c44 100644 --- a/drivers/char/watchdog/mv64x60_wdt.c +++ b/drivers/char/watchdog/mv64x60_wdt.c | |||
@@ -87,6 +87,8 @@ static int mv64x60_wdt_open(struct inode *inode, struct file *file) | |||
87 | mv64x60_wdt_service(); | 87 | mv64x60_wdt_service(); |
88 | mv64x60_wdt_handler_enable(); | 88 | mv64x60_wdt_handler_enable(); |
89 | 89 | ||
90 | nonseekable_open(inode, file); | ||
91 | |||
90 | return 0; | 92 | return 0; |
91 | } | 93 | } |
92 | 94 | ||
@@ -103,12 +105,9 @@ static int mv64x60_wdt_release(struct inode *inode, struct file *file) | |||
103 | return 0; | 105 | return 0; |
104 | } | 106 | } |
105 | 107 | ||
106 | static ssize_t mv64x60_wdt_write(struct file *file, const char *data, | 108 | static ssize_t mv64x60_wdt_write(struct file *file, const char __user *data, |
107 | size_t len, loff_t * ppos) | 109 | size_t len, loff_t * ppos) |
108 | { | 110 | { |
109 | if (*ppos != file->f_pos) | ||
110 | return -ESPIPE; | ||
111 | |||
112 | if (len) | 111 | if (len) |
113 | mv64x60_wdt_service(); | 112 | mv64x60_wdt_service(); |
114 | 113 | ||
@@ -119,6 +118,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, | |||
119 | unsigned int cmd, unsigned long arg) | 118 | unsigned int cmd, unsigned long arg) |
120 | { | 119 | { |
121 | int timeout; | 120 | int timeout; |
121 | void __user *argp = (void __user *)arg; | ||
122 | static struct watchdog_info info = { | 122 | static struct watchdog_info info = { |
123 | .options = WDIOF_KEEPALIVEPING, | 123 | .options = WDIOF_KEEPALIVEPING, |
124 | .firmware_version = 0, | 124 | .firmware_version = 0, |
@@ -127,13 +127,13 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, | |||
127 | 127 | ||
128 | switch (cmd) { | 128 | switch (cmd) { |
129 | case WDIOC_GETSUPPORT: | 129 | case WDIOC_GETSUPPORT: |
130 | if (copy_to_user((void *)arg, &info, sizeof(info))) | 130 | if (copy_to_user(argp, &info, sizeof(info))) |
131 | return -EFAULT; | 131 | return -EFAULT; |
132 | break; | 132 | break; |
133 | 133 | ||
134 | case WDIOC_GETSTATUS: | 134 | case WDIOC_GETSTATUS: |
135 | case WDIOC_GETBOOTSTATUS: | 135 | case WDIOC_GETBOOTSTATUS: |
136 | if (put_user(wdt_status, (int *)arg)) | 136 | if (put_user(wdt_status, (int __user *)argp)) |
137 | return -EFAULT; | 137 | return -EFAULT; |
138 | wdt_status &= ~WDIOF_KEEPALIVEPING; | 138 | wdt_status &= ~WDIOF_KEEPALIVEPING; |
139 | break; | 139 | break; |
@@ -154,7 +154,7 @@ static int mv64x60_wdt_ioctl(struct inode *inode, struct file *file, | |||
154 | 154 | ||
155 | case WDIOC_GETTIMEOUT: | 155 | case WDIOC_GETTIMEOUT: |
156 | timeout = mv64x60_wdt_timeout * HZ; | 156 | timeout = mv64x60_wdt_timeout * HZ; |
157 | if (put_user(timeout, (int *)arg)) | 157 | if (put_user(timeout, (int __user *)argp)) |
158 | return -EFAULT; | 158 | return -EFAULT; |
159 | break; | 159 | break; |
160 | 160 | ||
diff --git a/drivers/infiniband/core/uverbs.h b/drivers/infiniband/core/uverbs.h index b1897bed14ad..cc124344dd2c 100644 --- a/drivers/infiniband/core/uverbs.h +++ b/drivers/infiniband/core/uverbs.h | |||
@@ -69,6 +69,7 @@ struct ib_uverbs_event_file { | |||
69 | 69 | ||
70 | struct ib_uverbs_file { | 70 | struct ib_uverbs_file { |
71 | struct kref ref; | 71 | struct kref ref; |
72 | struct semaphore mutex; | ||
72 | struct ib_uverbs_device *device; | 73 | struct ib_uverbs_device *device; |
73 | struct ib_ucontext *ucontext; | 74 | struct ib_ucontext *ucontext; |
74 | struct ib_event_handler event_handler; | 75 | struct ib_event_handler event_handler; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index e91ebde46481..562445165d2b 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
@@ -76,8 +76,9 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
76 | struct ib_uverbs_get_context_resp resp; | 76 | struct ib_uverbs_get_context_resp resp; |
77 | struct ib_udata udata; | 77 | struct ib_udata udata; |
78 | struct ib_device *ibdev = file->device->ib_dev; | 78 | struct ib_device *ibdev = file->device->ib_dev; |
79 | struct ib_ucontext *ucontext; | ||
79 | int i; | 80 | int i; |
80 | int ret = in_len; | 81 | int ret; |
81 | 82 | ||
82 | if (out_len < sizeof resp) | 83 | if (out_len < sizeof resp) |
83 | return -ENOSPC; | 84 | return -ENOSPC; |
@@ -85,45 +86,56 @@ ssize_t ib_uverbs_get_context(struct ib_uverbs_file *file, | |||
85 | if (copy_from_user(&cmd, buf, sizeof cmd)) | 86 | if (copy_from_user(&cmd, buf, sizeof cmd)) |
86 | return -EFAULT; | 87 | return -EFAULT; |
87 | 88 | ||
89 | down(&file->mutex); | ||
90 | |||
91 | if (file->ucontext) { | ||
92 | ret = -EINVAL; | ||
93 | goto err; | ||
94 | } | ||
95 | |||
88 | INIT_UDATA(&udata, buf + sizeof cmd, | 96 | INIT_UDATA(&udata, buf + sizeof cmd, |
89 | (unsigned long) cmd.response + sizeof resp, | 97 | (unsigned long) cmd.response + sizeof resp, |
90 | in_len - sizeof cmd, out_len - sizeof resp); | 98 | in_len - sizeof cmd, out_len - sizeof resp); |
91 | 99 | ||
92 | file->ucontext = ibdev->alloc_ucontext(ibdev, &udata); | 100 | ucontext = ibdev->alloc_ucontext(ibdev, &udata); |
93 | if (IS_ERR(file->ucontext)) { | 101 | if (IS_ERR(ucontext)) |
94 | ret = PTR_ERR(file->ucontext); | 102 | return PTR_ERR(file->ucontext); |
95 | file->ucontext = NULL; | ||
96 | return ret; | ||
97 | } | ||
98 | 103 | ||
99 | file->ucontext->device = ibdev; | 104 | ucontext->device = ibdev; |
100 | INIT_LIST_HEAD(&file->ucontext->pd_list); | 105 | INIT_LIST_HEAD(&ucontext->pd_list); |
101 | INIT_LIST_HEAD(&file->ucontext->mr_list); | 106 | INIT_LIST_HEAD(&ucontext->mr_list); |
102 | INIT_LIST_HEAD(&file->ucontext->mw_list); | 107 | INIT_LIST_HEAD(&ucontext->mw_list); |
103 | INIT_LIST_HEAD(&file->ucontext->cq_list); | 108 | INIT_LIST_HEAD(&ucontext->cq_list); |
104 | INIT_LIST_HEAD(&file->ucontext->qp_list); | 109 | INIT_LIST_HEAD(&ucontext->qp_list); |
105 | INIT_LIST_HEAD(&file->ucontext->srq_list); | 110 | INIT_LIST_HEAD(&ucontext->srq_list); |
106 | INIT_LIST_HEAD(&file->ucontext->ah_list); | 111 | INIT_LIST_HEAD(&ucontext->ah_list); |
107 | spin_lock_init(&file->ucontext->lock); | ||
108 | 112 | ||
109 | resp.async_fd = file->async_file.fd; | 113 | resp.async_fd = file->async_file.fd; |
110 | for (i = 0; i < file->device->num_comp; ++i) | 114 | for (i = 0; i < file->device->num_comp; ++i) |
111 | if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab + | 115 | if (copy_to_user((void __user *) (unsigned long) cmd.cq_fd_tab + |
112 | i * sizeof (__u32), | 116 | i * sizeof (__u32), |
113 | &file->comp_file[i].fd, sizeof (__u32))) | 117 | &file->comp_file[i].fd, sizeof (__u32))) { |
114 | goto err; | 118 | ret = -EFAULT; |
119 | goto err_free; | ||
120 | } | ||
115 | 121 | ||
116 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 122 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
117 | &resp, sizeof resp)) | 123 | &resp, sizeof resp)) { |
118 | goto err; | 124 | ret = -EFAULT; |
125 | goto err_free; | ||
126 | } | ||
127 | |||
128 | file->ucontext = ucontext; | ||
129 | up(&file->mutex); | ||
119 | 130 | ||
120 | return in_len; | 131 | return in_len; |
121 | 132 | ||
122 | err: | 133 | err_free: |
123 | ibdev->dealloc_ucontext(file->ucontext); | 134 | ibdev->dealloc_ucontext(ucontext); |
124 | file->ucontext = NULL; | ||
125 | 135 | ||
126 | return -EFAULT; | 136 | err: |
137 | up(&file->mutex); | ||
138 | return ret; | ||
127 | } | 139 | } |
128 | 140 | ||
129 | ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, | 141 | ssize_t ib_uverbs_query_device(struct ib_uverbs_file *file, |
@@ -352,9 +364,9 @@ retry: | |||
352 | if (ret) | 364 | if (ret) |
353 | goto err_pd; | 365 | goto err_pd; |
354 | 366 | ||
355 | spin_lock_irq(&file->ucontext->lock); | 367 | down(&file->mutex); |
356 | list_add_tail(&uobj->list, &file->ucontext->pd_list); | 368 | list_add_tail(&uobj->list, &file->ucontext->pd_list); |
357 | spin_unlock_irq(&file->ucontext->lock); | 369 | up(&file->mutex); |
358 | 370 | ||
359 | memset(&resp, 0, sizeof resp); | 371 | memset(&resp, 0, sizeof resp); |
360 | resp.pd_handle = uobj->id; | 372 | resp.pd_handle = uobj->id; |
@@ -368,9 +380,9 @@ retry: | |||
368 | return in_len; | 380 | return in_len; |
369 | 381 | ||
370 | err_list: | 382 | err_list: |
371 | spin_lock_irq(&file->ucontext->lock); | 383 | down(&file->mutex); |
372 | list_del(&uobj->list); | 384 | list_del(&uobj->list); |
373 | spin_unlock_irq(&file->ucontext->lock); | 385 | up(&file->mutex); |
374 | 386 | ||
375 | down(&ib_uverbs_idr_mutex); | 387 | down(&ib_uverbs_idr_mutex); |
376 | idr_remove(&ib_uverbs_pd_idr, uobj->id); | 388 | idr_remove(&ib_uverbs_pd_idr, uobj->id); |
@@ -410,9 +422,9 @@ ssize_t ib_uverbs_dealloc_pd(struct ib_uverbs_file *file, | |||
410 | 422 | ||
411 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); | 423 | idr_remove(&ib_uverbs_pd_idr, cmd.pd_handle); |
412 | 424 | ||
413 | spin_lock_irq(&file->ucontext->lock); | 425 | down(&file->mutex); |
414 | list_del(&uobj->list); | 426 | list_del(&uobj->list); |
415 | spin_unlock_irq(&file->ucontext->lock); | 427 | up(&file->mutex); |
416 | 428 | ||
417 | kfree(uobj); | 429 | kfree(uobj); |
418 | 430 | ||
@@ -512,9 +524,9 @@ retry: | |||
512 | 524 | ||
513 | resp.mr_handle = obj->uobject.id; | 525 | resp.mr_handle = obj->uobject.id; |
514 | 526 | ||
515 | spin_lock_irq(&file->ucontext->lock); | 527 | down(&file->mutex); |
516 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); | 528 | list_add_tail(&obj->uobject.list, &file->ucontext->mr_list); |
517 | spin_unlock_irq(&file->ucontext->lock); | 529 | up(&file->mutex); |
518 | 530 | ||
519 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 531 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
520 | &resp, sizeof resp)) { | 532 | &resp, sizeof resp)) { |
@@ -527,9 +539,9 @@ retry: | |||
527 | return in_len; | 539 | return in_len; |
528 | 540 | ||
529 | err_list: | 541 | err_list: |
530 | spin_lock_irq(&file->ucontext->lock); | 542 | down(&file->mutex); |
531 | list_del(&obj->uobject.list); | 543 | list_del(&obj->uobject.list); |
532 | spin_unlock_irq(&file->ucontext->lock); | 544 | up(&file->mutex); |
533 | 545 | ||
534 | err_unreg: | 546 | err_unreg: |
535 | ib_dereg_mr(mr); | 547 | ib_dereg_mr(mr); |
@@ -570,9 +582,9 @@ ssize_t ib_uverbs_dereg_mr(struct ib_uverbs_file *file, | |||
570 | 582 | ||
571 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); | 583 | idr_remove(&ib_uverbs_mr_idr, cmd.mr_handle); |
572 | 584 | ||
573 | spin_lock_irq(&file->ucontext->lock); | 585 | down(&file->mutex); |
574 | list_del(&memobj->uobject.list); | 586 | list_del(&memobj->uobject.list); |
575 | spin_unlock_irq(&file->ucontext->lock); | 587 | up(&file->mutex); |
576 | 588 | ||
577 | ib_umem_release(file->device->ib_dev, &memobj->umem); | 589 | ib_umem_release(file->device->ib_dev, &memobj->umem); |
578 | kfree(memobj); | 590 | kfree(memobj); |
@@ -647,9 +659,9 @@ retry: | |||
647 | if (ret) | 659 | if (ret) |
648 | goto err_cq; | 660 | goto err_cq; |
649 | 661 | ||
650 | spin_lock_irq(&file->ucontext->lock); | 662 | down(&file->mutex); |
651 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); | 663 | list_add_tail(&uobj->uobject.list, &file->ucontext->cq_list); |
652 | spin_unlock_irq(&file->ucontext->lock); | 664 | up(&file->mutex); |
653 | 665 | ||
654 | memset(&resp, 0, sizeof resp); | 666 | memset(&resp, 0, sizeof resp); |
655 | resp.cq_handle = uobj->uobject.id; | 667 | resp.cq_handle = uobj->uobject.id; |
@@ -664,9 +676,9 @@ retry: | |||
664 | return in_len; | 676 | return in_len; |
665 | 677 | ||
666 | err_list: | 678 | err_list: |
667 | spin_lock_irq(&file->ucontext->lock); | 679 | down(&file->mutex); |
668 | list_del(&uobj->uobject.list); | 680 | list_del(&uobj->uobject.list); |
669 | spin_unlock_irq(&file->ucontext->lock); | 681 | up(&file->mutex); |
670 | 682 | ||
671 | down(&ib_uverbs_idr_mutex); | 683 | down(&ib_uverbs_idr_mutex); |
672 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); | 684 | idr_remove(&ib_uverbs_cq_idr, uobj->uobject.id); |
@@ -712,9 +724,9 @@ ssize_t ib_uverbs_destroy_cq(struct ib_uverbs_file *file, | |||
712 | 724 | ||
713 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); | 725 | idr_remove(&ib_uverbs_cq_idr, cmd.cq_handle); |
714 | 726 | ||
715 | spin_lock_irq(&file->ucontext->lock); | 727 | down(&file->mutex); |
716 | list_del(&uobj->uobject.list); | 728 | list_del(&uobj->uobject.list); |
717 | spin_unlock_irq(&file->ucontext->lock); | 729 | up(&file->mutex); |
718 | 730 | ||
719 | spin_lock_irq(&file->comp_file[0].lock); | 731 | spin_lock_irq(&file->comp_file[0].lock); |
720 | list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { | 732 | list_for_each_entry_safe(evt, tmp, &uobj->comp_list, obj_list) { |
@@ -847,9 +859,9 @@ retry: | |||
847 | 859 | ||
848 | resp.qp_handle = uobj->uobject.id; | 860 | resp.qp_handle = uobj->uobject.id; |
849 | 861 | ||
850 | spin_lock_irq(&file->ucontext->lock); | 862 | down(&file->mutex); |
851 | list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); | 863 | list_add_tail(&uobj->uobject.list, &file->ucontext->qp_list); |
852 | spin_unlock_irq(&file->ucontext->lock); | 864 | up(&file->mutex); |
853 | 865 | ||
854 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 866 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
855 | &resp, sizeof resp)) { | 867 | &resp, sizeof resp)) { |
@@ -862,9 +874,9 @@ retry: | |||
862 | return in_len; | 874 | return in_len; |
863 | 875 | ||
864 | err_list: | 876 | err_list: |
865 | spin_lock_irq(&file->ucontext->lock); | 877 | down(&file->mutex); |
866 | list_del(&uobj->uobject.list); | 878 | list_del(&uobj->uobject.list); |
867 | spin_unlock_irq(&file->ucontext->lock); | 879 | up(&file->mutex); |
868 | 880 | ||
869 | err_destroy: | 881 | err_destroy: |
870 | ib_destroy_qp(qp); | 882 | ib_destroy_qp(qp); |
@@ -989,9 +1001,9 @@ ssize_t ib_uverbs_destroy_qp(struct ib_uverbs_file *file, | |||
989 | 1001 | ||
990 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); | 1002 | idr_remove(&ib_uverbs_qp_idr, cmd.qp_handle); |
991 | 1003 | ||
992 | spin_lock_irq(&file->ucontext->lock); | 1004 | down(&file->mutex); |
993 | list_del(&uobj->uobject.list); | 1005 | list_del(&uobj->uobject.list); |
994 | spin_unlock_irq(&file->ucontext->lock); | 1006 | up(&file->mutex); |
995 | 1007 | ||
996 | spin_lock_irq(&file->async_file.lock); | 1008 | spin_lock_irq(&file->async_file.lock); |
997 | list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { | 1009 | list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { |
@@ -1136,9 +1148,9 @@ retry: | |||
1136 | 1148 | ||
1137 | resp.srq_handle = uobj->uobject.id; | 1149 | resp.srq_handle = uobj->uobject.id; |
1138 | 1150 | ||
1139 | spin_lock_irq(&file->ucontext->lock); | 1151 | down(&file->mutex); |
1140 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); | 1152 | list_add_tail(&uobj->uobject.list, &file->ucontext->srq_list); |
1141 | spin_unlock_irq(&file->ucontext->lock); | 1153 | up(&file->mutex); |
1142 | 1154 | ||
1143 | if (copy_to_user((void __user *) (unsigned long) cmd.response, | 1155 | if (copy_to_user((void __user *) (unsigned long) cmd.response, |
1144 | &resp, sizeof resp)) { | 1156 | &resp, sizeof resp)) { |
@@ -1151,9 +1163,9 @@ retry: | |||
1151 | return in_len; | 1163 | return in_len; |
1152 | 1164 | ||
1153 | err_list: | 1165 | err_list: |
1154 | spin_lock_irq(&file->ucontext->lock); | 1166 | down(&file->mutex); |
1155 | list_del(&uobj->uobject.list); | 1167 | list_del(&uobj->uobject.list); |
1156 | spin_unlock_irq(&file->ucontext->lock); | 1168 | up(&file->mutex); |
1157 | 1169 | ||
1158 | err_destroy: | 1170 | err_destroy: |
1159 | ib_destroy_srq(srq); | 1171 | ib_destroy_srq(srq); |
@@ -1227,9 +1239,9 @@ ssize_t ib_uverbs_destroy_srq(struct ib_uverbs_file *file, | |||
1227 | 1239 | ||
1228 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); | 1240 | idr_remove(&ib_uverbs_srq_idr, cmd.srq_handle); |
1229 | 1241 | ||
1230 | spin_lock_irq(&file->ucontext->lock); | 1242 | down(&file->mutex); |
1231 | list_del(&uobj->uobject.list); | 1243 | list_del(&uobj->uobject.list); |
1232 | spin_unlock_irq(&file->ucontext->lock); | 1244 | up(&file->mutex); |
1233 | 1245 | ||
1234 | spin_lock_irq(&file->async_file.lock); | 1246 | spin_lock_irq(&file->async_file.lock); |
1235 | list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { | 1247 | list_for_each_entry_safe(evt, tmp, &uobj->event_list, obj_list) { |
diff --git a/drivers/infiniband/core/uverbs_main.c b/drivers/infiniband/core/uverbs_main.c index ce5bdb7af306..12511808de21 100644 --- a/drivers/infiniband/core/uverbs_main.c +++ b/drivers/infiniband/core/uverbs_main.c | |||
@@ -448,7 +448,9 @@ static ssize_t ib_uverbs_write(struct file *filp, const char __user *buf, | |||
448 | if (hdr.in_words * 4 != count) | 448 | if (hdr.in_words * 4 != count) |
449 | return -EINVAL; | 449 | return -EINVAL; |
450 | 450 | ||
451 | if (hdr.command < 0 || hdr.command >= ARRAY_SIZE(uverbs_cmd_table)) | 451 | if (hdr.command < 0 || |
452 | hdr.command >= ARRAY_SIZE(uverbs_cmd_table) || | ||
453 | !uverbs_cmd_table[hdr.command]) | ||
452 | return -EINVAL; | 454 | return -EINVAL; |
453 | 455 | ||
454 | if (!file->ucontext && | 456 | if (!file->ucontext && |
@@ -484,27 +486,29 @@ static int ib_uverbs_open(struct inode *inode, struct file *filp) | |||
484 | file = kmalloc(sizeof *file + | 486 | file = kmalloc(sizeof *file + |
485 | (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file), | 487 | (dev->num_comp - 1) * sizeof (struct ib_uverbs_event_file), |
486 | GFP_KERNEL); | 488 | GFP_KERNEL); |
487 | if (!file) | 489 | if (!file) { |
488 | return -ENOMEM; | 490 | ret = -ENOMEM; |
491 | goto err; | ||
492 | } | ||
489 | 493 | ||
490 | file->device = dev; | 494 | file->device = dev; |
491 | kref_init(&file->ref); | 495 | kref_init(&file->ref); |
496 | init_MUTEX(&file->mutex); | ||
492 | 497 | ||
493 | file->ucontext = NULL; | 498 | file->ucontext = NULL; |
494 | 499 | ||
500 | kref_get(&file->ref); | ||
495 | ret = ib_uverbs_event_init(&file->async_file, file); | 501 | ret = ib_uverbs_event_init(&file->async_file, file); |
496 | if (ret) | 502 | if (ret) |
497 | goto err; | 503 | goto err_kref; |
498 | 504 | ||
499 | file->async_file.is_async = 1; | 505 | file->async_file.is_async = 1; |
500 | 506 | ||
501 | kref_get(&file->ref); | ||
502 | |||
503 | for (i = 0; i < dev->num_comp; ++i) { | 507 | for (i = 0; i < dev->num_comp; ++i) { |
508 | kref_get(&file->ref); | ||
504 | ret = ib_uverbs_event_init(&file->comp_file[i], file); | 509 | ret = ib_uverbs_event_init(&file->comp_file[i], file); |
505 | if (ret) | 510 | if (ret) |
506 | goto err_async; | 511 | goto err_async; |
507 | kref_get(&file->ref); | ||
508 | file->comp_file[i].is_async = 0; | 512 | file->comp_file[i].is_async = 0; |
509 | } | 513 | } |
510 | 514 | ||
@@ -524,9 +528,16 @@ err_async: | |||
524 | 528 | ||
525 | ib_uverbs_event_release(&file->async_file); | 529 | ib_uverbs_event_release(&file->async_file); |
526 | 530 | ||
527 | err: | 531 | err_kref: |
532 | /* | ||
533 | * One extra kref_put() because we took a reference before the | ||
534 | * event file creation that failed and got us here. | ||
535 | */ | ||
536 | kref_put(&file->ref, ib_uverbs_release_file); | ||
528 | kref_put(&file->ref, ib_uverbs_release_file); | 537 | kref_put(&file->ref, ib_uverbs_release_file); |
529 | 538 | ||
539 | err: | ||
540 | module_put(dev->ib_dev->owner); | ||
530 | return ret; | 541 | return ret; |
531 | } | 542 | } |
532 | 543 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index cc758a2d2bc6..f6a8ac026557 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
@@ -605,7 +605,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, | |||
605 | err = -EINVAL; | 605 | err = -EINVAL; |
606 | goto out; | 606 | goto out; |
607 | } | 607 | } |
608 | for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i, ++nent) { | 608 | for (i = 0; i < mthca_icm_size(&iter) / (1 << lg); ++i) { |
609 | if (virt != -1) { | 609 | if (virt != -1) { |
610 | pages[nent * 2] = cpu_to_be64(virt); | 610 | pages[nent * 2] = cpu_to_be64(virt); |
611 | virt += 1 << lg; | 611 | virt += 1 << lg; |
@@ -616,7 +616,7 @@ static int mthca_map_cmd(struct mthca_dev *dev, u16 op, struct mthca_icm *icm, | |||
616 | ts += 1 << (lg - 10); | 616 | ts += 1 << (lg - 10); |
617 | ++tc; | 617 | ++tc; |
618 | 618 | ||
619 | if (nent == MTHCA_MAILBOX_SIZE / 16) { | 619 | if (++nent == MTHCA_MAILBOX_SIZE / 16) { |
620 | err = mthca_cmd(dev, mailbox->dma, nent, 0, op, | 620 | err = mthca_cmd(dev, mailbox->dma, nent, 0, op, |
621 | CMD_TIME_CLASS_B, status); | 621 | CMD_TIME_CLASS_B, status); |
622 | if (err || *status) | 622 | if (err || *status) |
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 78152a8ad17d..c81fa8e975ef 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
@@ -836,7 +836,7 @@ int __devinit mthca_init_eq_table(struct mthca_dev *dev) | |||
836 | dev->eq_table.clr_mask = | 836 | dev->eq_table.clr_mask = |
837 | swab32(1 << (dev->eq_table.inta_pin & 31)); | 837 | swab32(1 << (dev->eq_table.inta_pin & 31)); |
838 | dev->eq_table.clr_int = dev->clr_base + | 838 | dev->eq_table.clr_int = dev->clr_base + |
839 | (dev->eq_table.inta_pin < 31 ? 4 : 0); | 839 | (dev->eq_table.inta_pin < 32 ? 4 : 0); |
840 | } | 840 | } |
841 | 841 | ||
842 | dev->eq_table.arm_mask = 0; | 842 | dev->eq_table.arm_mask = 0; |
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 1827400f189b..7bd7a4bec7b4 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
@@ -290,7 +290,7 @@ struct mthca_icm_table *mthca_alloc_icm_table(struct mthca_dev *dev, | |||
290 | int i; | 290 | int i; |
291 | u8 status; | 291 | u8 status; |
292 | 292 | ||
293 | num_icm = obj_size * nobj / MTHCA_TABLE_CHUNK_SIZE; | 293 | num_icm = (obj_size * nobj + MTHCA_TABLE_CHUNK_SIZE - 1) / MTHCA_TABLE_CHUNK_SIZE; |
294 | 294 | ||
295 | table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL); | 295 | table = kmalloc(sizeof *table + num_icm * sizeof *table->icm, GFP_KERNEL); |
296 | if (!table) | 296 | if (!table) |
@@ -529,12 +529,25 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) | |||
529 | goto found; | 529 | goto found; |
530 | } | 530 | } |
531 | 531 | ||
532 | for (i = start; i != end; i += dir) | ||
533 | if (!dev->db_tab->page[i].db_rec) { | ||
534 | page = dev->db_tab->page + i; | ||
535 | goto alloc; | ||
536 | } | ||
537 | |||
532 | if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { | 538 | if (dev->db_tab->max_group1 >= dev->db_tab->min_group2 - 1) { |
533 | ret = -ENOMEM; | 539 | ret = -ENOMEM; |
534 | goto out; | 540 | goto out; |
535 | } | 541 | } |
536 | 542 | ||
543 | if (group == 0) | ||
544 | ++dev->db_tab->max_group1; | ||
545 | else | ||
546 | --dev->db_tab->min_group2; | ||
547 | |||
537 | page = dev->db_tab->page + end; | 548 | page = dev->db_tab->page + end; |
549 | |||
550 | alloc: | ||
538 | page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, | 551 | page->db_rec = dma_alloc_coherent(&dev->pdev->dev, 4096, |
539 | &page->mapping, GFP_KERNEL); | 552 | &page->mapping, GFP_KERNEL); |
540 | if (!page->db_rec) { | 553 | if (!page->db_rec) { |
@@ -554,10 +567,6 @@ int mthca_alloc_db(struct mthca_dev *dev, int type, u32 qn, __be32 **db) | |||
554 | } | 567 | } |
555 | 568 | ||
556 | bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); | 569 | bitmap_zero(page->used, MTHCA_DB_REC_PER_PAGE); |
557 | if (group == 0) | ||
558 | ++dev->db_tab->max_group1; | ||
559 | else | ||
560 | --dev->db_tab->min_group2; | ||
561 | 570 | ||
562 | found: | 571 | found: |
563 | j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); | 572 | j = find_first_zero_bit(page->used, MTHCA_DB_REC_PER_PAGE); |
diff --git a/drivers/infiniband/hw/mthca/mthca_provider.c b/drivers/infiniband/hw/mthca/mthca_provider.c index 1c1c2e230871..3f5319a46577 100644 --- a/drivers/infiniband/hw/mthca/mthca_provider.c +++ b/drivers/infiniband/hw/mthca/mthca_provider.c | |||
@@ -84,7 +84,7 @@ static int mthca_query_device(struct ib_device *ibdev, | |||
84 | props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & | 84 | props->vendor_id = be32_to_cpup((__be32 *) (out_mad->data + 36)) & |
85 | 0xffffff; | 85 | 0xffffff; |
86 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); | 86 | props->vendor_part_id = be16_to_cpup((__be16 *) (out_mad->data + 30)); |
87 | props->hw_ver = be16_to_cpup((__be16 *) (out_mad->data + 32)); | 87 | props->hw_ver = be32_to_cpup((__be32 *) (out_mad->data + 32)); |
88 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); | 88 | memcpy(&props->sys_image_guid, out_mad->data + 4, 8); |
89 | memcpy(&props->node_guid, out_mad->data + 12, 8); | 89 | memcpy(&props->node_guid, out_mad->data + 12, 8); |
90 | 90 | ||
diff --git a/drivers/isdn/divert/divert_procfs.c b/drivers/isdn/divert/divert_procfs.c index e1f0d87de0eb..0b0ea26023e5 100644 --- a/drivers/isdn/divert/divert_procfs.c +++ b/drivers/isdn/divert/divert_procfs.c | |||
@@ -287,12 +287,12 @@ divert_dev_init(void) | |||
287 | init_waitqueue_head(&rd_queue); | 287 | init_waitqueue_head(&rd_queue); |
288 | 288 | ||
289 | #ifdef CONFIG_PROC_FS | 289 | #ifdef CONFIG_PROC_FS |
290 | isdn_proc_entry = create_proc_entry("isdn", S_IFDIR | S_IRUGO | S_IXUGO, proc_net); | 290 | isdn_proc_entry = proc_mkdir("net/isdn", NULL); |
291 | if (!isdn_proc_entry) | 291 | if (!isdn_proc_entry) |
292 | return (-1); | 292 | return (-1); |
293 | isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); | 293 | isdn_divert_entry = create_proc_entry("divert", S_IFREG | S_IRUGO, isdn_proc_entry); |
294 | if (!isdn_divert_entry) { | 294 | if (!isdn_divert_entry) { |
295 | remove_proc_entry("isdn", proc_net); | 295 | remove_proc_entry("net/isdn", NULL); |
296 | return (-1); | 296 | return (-1); |
297 | } | 297 | } |
298 | isdn_divert_entry->proc_fops = &isdn_fops; | 298 | isdn_divert_entry->proc_fops = &isdn_fops; |
@@ -312,7 +312,7 @@ divert_dev_deinit(void) | |||
312 | 312 | ||
313 | #ifdef CONFIG_PROC_FS | 313 | #ifdef CONFIG_PROC_FS |
314 | remove_proc_entry("divert", isdn_proc_entry); | 314 | remove_proc_entry("divert", isdn_proc_entry); |
315 | remove_proc_entry("isdn", proc_net); | 315 | remove_proc_entry("net/isdn", NULL); |
316 | #endif /* CONFIG_PROC_FS */ | 316 | #endif /* CONFIG_PROC_FS */ |
317 | 317 | ||
318 | return (0); | 318 | return (0); |
diff --git a/drivers/isdn/hardware/eicon/diva_didd.c b/drivers/isdn/hardware/eicon/diva_didd.c index 7fdf8ae5be52..27204f4b111a 100644 --- a/drivers/isdn/hardware/eicon/diva_didd.c +++ b/drivers/isdn/hardware/eicon/diva_didd.c | |||
@@ -30,8 +30,6 @@ static char *DRIVERNAME = | |||
30 | static char *DRIVERLNAME = "divadidd"; | 30 | static char *DRIVERLNAME = "divadidd"; |
31 | char *DRIVERRELEASE_DIDD = "2.0"; | 31 | char *DRIVERRELEASE_DIDD = "2.0"; |
32 | 32 | ||
33 | static char *main_proc_dir = "eicon"; | ||
34 | |||
35 | MODULE_DESCRIPTION("DIDD table driver for diva drivers"); | 33 | MODULE_DESCRIPTION("DIDD table driver for diva drivers"); |
36 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); | 34 | MODULE_AUTHOR("Cytronics & Melware, Eicon Networks"); |
37 | MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); | 35 | MODULE_SUPPORTED_DEVICE("Eicon diva drivers"); |
@@ -89,7 +87,7 @@ proc_read(char *page, char **start, off_t off, int count, int *eof, | |||
89 | 87 | ||
90 | static int DIVA_INIT_FUNCTION create_proc(void) | 88 | static int DIVA_INIT_FUNCTION create_proc(void) |
91 | { | 89 | { |
92 | proc_net_eicon = create_proc_entry(main_proc_dir, S_IFDIR, proc_net); | 90 | proc_net_eicon = proc_mkdir("net/eicon", NULL); |
93 | 91 | ||
94 | if (proc_net_eicon) { | 92 | if (proc_net_eicon) { |
95 | if ((proc_didd = | 93 | if ((proc_didd = |
@@ -105,7 +103,7 @@ static int DIVA_INIT_FUNCTION create_proc(void) | |||
105 | static void DIVA_EXIT_FUNCTION remove_proc(void) | 103 | static void DIVA_EXIT_FUNCTION remove_proc(void) |
106 | { | 104 | { |
107 | remove_proc_entry(DRIVERLNAME, proc_net_eicon); | 105 | remove_proc_entry(DRIVERLNAME, proc_net_eicon); |
108 | remove_proc_entry(main_proc_dir, proc_net); | 106 | remove_proc_entry("net/eicon", NULL); |
109 | } | 107 | } |
110 | 108 | ||
111 | static int DIVA_INIT_FUNCTION divadidd_init(void) | 109 | static int DIVA_INIT_FUNCTION divadidd_init(void) |
diff --git a/drivers/isdn/hardware/eicon/divasproc.c b/drivers/isdn/hardware/eicon/divasproc.c index b6435589d459..c12efa6f8429 100644 --- a/drivers/isdn/hardware/eicon/divasproc.c +++ b/drivers/isdn/hardware/eicon/divasproc.c | |||
@@ -381,7 +381,7 @@ int create_adapter_proc(diva_os_xdi_adapter_t * a) | |||
381 | char tmp[16]; | 381 | char tmp[16]; |
382 | 382 | ||
383 | sprintf(tmp, "%s%d", adapter_dir_name, a->controller); | 383 | sprintf(tmp, "%s%d", adapter_dir_name, a->controller); |
384 | if (!(de = create_proc_entry(tmp, S_IFDIR, proc_net_eicon))) | 384 | if (!(de = proc_mkdir(tmp, proc_net_eicon))) |
385 | return (0); | 385 | return (0); |
386 | a->proc_adapter_dir = (void *) de; | 386 | a->proc_adapter_dir = (void *) de; |
387 | 387 | ||
diff --git a/drivers/isdn/hysdn/hysdn_procconf.c b/drivers/isdn/hysdn/hysdn_procconf.c index 5da507e532fc..639582f61f41 100644 --- a/drivers/isdn/hysdn/hysdn_procconf.c +++ b/drivers/isdn/hysdn/hysdn_procconf.c | |||
@@ -394,7 +394,7 @@ hysdn_procconf_init(void) | |||
394 | hysdn_card *card; | 394 | hysdn_card *card; |
395 | uchar conf_name[20]; | 395 | uchar conf_name[20]; |
396 | 396 | ||
397 | hysdn_proc_entry = create_proc_entry(PROC_SUBDIR_NAME, S_IFDIR | S_IRUGO | S_IXUGO, proc_net); | 397 | hysdn_proc_entry = proc_mkdir(PROC_SUBDIR_NAME, proc_net); |
398 | if (!hysdn_proc_entry) { | 398 | if (!hysdn_proc_entry) { |
399 | printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n"); | 399 | printk(KERN_ERR "HYSDN: unable to create hysdn subdir\n"); |
400 | return (-1); | 400 | return (-1); |
diff --git a/drivers/md/dm-ioctl.c b/drivers/md/dm-ioctl.c index 200a0688f717..54ec737195e0 100644 --- a/drivers/md/dm-ioctl.c +++ b/drivers/md/dm-ioctl.c | |||
@@ -230,11 +230,20 @@ static int dm_hash_insert(const char *name, const char *uuid, struct mapped_devi | |||
230 | 230 | ||
231 | static void __hash_remove(struct hash_cell *hc) | 231 | static void __hash_remove(struct hash_cell *hc) |
232 | { | 232 | { |
233 | struct dm_table *table; | ||
234 | |||
233 | /* remove from the dev hash */ | 235 | /* remove from the dev hash */ |
234 | list_del(&hc->uuid_list); | 236 | list_del(&hc->uuid_list); |
235 | list_del(&hc->name_list); | 237 | list_del(&hc->name_list); |
236 | unregister_with_devfs(hc); | 238 | unregister_with_devfs(hc); |
237 | dm_set_mdptr(hc->md, NULL); | 239 | dm_set_mdptr(hc->md, NULL); |
240 | |||
241 | table = dm_get_table(hc->md); | ||
242 | if (table) { | ||
243 | dm_table_event(table); | ||
244 | dm_table_put(table); | ||
245 | } | ||
246 | |||
238 | dm_put(hc->md); | 247 | dm_put(hc->md); |
239 | if (hc->new_map) | 248 | if (hc->new_map) |
240 | dm_table_put(hc->new_map); | 249 | dm_table_put(hc->new_map); |
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 785806bdb248..f9b7b32d5d5c 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -329,13 +329,17 @@ static int map_io(struct multipath *m, struct bio *bio, struct mpath_io *mpio, | |||
329 | /* | 329 | /* |
330 | * If we run out of usable paths, should we queue I/O or error it? | 330 | * If we run out of usable paths, should we queue I/O or error it? |
331 | */ | 331 | */ |
332 | static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path) | 332 | static int queue_if_no_path(struct multipath *m, unsigned queue_if_no_path, |
333 | unsigned save_old_value) | ||
333 | { | 334 | { |
334 | unsigned long flags; | 335 | unsigned long flags; |
335 | 336 | ||
336 | spin_lock_irqsave(&m->lock, flags); | 337 | spin_lock_irqsave(&m->lock, flags); |
337 | 338 | ||
338 | m->saved_queue_if_no_path = m->queue_if_no_path; | 339 | if (save_old_value) |
340 | m->saved_queue_if_no_path = m->queue_if_no_path; | ||
341 | else | ||
342 | m->saved_queue_if_no_path = queue_if_no_path; | ||
339 | m->queue_if_no_path = queue_if_no_path; | 343 | m->queue_if_no_path = queue_if_no_path; |
340 | if (!m->queue_if_no_path && m->queue_size) | 344 | if (!m->queue_if_no_path && m->queue_size) |
341 | queue_work(kmultipathd, &m->process_queued_ios); | 345 | queue_work(kmultipathd, &m->process_queued_ios); |
@@ -677,7 +681,7 @@ static int parse_features(struct arg_set *as, struct multipath *m, | |||
677 | return 0; | 681 | return 0; |
678 | 682 | ||
679 | if (!strnicmp(shift(as), MESG_STR("queue_if_no_path"))) | 683 | if (!strnicmp(shift(as), MESG_STR("queue_if_no_path"))) |
680 | return queue_if_no_path(m, 1); | 684 | return queue_if_no_path(m, 1, 0); |
681 | else { | 685 | else { |
682 | ti->error = "Unrecognised multipath feature request"; | 686 | ti->error = "Unrecognised multipath feature request"; |
683 | return -EINVAL; | 687 | return -EINVAL; |
@@ -1077,7 +1081,7 @@ static void multipath_presuspend(struct dm_target *ti) | |||
1077 | { | 1081 | { |
1078 | struct multipath *m = (struct multipath *) ti->private; | 1082 | struct multipath *m = (struct multipath *) ti->private; |
1079 | 1083 | ||
1080 | queue_if_no_path(m, 0); | 1084 | queue_if_no_path(m, 0, 1); |
1081 | } | 1085 | } |
1082 | 1086 | ||
1083 | /* | 1087 | /* |
@@ -1222,9 +1226,9 @@ static int multipath_message(struct dm_target *ti, unsigned argc, char **argv) | |||
1222 | 1226 | ||
1223 | if (argc == 1) { | 1227 | if (argc == 1) { |
1224 | if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) | 1228 | if (!strnicmp(argv[0], MESG_STR("queue_if_no_path"))) |
1225 | return queue_if_no_path(m, 1); | 1229 | return queue_if_no_path(m, 1, 0); |
1226 | else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) | 1230 | else if (!strnicmp(argv[0], MESG_STR("fail_if_no_path"))) |
1227 | return queue_if_no_path(m, 0); | 1231 | return queue_if_no_path(m, 0, 0); |
1228 | } | 1232 | } |
1229 | 1233 | ||
1230 | if (argc != 2) | 1234 | if (argc != 2) |
diff --git a/drivers/media/dvb/frontends/tda10021.c b/drivers/media/dvb/frontends/tda10021.c index 87d5f4d8790f..eaf130e666d8 100644 --- a/drivers/media/dvb/frontends/tda10021.c +++ b/drivers/media/dvb/frontends/tda10021.c | |||
@@ -100,8 +100,8 @@ static u8 tda10021_readreg (struct tda10021_state* state, u8 reg) | |||
100 | 100 | ||
101 | ret = i2c_transfer (state->i2c, msg, 2); | 101 | ret = i2c_transfer (state->i2c, msg, 2); |
102 | if (ret != 2) | 102 | if (ret != 2) |
103 | printk("DVB: TDA10021(%d): %s: readreg error (ret == %i)\n", | 103 | printk("DVB: TDA10021: %s: readreg error (ret == %i)\n", |
104 | state->frontend.dvb->num, __FUNCTION__, ret); | 104 | __FUNCTION__, ret); |
105 | return b1[0]; | 105 | return b1[0]; |
106 | } | 106 | } |
107 | 107 | ||
diff --git a/drivers/media/video/cpia.c b/drivers/media/video/cpia.c index 8c08b7f1ad23..b7ec9bf45085 100644 --- a/drivers/media/video/cpia.c +++ b/drivers/media/video/cpia.c | |||
@@ -1397,7 +1397,7 @@ static void destroy_proc_cpia_cam(struct cam_data *cam) | |||
1397 | 1397 | ||
1398 | static void proc_cpia_create(void) | 1398 | static void proc_cpia_create(void) |
1399 | { | 1399 | { |
1400 | cpia_proc_root = create_proc_entry("cpia", S_IFDIR, NULL); | 1400 | cpia_proc_root = proc_mkdir("cpia", NULL); |
1401 | 1401 | ||
1402 | if (cpia_proc_root) | 1402 | if (cpia_proc_root) |
1403 | cpia_proc_root->owner = THIS_MODULE; | 1403 | cpia_proc_root->owner = THIS_MODULE; |
diff --git a/drivers/media/video/rds.h b/drivers/media/video/rds.h index 30337d0f1a87..0d30eb744e61 100644 --- a/drivers/media/video/rds.h +++ b/drivers/media/video/rds.h | |||
@@ -31,7 +31,7 @@ | |||
31 | struct rds_command { | 31 | struct rds_command { |
32 | unsigned int block_count; | 32 | unsigned int block_count; |
33 | int result; | 33 | int result; |
34 | unsigned char *buffer; | 34 | unsigned char __user *buffer; |
35 | struct file *instance; | 35 | struct file *instance; |
36 | poll_table *event_list; | 36 | poll_table *event_list; |
37 | }; | 37 | }; |
diff --git a/drivers/media/video/saa6588.c b/drivers/media/video/saa6588.c index 1a657a70ff43..72b70eb5da1d 100644 --- a/drivers/media/video/saa6588.c +++ b/drivers/media/video/saa6588.c | |||
@@ -157,7 +157,7 @@ static struct i2c_client client_template; | |||
157 | 157 | ||
158 | /* ---------------------------------------------------------------------- */ | 158 | /* ---------------------------------------------------------------------- */ |
159 | 159 | ||
160 | static int block_to_user_buf(struct saa6588 *s, unsigned char *user_buf) | 160 | static int block_to_user_buf(struct saa6588 *s, unsigned char __user *user_buf) |
161 | { | 161 | { |
162 | int i; | 162 | int i; |
163 | 163 | ||
@@ -191,7 +191,7 @@ static void read_from_buf(struct saa6588 *s, struct rds_command *a) | |||
191 | { | 191 | { |
192 | unsigned long flags; | 192 | unsigned long flags; |
193 | 193 | ||
194 | unsigned char *buf_ptr = a->buffer; /* This is a user space buffer! */ | 194 | unsigned char __user *buf_ptr = a->buffer; |
195 | unsigned int i; | 195 | unsigned int i; |
196 | unsigned int rd_blocks; | 196 | unsigned int rd_blocks; |
197 | 197 | ||
diff --git a/drivers/mtd/maps/ixp4xx.c b/drivers/mtd/maps/ixp4xx.c index 5afe660aa2c4..bbb0e6e569a6 100644 --- a/drivers/mtd/maps/ixp4xx.c +++ b/drivers/mtd/maps/ixp4xx.c | |||
@@ -254,6 +254,6 @@ module_init(ixp4xx_flash_init); | |||
254 | module_exit(ixp4xx_flash_exit); | 254 | module_exit(ixp4xx_flash_exit); |
255 | 255 | ||
256 | MODULE_LICENSE("GPL"); | 256 | MODULE_LICENSE("GPL"); |
257 | MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems") | 257 | MODULE_DESCRIPTION("MTD map driver for Intel IXP4xx systems"); |
258 | MODULE_AUTHOR("Deepak Saxena"); | 258 | MODULE_AUTHOR("Deepak Saxena"); |
259 | 259 | ||
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 32d5fabd4b10..a2c4dd4fb221 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -99,7 +99,7 @@ static irqreturn_t ibmveth_interrupt(int irq, void *dev_instance, struct pt_regs | |||
99 | static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*); | 99 | static inline void ibmveth_schedule_replenishing(struct ibmveth_adapter*); |
100 | 100 | ||
101 | #ifdef CONFIG_PROC_FS | 101 | #ifdef CONFIG_PROC_FS |
102 | #define IBMVETH_PROC_DIR "ibmveth" | 102 | #define IBMVETH_PROC_DIR "net/ibmveth" |
103 | static struct proc_dir_entry *ibmveth_proc_dir; | 103 | static struct proc_dir_entry *ibmveth_proc_dir; |
104 | #endif | 104 | #endif |
105 | 105 | ||
@@ -1010,7 +1010,7 @@ static int __devexit ibmveth_remove(struct vio_dev *dev) | |||
1010 | #ifdef CONFIG_PROC_FS | 1010 | #ifdef CONFIG_PROC_FS |
1011 | static void ibmveth_proc_register_driver(void) | 1011 | static void ibmveth_proc_register_driver(void) |
1012 | { | 1012 | { |
1013 | ibmveth_proc_dir = create_proc_entry(IBMVETH_PROC_DIR, S_IFDIR, proc_net); | 1013 | ibmveth_proc_dir = proc_mkdir(IBMVETH_PROC_DIR, NULL); |
1014 | if (ibmveth_proc_dir) { | 1014 | if (ibmveth_proc_dir) { |
1015 | SET_MODULE_OWNER(ibmveth_proc_dir); | 1015 | SET_MODULE_OWNER(ibmveth_proc_dir); |
1016 | } | 1016 | } |
@@ -1018,7 +1018,7 @@ static void ibmveth_proc_register_driver(void) | |||
1018 | 1018 | ||
1019 | static void ibmveth_proc_unregister_driver(void) | 1019 | static void ibmveth_proc_unregister_driver(void) |
1020 | { | 1020 | { |
1021 | remove_proc_entry(IBMVETH_PROC_DIR, proc_net); | 1021 | remove_proc_entry(IBMVETH_PROC_DIR, NULL); |
1022 | } | 1022 | } |
1023 | 1023 | ||
1024 | static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) | 1024 | static void *ibmveth_seq_start(struct seq_file *seq, loff_t *pos) |
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index 6d9de626c967..651c5a6578fd 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c | |||
@@ -1875,11 +1875,11 @@ static int __init vlsi_mod_init(void) | |||
1875 | 1875 | ||
1876 | sirpulse = !!sirpulse; | 1876 | sirpulse = !!sirpulse; |
1877 | 1877 | ||
1878 | /* create_proc_entry returns NULL if !CONFIG_PROC_FS. | 1878 | /* proc_mkdir returns NULL if !CONFIG_PROC_FS. |
1879 | * Failure to create the procfs entry is handled like running | 1879 | * Failure to create the procfs entry is handled like running |
1880 | * without procfs - it's not required for the driver to work. | 1880 | * without procfs - it's not required for the driver to work. |
1881 | */ | 1881 | */ |
1882 | vlsi_proc_root = create_proc_entry(PROC_DIR, S_IFDIR, NULL); | 1882 | vlsi_proc_root = proc_mkdir(PROC_DIR, NULL); |
1883 | if (vlsi_proc_root) { | 1883 | if (vlsi_proc_root) { |
1884 | /* protect registered procdir against module removal. | 1884 | /* protect registered procdir against module removal. |
1885 | * Because we are in the module init path there's no race | 1885 | * Because we are in the module init path there's no race |
diff --git a/drivers/net/pppoe.c b/drivers/net/pppoe.c index 82f236cc3b9b..a842ecc60a34 100644 --- a/drivers/net/pppoe.c +++ b/drivers/net/pppoe.c | |||
@@ -1070,7 +1070,7 @@ static int __init pppoe_proc_init(void) | |||
1070 | { | 1070 | { |
1071 | struct proc_dir_entry *p; | 1071 | struct proc_dir_entry *p; |
1072 | 1072 | ||
1073 | p = create_proc_entry("pppoe", S_IRUGO, proc_net); | 1073 | p = create_proc_entry("net/pppoe", S_IRUGO, NULL); |
1074 | if (!p) | 1074 | if (!p) |
1075 | return -ENOMEM; | 1075 | return -ENOMEM; |
1076 | 1076 | ||
@@ -1142,7 +1142,7 @@ static void __exit pppoe_exit(void) | |||
1142 | dev_remove_pack(&pppoes_ptype); | 1142 | dev_remove_pack(&pppoes_ptype); |
1143 | dev_remove_pack(&pppoed_ptype); | 1143 | dev_remove_pack(&pppoed_ptype); |
1144 | unregister_netdevice_notifier(&pppoe_notifier); | 1144 | unregister_netdevice_notifier(&pppoe_notifier); |
1145 | remove_proc_entry("pppoe", proc_net); | 1145 | remove_proc_entry("net/pppoe", NULL); |
1146 | proto_unregister(&pppoe_sk_proto); | 1146 | proto_unregister(&pppoe_sk_proto); |
1147 | } | 1147 | } |
1148 | 1148 | ||
diff --git a/drivers/net/sk98lin/skge.c b/drivers/net/sk98lin/skge.c index 2e72d79a143c..b18c92cb629e 100644 --- a/drivers/net/sk98lin/skge.c +++ b/drivers/net/sk98lin/skge.c | |||
@@ -235,7 +235,7 @@ static int SkDrvDeInitAdapter(SK_AC *pAC, int devNbr); | |||
235 | * Extern Function Prototypes | 235 | * Extern Function Prototypes |
236 | * | 236 | * |
237 | ******************************************************************************/ | 237 | ******************************************************************************/ |
238 | static const char SKRootName[] = "sk98lin"; | 238 | static const char SKRootName[] = "net/sk98lin"; |
239 | static struct proc_dir_entry *pSkRootDir; | 239 | static struct proc_dir_entry *pSkRootDir; |
240 | extern struct file_operations sk_proc_fops; | 240 | extern struct file_operations sk_proc_fops; |
241 | 241 | ||
@@ -5242,20 +5242,20 @@ static int __init skge_init(void) | |||
5242 | { | 5242 | { |
5243 | int error; | 5243 | int error; |
5244 | 5244 | ||
5245 | pSkRootDir = proc_mkdir(SKRootName, proc_net); | 5245 | pSkRootDir = proc_mkdir(SKRootName, NULL); |
5246 | if (pSkRootDir) | 5246 | if (pSkRootDir) |
5247 | pSkRootDir->owner = THIS_MODULE; | 5247 | pSkRootDir->owner = THIS_MODULE; |
5248 | 5248 | ||
5249 | error = pci_register_driver(&skge_driver); | 5249 | error = pci_register_driver(&skge_driver); |
5250 | if (error) | 5250 | if (error) |
5251 | proc_net_remove(SKRootName); | 5251 | remove_proc_entry(SKRootName, NULL); |
5252 | return error; | 5252 | return error; |
5253 | } | 5253 | } |
5254 | 5254 | ||
5255 | static void __exit skge_exit(void) | 5255 | static void __exit skge_exit(void) |
5256 | { | 5256 | { |
5257 | pci_unregister_driver(&skge_driver); | 5257 | pci_unregister_driver(&skge_driver); |
5258 | proc_net_remove(SKRootName); | 5258 | remove_proc_entry(SKRootName, NULL); |
5259 | 5259 | ||
5260 | } | 5260 | } |
5261 | 5261 | ||
diff --git a/drivers/net/wireless/orinoco.c b/drivers/net/wireless/orinoco.c index 8de49fe57233..6deb7cc810cc 100644 --- a/drivers/net/wireless/orinoco.c +++ b/drivers/net/wireless/orinoco.c | |||
@@ -2458,7 +2458,6 @@ struct net_device *alloc_orinocodev(int sizeof_card, | |||
2458 | dev->watchdog_timeo = HZ; /* 1 second timeout */ | 2458 | dev->watchdog_timeo = HZ; /* 1 second timeout */ |
2459 | dev->get_stats = orinoco_get_stats; | 2459 | dev->get_stats = orinoco_get_stats; |
2460 | dev->ethtool_ops = &orinoco_ethtool_ops; | 2460 | dev->ethtool_ops = &orinoco_ethtool_ops; |
2461 | dev->get_wireless_stats = orinoco_get_wireless_stats; | ||
2462 | dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def; | 2461 | dev->wireless_handlers = (struct iw_handler_def *)&orinoco_handler_def; |
2463 | dev->change_mtu = orinoco_change_mtu; | 2462 | dev->change_mtu = orinoco_change_mtu; |
2464 | dev->set_multicast_list = orinoco_set_multicast_list; | 2463 | dev->set_multicast_list = orinoco_set_multicast_list; |
@@ -4399,6 +4398,7 @@ static const struct iw_handler_def orinoco_handler_def = { | |||
4399 | .standard = orinoco_handler, | 4398 | .standard = orinoco_handler, |
4400 | .private = orinoco_private_handler, | 4399 | .private = orinoco_private_handler, |
4401 | .private_args = orinoco_privtab, | 4400 | .private_args = orinoco_privtab, |
4401 | .get_wireless_stats = orinoco_get_wireless_stats, | ||
4402 | }; | 4402 | }; |
4403 | 4403 | ||
4404 | static void orinoco_get_drvinfo(struct net_device *dev, | 4404 | static void orinoco_get_drvinfo(struct net_device *dev, |
diff --git a/drivers/pcmcia/rsrc_nonstatic.c b/drivers/pcmcia/rsrc_nonstatic.c index c42455d20eb6..f9a5c70284b5 100644 --- a/drivers/pcmcia/rsrc_nonstatic.c +++ b/drivers/pcmcia/rsrc_nonstatic.c | |||
@@ -691,7 +691,7 @@ static int adjust_memory(struct pcmcia_socket *s, unsigned int action, unsigned | |||
691 | unsigned long size = end - start + 1; | 691 | unsigned long size = end - start + 1; |
692 | int ret = 0; | 692 | int ret = 0; |
693 | 693 | ||
694 | if (end <= start) | 694 | if (end < start) |
695 | return -EINVAL; | 695 | return -EINVAL; |
696 | 696 | ||
697 | down(&rsrc_sem); | 697 | down(&rsrc_sem); |
@@ -724,7 +724,7 @@ static int adjust_io(struct pcmcia_socket *s, unsigned int action, unsigned long | |||
724 | unsigned long size = end - start + 1; | 724 | unsigned long size = end - start + 1; |
725 | int ret = 0; | 725 | int ret = 0; |
726 | 726 | ||
727 | if (end <= start) | 727 | if (end < start) |
728 | return -EINVAL; | 728 | return -EINVAL; |
729 | 729 | ||
730 | if (end > IO_SPACE_LIMIT) | 730 | if (end > IO_SPACE_LIMIT) |
@@ -817,7 +817,7 @@ static int nonstatic_autoadd_resources(struct pcmcia_socket *s) | |||
817 | 817 | ||
818 | /* if we got at least one of IO, and one of MEM, we can be glad and | 818 | /* if we got at least one of IO, and one of MEM, we can be glad and |
819 | * activate the PCMCIA subsystem */ | 819 | * activate the PCMCIA subsystem */ |
820 | if (done & (IORESOURCE_MEM | IORESOURCE_IO)) | 820 | if (done == (IORESOURCE_MEM | IORESOURCE_IO)) |
821 | s->resource_setup_done = 1; | 821 | s->resource_setup_done = 1; |
822 | 822 | ||
823 | return 0; | 823 | return 0; |
@@ -925,7 +925,7 @@ static ssize_t store_io_db(struct class_device *class_dev, const char *buf, size | |||
925 | return -EINVAL; | 925 | return -EINVAL; |
926 | } | 926 | } |
927 | } | 927 | } |
928 | if (end_addr <= start_addr) | 928 | if (end_addr < start_addr) |
929 | return -EINVAL; | 929 | return -EINVAL; |
930 | 930 | ||
931 | ret = adjust_io(s, add, start_addr, end_addr); | 931 | ret = adjust_io(s, add, start_addr, end_addr); |
@@ -977,7 +977,7 @@ static ssize_t store_mem_db(struct class_device *class_dev, const char *buf, siz | |||
977 | return -EINVAL; | 977 | return -EINVAL; |
978 | } | 978 | } |
979 | } | 979 | } |
980 | if (end_addr <= start_addr) | 980 | if (end_addr < start_addr) |
981 | return -EINVAL; | 981 | return -EINVAL; |
982 | 982 | ||
983 | ret = adjust_memory(s, add, start_addr, end_addr); | 983 | ret = adjust_memory(s, add, start_addr, end_addr); |
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 4d09a6e4dd2e..ad94367df430 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
@@ -2849,8 +2849,7 @@ sg_proc_init(void) | |||
2849 | struct proc_dir_entry *pdep; | 2849 | struct proc_dir_entry *pdep; |
2850 | struct sg_proc_leaf * leaf; | 2850 | struct sg_proc_leaf * leaf; |
2851 | 2851 | ||
2852 | sg_proc_sgp = create_proc_entry(sg_proc_sg_dirname, | 2852 | sg_proc_sgp = proc_mkdir(sg_proc_sg_dirname, NULL); |
2853 | S_IFDIR | S_IRUGO | S_IXUGO, NULL); | ||
2854 | if (!sg_proc_sgp) | 2853 | if (!sg_proc_sgp) |
2855 | return 1; | 2854 | return 1; |
2856 | for (k = 0; k < num_leaves; ++k) { | 2855 | for (k = 0; k < num_leaves; ++k) { |
diff --git a/drivers/usb/media/vicam.c b/drivers/usb/media/vicam.c index 4a5857c53f11..0bc0b1247a6b 100644 --- a/drivers/usb/media/vicam.c +++ b/drivers/usb/media/vicam.c | |||
@@ -1148,7 +1148,7 @@ vicam_write_proc_gain(struct file *file, const char *buffer, | |||
1148 | static void | 1148 | static void |
1149 | vicam_create_proc_root(void) | 1149 | vicam_create_proc_root(void) |
1150 | { | 1150 | { |
1151 | vicam_proc_root = create_proc_entry("video/vicam", S_IFDIR, 0); | 1151 | vicam_proc_root = proc_mkdir("video/vicam", NULL); |
1152 | 1152 | ||
1153 | if (vicam_proc_root) | 1153 | if (vicam_proc_root) |
1154 | vicam_proc_root->owner = THIS_MODULE; | 1154 | vicam_proc_root->owner = THIS_MODULE; |
@@ -1181,7 +1181,7 @@ vicam_create_proc_entry(struct vicam_camera *cam) | |||
1181 | 1181 | ||
1182 | sprintf(name, "video%d", cam->vdev.minor); | 1182 | sprintf(name, "video%d", cam->vdev.minor); |
1183 | 1183 | ||
1184 | cam->proc_dir = create_proc_entry(name, S_IFDIR, vicam_proc_root); | 1184 | cam->proc_dir = proc_mkdir(name, vicam_proc_root); |
1185 | 1185 | ||
1186 | if ( !cam->proc_dir ) | 1186 | if ( !cam->proc_dir ) |
1187 | return; // FIXME: We should probably return an error here | 1187 | return; // FIXME: We should probably return an error here |
diff --git a/drivers/video/Kconfig b/drivers/video/Kconfig index 773ae11b4a19..1cd942abb580 100644 --- a/drivers/video/Kconfig +++ b/drivers/video/Kconfig | |||
@@ -768,6 +768,7 @@ config FB_INTEL | |||
768 | select FB_CFB_FILLRECT | 768 | select FB_CFB_FILLRECT |
769 | select FB_CFB_COPYAREA | 769 | select FB_CFB_COPYAREA |
770 | select FB_CFB_IMAGEBLIT | 770 | select FB_CFB_IMAGEBLIT |
771 | select FB_SOFT_CURSOR | ||
771 | help | 772 | help |
772 | This driver supports the on-board graphics built in to the Intel | 773 | This driver supports the on-board graphics built in to the Intel |
773 | 830M/845G/852GM/855GM/865G chipsets. | 774 | 830M/845G/852GM/855GM/865G chipsets. |
diff --git a/drivers/video/cyblafb.c b/drivers/video/cyblafb.c index ae2762cb5608..6992100a508c 100644 --- a/drivers/video/cyblafb.c +++ b/drivers/video/cyblafb.c | |||
@@ -410,20 +410,21 @@ static void cyblafb_imageblit(struct fb_info *info, | |||
410 | out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1)); | 410 | out32(GE0C,point(image->dx+image->width-1,image->dy+image->height-1)); |
411 | 411 | ||
412 | while(index < index_end) { | 412 | while(index < index_end) { |
413 | const char *p = image->data + index; | ||
413 | for(i=0;i<width_dds;i++) { | 414 | for(i=0;i<width_dds;i++) { |
414 | out32(GE9C,*((u32*) ((u32)image->data + index))); | 415 | out32(GE9C,*(u32*)p); |
416 | p+=4; | ||
415 | index+=4; | 417 | index+=4; |
416 | } | 418 | } |
417 | switch(width_dbs) { | 419 | switch(width_dbs) { |
418 | case 0: break; | 420 | case 0: break; |
419 | case 8: out32(GE9C,*((u8*)((u32)image->data+index))); | 421 | case 8: out32(GE9C,*(u8*)p); |
420 | index+=1; | 422 | index+=1; |
421 | break; | 423 | break; |
422 | case 16: out32(GE9C,*((u16*)((u32)image->data+index))); | 424 | case 16: out32(GE9C,*(u16*)p); |
423 | index+=2; | 425 | index+=2; |
424 | break; | 426 | break; |
425 | case 24: out32(GE9C,(u32)(*((u16*)((u32)image->data+index))) | | 427 | case 24: out32(GE9C,*(u16*)p | *(u8*)(p+2)<<16); |
426 | (u32)(*((u8*)((u32)image->data+index+2)))<<16); | ||
427 | index+=3; | 428 | index+=3; |
428 | break; | 429 | break; |
429 | } | 430 | } |
diff --git a/drivers/video/i810/i810-i2c.c b/drivers/video/i810/i810-i2c.c index fda53aac1fc1..689d2586366d 100644 --- a/drivers/video/i810/i810-i2c.c +++ b/drivers/video/i810/i810-i2c.c | |||
@@ -44,7 +44,7 @@ static void i810i2c_setscl(void *data, int state) | |||
44 | { | 44 | { |
45 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 45 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
46 | struct i810fb_par *par = chan->par; | 46 | struct i810fb_par *par = chan->par; |
47 | u8 *mmio = par->mmio_start_virtual; | 47 | u8 __iomem *mmio = par->mmio_start_virtual; |
48 | 48 | ||
49 | i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | | 49 | i810_writel(mmio, GPIOB, (state ? SCL_VAL_OUT : 0) | SCL_DIR | |
50 | SCL_DIR_MASK | SCL_VAL_MASK); | 50 | SCL_DIR_MASK | SCL_VAL_MASK); |
@@ -55,7 +55,7 @@ static void i810i2c_setsda(void *data, int state) | |||
55 | { | 55 | { |
56 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 56 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
57 | struct i810fb_par *par = chan->par; | 57 | struct i810fb_par *par = chan->par; |
58 | u8 *mmio = par->mmio_start_virtual; | 58 | u8 __iomem *mmio = par->mmio_start_virtual; |
59 | 59 | ||
60 | i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | | 60 | i810_writel(mmio, GPIOB, (state ? SDA_VAL_OUT : 0) | SDA_DIR | |
61 | SDA_DIR_MASK | SDA_VAL_MASK); | 61 | SDA_DIR_MASK | SDA_VAL_MASK); |
@@ -66,7 +66,7 @@ static int i810i2c_getscl(void *data) | |||
66 | { | 66 | { |
67 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 67 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
68 | struct i810fb_par *par = chan->par; | 68 | struct i810fb_par *par = chan->par; |
69 | u8 *mmio = par->mmio_start_virtual; | 69 | u8 __iomem *mmio = par->mmio_start_virtual; |
70 | 70 | ||
71 | i810_writel(mmio, GPIOB, SCL_DIR_MASK); | 71 | i810_writel(mmio, GPIOB, SCL_DIR_MASK); |
72 | i810_writel(mmio, GPIOB, 0); | 72 | i810_writel(mmio, GPIOB, 0); |
@@ -77,7 +77,7 @@ static int i810i2c_getsda(void *data) | |||
77 | { | 77 | { |
78 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 78 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
79 | struct i810fb_par *par = chan->par; | 79 | struct i810fb_par *par = chan->par; |
80 | u8 *mmio = par->mmio_start_virtual; | 80 | u8 __iomem *mmio = par->mmio_start_virtual; |
81 | 81 | ||
82 | i810_writel(mmio, GPIOB, SDA_DIR_MASK); | 82 | i810_writel(mmio, GPIOB, SDA_DIR_MASK); |
83 | i810_writel(mmio, GPIOB, 0); | 83 | i810_writel(mmio, GPIOB, 0); |
@@ -88,7 +88,7 @@ static void i810ddc_setscl(void *data, int state) | |||
88 | { | 88 | { |
89 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 89 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
90 | struct i810fb_par *par = chan->par; | 90 | struct i810fb_par *par = chan->par; |
91 | u8 *mmio = par->mmio_start_virtual; | 91 | u8 __iomem *mmio = par->mmio_start_virtual; |
92 | 92 | ||
93 | i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR | | 93 | i810_writel(mmio, GPIOA, (state ? SCL_VAL_OUT : 0) | SCL_DIR | |
94 | SCL_DIR_MASK | SCL_VAL_MASK); | 94 | SCL_DIR_MASK | SCL_VAL_MASK); |
@@ -99,7 +99,7 @@ static void i810ddc_setsda(void *data, int state) | |||
99 | { | 99 | { |
100 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 100 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
101 | struct i810fb_par *par = chan->par; | 101 | struct i810fb_par *par = chan->par; |
102 | u8 *mmio = par->mmio_start_virtual; | 102 | u8 __iomem *mmio = par->mmio_start_virtual; |
103 | 103 | ||
104 | i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR | | 104 | i810_writel(mmio, GPIOA, (state ? SDA_VAL_OUT : 0) | SDA_DIR | |
105 | SDA_DIR_MASK | SDA_VAL_MASK); | 105 | SDA_DIR_MASK | SDA_VAL_MASK); |
@@ -110,7 +110,7 @@ static int i810ddc_getscl(void *data) | |||
110 | { | 110 | { |
111 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 111 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
112 | struct i810fb_par *par = chan->par; | 112 | struct i810fb_par *par = chan->par; |
113 | u8 *mmio = par->mmio_start_virtual; | 113 | u8 __iomem *mmio = par->mmio_start_virtual; |
114 | 114 | ||
115 | i810_writel(mmio, GPIOA, SCL_DIR_MASK); | 115 | i810_writel(mmio, GPIOA, SCL_DIR_MASK); |
116 | i810_writel(mmio, GPIOA, 0); | 116 | i810_writel(mmio, GPIOA, 0); |
@@ -121,7 +121,7 @@ static int i810ddc_getsda(void *data) | |||
121 | { | 121 | { |
122 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; | 122 | struct i810fb_i2c_chan *chan = (struct i810fb_i2c_chan *)data; |
123 | struct i810fb_par *par = chan->par; | 123 | struct i810fb_par *par = chan->par; |
124 | u8 *mmio = par->mmio_start_virtual; | 124 | u8 __iomem *mmio = par->mmio_start_virtual; |
125 | 125 | ||
126 | i810_writel(mmio, GPIOA, SDA_DIR_MASK); | 126 | i810_writel(mmio, GPIOA, SDA_DIR_MASK); |
127 | i810_writel(mmio, GPIOA, 0); | 127 | i810_writel(mmio, GPIOA, 0); |
diff --git a/drivers/video/intelfb/intelfbdrv.c b/drivers/video/intelfb/intelfbdrv.c index bf62e6ed0382..80a09344f1aa 100644 --- a/drivers/video/intelfb/intelfbdrv.c +++ b/drivers/video/intelfb/intelfbdrv.c | |||
@@ -226,7 +226,7 @@ MODULE_DEVICE_TABLE(pci, intelfb_pci_table); | |||
226 | 226 | ||
227 | static int accel = 1; | 227 | static int accel = 1; |
228 | static int vram = 4; | 228 | static int vram = 4; |
229 | static int hwcursor = 1; | 229 | static int hwcursor = 0; |
230 | static int mtrr = 1; | 230 | static int mtrr = 1; |
231 | static int fixed = 0; | 231 | static int fixed = 0; |
232 | static int noinit = 0; | 232 | static int noinit = 0; |
@@ -609,15 +609,9 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
609 | dinfo->accel = 0; | 609 | dinfo->accel = 0; |
610 | } | 610 | } |
611 | 611 | ||
612 | if (MB(voffset) < stolen_size) | ||
613 | offset = (stolen_size >> 12); | ||
614 | else | ||
615 | offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; | ||
616 | |||
617 | /* Framebuffer parameters - Use all the stolen memory if >= vram */ | 612 | /* Framebuffer parameters - Use all the stolen memory if >= vram */ |
618 | if (ROUND_UP_TO_PAGE(stolen_size) >= ((offset << 12) + MB(vram))) { | 613 | if (ROUND_UP_TO_PAGE(stolen_size) >= MB(vram)) { |
619 | dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); | 614 | dinfo->fb.size = ROUND_UP_TO_PAGE(stolen_size); |
620 | dinfo->fb.offset = 0; | ||
621 | dinfo->fbmem_gart = 0; | 615 | dinfo->fbmem_gart = 0; |
622 | } else { | 616 | } else { |
623 | dinfo->fb.size = MB(vram); | 617 | dinfo->fb.size = MB(vram); |
@@ -648,6 +642,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
648 | return -ENODEV; | 642 | return -ENODEV; |
649 | } | 643 | } |
650 | 644 | ||
645 | if (MB(voffset) < stolen_size) | ||
646 | offset = (stolen_size >> 12); | ||
647 | else | ||
648 | offset = ROUND_UP_TO_PAGE(MB(voffset))/GTT_PAGE_SIZE; | ||
649 | |||
651 | /* set the mem offsets - set them after the already used pages */ | 650 | /* set the mem offsets - set them after the already used pages */ |
652 | if (dinfo->accel) { | 651 | if (dinfo->accel) { |
653 | dinfo->ring.offset = offset + gtt_info.current_memory; | 652 | dinfo->ring.offset = offset + gtt_info.current_memory; |
@@ -662,10 +661,11 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
662 | + (dinfo->cursor.size >> 12); | 661 | + (dinfo->cursor.size >> 12); |
663 | } | 662 | } |
664 | 663 | ||
664 | /* Allocate memories (which aren't stolen) */ | ||
665 | /* Map the fb and MMIO regions */ | 665 | /* Map the fb and MMIO regions */ |
666 | /* ioremap only up to the end of used aperture */ | 666 | /* ioremap only up to the end of used aperture */ |
667 | dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache | 667 | dinfo->aperture.virtual = (u8 __iomem *)ioremap_nocache |
668 | (dinfo->aperture.physical, (dinfo->fb.offset << 12) | 668 | (dinfo->aperture.physical, ((offset + dinfo->fb.offset) << 12) |
669 | + dinfo->fb.size); | 669 | + dinfo->fb.size); |
670 | if (!dinfo->aperture.virtual) { | 670 | if (!dinfo->aperture.virtual) { |
671 | ERR_MSG("Cannot remap FB region.\n"); | 671 | ERR_MSG("Cannot remap FB region.\n"); |
@@ -682,7 +682,6 @@ intelfb_pci_register(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
682 | return -ENODEV; | 682 | return -ENODEV; |
683 | } | 683 | } |
684 | 684 | ||
685 | /* Allocate memories (which aren't stolen) */ | ||
686 | if (dinfo->accel) { | 685 | if (dinfo->accel) { |
687 | if (!(dinfo->gtt_ring_mem = | 686 | if (!(dinfo->gtt_ring_mem = |
688 | agp_allocate_memory(bridge, dinfo->ring.size >> 12, | 687 | agp_allocate_memory(bridge, dinfo->ring.size >> 12, |
@@ -1484,7 +1483,7 @@ intelfb_cursor(struct fb_info *info, struct fb_cursor *cursor) | |||
1484 | #endif | 1483 | #endif |
1485 | 1484 | ||
1486 | if (!dinfo->hwcursor) | 1485 | if (!dinfo->hwcursor) |
1487 | return -ENXIO; | 1486 | return soft_cursor(info, cursor); |
1488 | 1487 | ||
1489 | intelfbhw_cursor_hide(dinfo); | 1488 | intelfbhw_cursor_hide(dinfo); |
1490 | 1489 | ||
diff --git a/drivers/video/s3c2410fb.c b/drivers/video/s3c2410fb.c index 00c0223a352e..5ab79afb53b7 100644 --- a/drivers/video/s3c2410fb.c +++ b/drivers/video/s3c2410fb.c | |||
@@ -228,8 +228,8 @@ static int s3c2410fb_check_var(struct fb_var_screeninfo *var, | |||
228 | * information | 228 | * information |
229 | */ | 229 | */ |
230 | 230 | ||
231 | static int s3c2410fb_activate_var(struct s3c2410fb_info *fbi, | 231 | static void s3c2410fb_activate_var(struct s3c2410fb_info *fbi, |
232 | struct fb_var_screeninfo *var) | 232 | struct fb_var_screeninfo *var) |
233 | { | 233 | { |
234 | fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; | 234 | fbi->regs.lcdcon1 &= ~S3C2410_LCDCON1_MODEMASK; |
235 | 235 | ||
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index 821c9c4d76aa..d95f8626d170 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
@@ -71,21 +71,28 @@ static int v9fs_fid_insert(struct v9fs_fid *fid, struct dentry *dentry) | |||
71 | * | 71 | * |
72 | */ | 72 | */ |
73 | 73 | ||
74 | struct v9fs_fid *v9fs_fid_create(struct dentry *dentry) | 74 | struct v9fs_fid *v9fs_fid_create(struct dentry *dentry, |
75 | struct v9fs_session_info *v9ses, int fid, int create) | ||
75 | { | 76 | { |
76 | struct v9fs_fid *new; | 77 | struct v9fs_fid *new; |
77 | 78 | ||
79 | dprintk(DEBUG_9P, "fid create dentry %p, fid %d, create %d\n", | ||
80 | dentry, fid, create); | ||
81 | |||
78 | new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); | 82 | new = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); |
79 | if (new == NULL) { | 83 | if (new == NULL) { |
80 | dprintk(DEBUG_ERROR, "Out of Memory\n"); | 84 | dprintk(DEBUG_ERROR, "Out of Memory\n"); |
81 | return ERR_PTR(-ENOMEM); | 85 | return ERR_PTR(-ENOMEM); |
82 | } | 86 | } |
83 | 87 | ||
84 | new->fid = -1; | 88 | new->fid = fid; |
89 | new->v9ses = v9ses; | ||
85 | new->fidopen = 0; | 90 | new->fidopen = 0; |
86 | new->fidcreate = 0; | 91 | new->fidcreate = create; |
87 | new->fidclunked = 0; | 92 | new->fidclunked = 0; |
88 | new->iounit = 0; | 93 | new->iounit = 0; |
94 | new->rdir_pos = 0; | ||
95 | new->rdir_fcall = NULL; | ||
89 | 96 | ||
90 | if (v9fs_fid_insert(new, dentry) == 0) | 97 | if (v9fs_fid_insert(new, dentry) == 0) |
91 | return new; | 98 | return new; |
@@ -109,6 +116,59 @@ void v9fs_fid_destroy(struct v9fs_fid *fid) | |||
109 | } | 116 | } |
110 | 117 | ||
111 | /** | 118 | /** |
119 | * v9fs_fid_walk_up - walks from the process current directory | ||
120 | * up to the specified dentry. | ||
121 | */ | ||
122 | static struct v9fs_fid *v9fs_fid_walk_up(struct dentry *dentry) | ||
123 | { | ||
124 | int fidnum, cfidnum, err; | ||
125 | struct v9fs_fid *cfid; | ||
126 | struct dentry *cde; | ||
127 | struct v9fs_session_info *v9ses; | ||
128 | |||
129 | v9ses = v9fs_inode2v9ses(current->fs->pwd->d_inode); | ||
130 | cfid = v9fs_fid_lookup(current->fs->pwd); | ||
131 | if (cfid == NULL) { | ||
132 | dprintk(DEBUG_ERROR, "process cwd doesn't have a fid\n"); | ||
133 | return ERR_PTR(-ENOENT); | ||
134 | } | ||
135 | |||
136 | cfidnum = cfid->fid; | ||
137 | cde = current->fs->pwd; | ||
138 | /* TODO: take advantage of multiwalk */ | ||
139 | |||
140 | fidnum = v9fs_get_idpool(&v9ses->fidpool); | ||
141 | if (fidnum < 0) { | ||
142 | dprintk(DEBUG_ERROR, "could not get a new fid num\n"); | ||
143 | err = -ENOENT; | ||
144 | goto clunk_fid; | ||
145 | } | ||
146 | |||
147 | while (cde != dentry) { | ||
148 | if (cde == cde->d_parent) { | ||
149 | dprintk(DEBUG_ERROR, "can't find dentry\n"); | ||
150 | err = -ENOENT; | ||
151 | goto clunk_fid; | ||
152 | } | ||
153 | |||
154 | err = v9fs_t_walk(v9ses, cfidnum, fidnum, "..", NULL); | ||
155 | if (err < 0) { | ||
156 | dprintk(DEBUG_ERROR, "problem walking to parent\n"); | ||
157 | goto clunk_fid; | ||
158 | } | ||
159 | |||
160 | cfidnum = fidnum; | ||
161 | cde = cde->d_parent; | ||
162 | } | ||
163 | |||
164 | return v9fs_fid_create(dentry, v9ses, fidnum, 0); | ||
165 | |||
166 | clunk_fid: | ||
167 | v9fs_t_clunk(v9ses, fidnum, NULL); | ||
168 | return ERR_PTR(err); | ||
169 | } | ||
170 | |||
171 | /** | ||
112 | * v9fs_fid_lookup - retrieve the right fid from a particular dentry | 172 | * v9fs_fid_lookup - retrieve the right fid from a particular dentry |
113 | * @dentry: dentry to look for fid in | 173 | * @dentry: dentry to look for fid in |
114 | * @type: intent of lookup (operation or traversal) | 174 | * @type: intent of lookup (operation or traversal) |
@@ -119,49 +179,25 @@ void v9fs_fid_destroy(struct v9fs_fid *fid) | |||
119 | * | 179 | * |
120 | */ | 180 | */ |
121 | 181 | ||
122 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) | 182 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry) |
123 | { | 183 | { |
124 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; | 184 | struct list_head *fid_list = (struct list_head *)dentry->d_fsdata; |
125 | struct v9fs_fid *current_fid = NULL; | 185 | struct v9fs_fid *current_fid = NULL; |
126 | struct v9fs_fid *temp = NULL; | 186 | struct v9fs_fid *temp = NULL; |
127 | struct v9fs_fid *return_fid = NULL; | 187 | struct v9fs_fid *return_fid = NULL; |
128 | int found_parent = 0; | ||
129 | int found_user = 0; | ||
130 | 188 | ||
131 | dprintk(DEBUG_9P, " dentry: %s (%p) type %d\n", dentry->d_iname, dentry, | 189 | dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); |
132 | type); | ||
133 | 190 | ||
134 | if (fid_list && !list_empty(fid_list)) { | 191 | if (fid_list) { |
135 | list_for_each_entry_safe(current_fid, temp, fid_list, list) { | 192 | list_for_each_entry_safe(current_fid, temp, fid_list, list) { |
136 | if (current_fid->uid == current->uid) { | 193 | if (!current_fid->fidcreate) { |
137 | if (return_fid == NULL) { | 194 | return_fid = current_fid; |
138 | if ((type == FID_OP) | 195 | break; |
139 | || (!current_fid->fidopen)) { | ||
140 | return_fid = current_fid; | ||
141 | found_user = 1; | ||
142 | } | ||
143 | } | ||
144 | } | ||
145 | if (current_fid->pid == current->real_parent->pid) { | ||
146 | if ((return_fid == NULL) || (found_parent) | ||
147 | || (found_user)) { | ||
148 | if ((type == FID_OP) | ||
149 | || (!current_fid->fidopen)) { | ||
150 | return_fid = current_fid; | ||
151 | found_parent = 1; | ||
152 | found_user = 0; | ||
153 | } | ||
154 | } | ||
155 | } | ||
156 | if (current_fid->pid == current->pid) { | ||
157 | if ((type == FID_OP) || | ||
158 | (!current_fid->fidopen)) { | ||
159 | return_fid = current_fid; | ||
160 | found_parent = 0; | ||
161 | found_user = 0; | ||
162 | } | ||
163 | } | 196 | } |
164 | } | 197 | } |
198 | |||
199 | if (!return_fid) | ||
200 | return_fid = current_fid; | ||
165 | } | 201 | } |
166 | 202 | ||
167 | /* we are at the root but didn't match */ | 203 | /* we are at the root but didn't match */ |
@@ -187,55 +223,33 @@ struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type) | |||
187 | 223 | ||
188 | /* XXX - there may be some duplication we can get rid of */ | 224 | /* XXX - there may be some duplication we can get rid of */ |
189 | if (par == dentry) { | 225 | if (par == dentry) { |
190 | /* we need to fid_lookup the starting point */ | 226 | return_fid = v9fs_fid_walk_up(dentry); |
191 | int fidnum = -1; | 227 | if (IS_ERR(return_fid)) |
192 | int oldfid = -1; | 228 | return_fid = NULL; |
193 | int result = -1; | 229 | } |
194 | struct v9fs_session_info *v9ses = | 230 | } |
195 | v9fs_inode2v9ses(current->fs->pwd->d_inode); | ||
196 | |||
197 | current_fid = | ||
198 | v9fs_fid_lookup(current->fs->pwd, FID_WALK); | ||
199 | if (current_fid == NULL) { | ||
200 | dprintk(DEBUG_ERROR, | ||
201 | "process cwd doesn't have a fid\n"); | ||
202 | return return_fid; | ||
203 | } | ||
204 | oldfid = current_fid->fid; | ||
205 | par = current->fs->pwd; | ||
206 | /* TODO: take advantage of multiwalk */ | ||
207 | 231 | ||
208 | fidnum = v9fs_get_idpool(&v9ses->fidpool); | 232 | return return_fid; |
209 | if (fidnum < 0) { | 233 | } |
210 | dprintk(DEBUG_ERROR, | ||
211 | "could not get a new fid num\n"); | ||
212 | return return_fid; | ||
213 | } | ||
214 | 234 | ||
215 | while (par != dentry) { | 235 | struct v9fs_fid *v9fs_fid_get_created(struct dentry *dentry) |
216 | result = | 236 | { |
217 | v9fs_t_walk(v9ses, oldfid, fidnum, "..", | 237 | struct list_head *fid_list; |
218 | NULL); | 238 | struct v9fs_fid *fid, *ftmp, *ret; |
219 | if (result < 0) { | 239 | |
220 | dprintk(DEBUG_ERROR, | 240 | dprintk(DEBUG_9P, " dentry: %s (%p)\n", dentry->d_iname, dentry); |
221 | "problem walking to parent\n"); | 241 | fid_list = (struct list_head *)dentry->d_fsdata; |
222 | 242 | ret = NULL; | |
223 | break; | 243 | if (fid_list) { |
224 | } | 244 | list_for_each_entry_safe(fid, ftmp, fid_list, list) { |
225 | oldfid = fidnum; | 245 | if (fid->fidcreate && fid->pid == current->pid) { |
226 | if (par == par->d_parent) { | 246 | list_del(&fid->list); |
227 | dprintk(DEBUG_ERROR, | 247 | ret = fid; |
228 | "can't find dentry\n"); | 248 | break; |
229 | break; | ||
230 | } | ||
231 | par = par->d_parent; | ||
232 | } | ||
233 | if (par == dentry) { | ||
234 | return_fid = v9fs_fid_create(dentry); | ||
235 | return_fid->fid = fidnum; | ||
236 | } | 249 | } |
237 | } | 250 | } |
238 | } | 251 | } |
239 | 252 | ||
240 | return return_fid; | 253 | dprintk(DEBUG_9P, "return %p\n", ret); |
254 | return ret; | ||
241 | } | 255 | } |
diff --git a/fs/9p/fid.h b/fs/9p/fid.h index 7db478ccca36..84c673a44c83 100644 --- a/fs/9p/fid.h +++ b/fs/9p/fid.h | |||
@@ -25,6 +25,7 @@ | |||
25 | 25 | ||
26 | #define FID_OP 0 | 26 | #define FID_OP 0 |
27 | #define FID_WALK 1 | 27 | #define FID_WALK 1 |
28 | #define FID_CREATE 2 | ||
28 | 29 | ||
29 | struct v9fs_fid { | 30 | struct v9fs_fid { |
30 | struct list_head list; /* list of fids associated with a dentry */ | 31 | struct list_head list; /* list of fids associated with a dentry */ |
@@ -52,6 +53,8 @@ struct v9fs_fid { | |||
52 | struct v9fs_session_info *v9ses; /* session info for this FID */ | 53 | struct v9fs_session_info *v9ses; /* session info for this FID */ |
53 | }; | 54 | }; |
54 | 55 | ||
55 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry, int type); | 56 | struct v9fs_fid *v9fs_fid_lookup(struct dentry *dentry); |
57 | struct v9fs_fid *v9fs_fid_get_created(struct dentry *); | ||
56 | void v9fs_fid_destroy(struct v9fs_fid *fid); | 58 | void v9fs_fid_destroy(struct v9fs_fid *fid); |
57 | struct v9fs_fid *v9fs_fid_create(struct dentry *); | 59 | struct v9fs_fid *v9fs_fid_create(struct dentry *, |
60 | struct v9fs_session_info *v9ses, int fid, int create); | ||
diff --git a/fs/9p/vfs_dentry.c b/fs/9p/vfs_dentry.c index 306c96741f81..a6aa947de0f9 100644 --- a/fs/9p/vfs_dentry.c +++ b/fs/9p/vfs_dentry.c | |||
@@ -67,7 +67,7 @@ static int v9fs_dentry_validate(struct dentry *dentry, struct nameidata *nd) | |||
67 | struct dentry *dc = current->fs->pwd; | 67 | struct dentry *dc = current->fs->pwd; |
68 | 68 | ||
69 | dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); | 69 | dprintk(DEBUG_VFS, "dentry: %s (%p)\n", dentry->d_iname, dentry); |
70 | if (v9fs_fid_lookup(dentry, FID_OP)) { | 70 | if (v9fs_fid_lookup(dentry)) { |
71 | dprintk(DEBUG_VFS, "VALID\n"); | 71 | dprintk(DEBUG_VFS, "VALID\n"); |
72 | return 1; | 72 | return 1; |
73 | } | 73 | } |
diff --git a/fs/9p/vfs_dir.c b/fs/9p/vfs_dir.c index c478a7384186..57a43b8feef5 100644 --- a/fs/9p/vfs_dir.c +++ b/fs/9p/vfs_dir.c | |||
@@ -197,21 +197,18 @@ int v9fs_dir_release(struct inode *inode, struct file *filp) | |||
197 | filemap_fdatawait(inode->i_mapping); | 197 | filemap_fdatawait(inode->i_mapping); |
198 | 198 | ||
199 | if (fidnum >= 0) { | 199 | if (fidnum >= 0) { |
200 | fid->fidopen--; | ||
201 | dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, | 200 | dprintk(DEBUG_VFS, "fidopen: %d v9f->fid: %d\n", fid->fidopen, |
202 | fid->fid); | 201 | fid->fid); |
203 | 202 | ||
204 | if (fid->fidopen == 0) { | 203 | if (v9fs_t_clunk(v9ses, fidnum, NULL)) |
205 | if (v9fs_t_clunk(v9ses, fidnum, NULL)) | 204 | dprintk(DEBUG_ERROR, "clunk failed\n"); |
206 | dprintk(DEBUG_ERROR, "clunk failed\n"); | ||
207 | 205 | ||
208 | v9fs_put_idpool(fid->fid, &v9ses->fidpool); | 206 | v9fs_put_idpool(fid->fid, &v9ses->fidpool); |
209 | } | ||
210 | 207 | ||
211 | kfree(fid->rdir_fcall); | 208 | kfree(fid->rdir_fcall); |
209 | kfree(fid); | ||
212 | 210 | ||
213 | filp->private_data = NULL; | 211 | filp->private_data = NULL; |
214 | v9fs_fid_destroy(fid); | ||
215 | } | 212 | } |
216 | 213 | ||
217 | d_drop(filp->f_dentry); | 214 | d_drop(filp->f_dentry); |
diff --git a/fs/9p/vfs_file.c b/fs/9p/vfs_file.c index 1f8ae7d580ab..a4799e971d1c 100644 --- a/fs/9p/vfs_file.c +++ b/fs/9p/vfs_file.c | |||
@@ -53,30 +53,36 @@ | |||
53 | int v9fs_file_open(struct inode *inode, struct file *file) | 53 | int v9fs_file_open(struct inode *inode, struct file *file) |
54 | { | 54 | { |
55 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); | 55 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(inode); |
56 | struct v9fs_fid *v9fid = v9fs_fid_lookup(file->f_dentry, FID_WALK); | 56 | struct v9fs_fid *v9fid, *fid; |
57 | struct v9fs_fid *v9newfid = NULL; | ||
58 | struct v9fs_fcall *fcall = NULL; | 57 | struct v9fs_fcall *fcall = NULL; |
59 | int open_mode = 0; | 58 | int open_mode = 0; |
60 | unsigned int iounit = 0; | 59 | unsigned int iounit = 0; |
61 | int newfid = -1; | 60 | int newfid = -1; |
62 | long result = -1; | 61 | long result = -1; |
63 | 62 | ||
64 | dprintk(DEBUG_VFS, "inode: %p file: %p v9fid= %p\n", inode, file, | 63 | dprintk(DEBUG_VFS, "inode: %p file: %p \n", inode, file); |
65 | v9fid); | 64 | |
65 | v9fid = v9fs_fid_get_created(file->f_dentry); | ||
66 | if (!v9fid) | ||
67 | v9fid = v9fs_fid_lookup(file->f_dentry); | ||
66 | 68 | ||
67 | if (!v9fid) { | 69 | if (!v9fid) { |
68 | struct dentry *dentry = file->f_dentry; | ||
69 | dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); | 70 | dprintk(DEBUG_ERROR, "Couldn't resolve fid from dentry\n"); |
71 | return -EBADF; | ||
72 | } | ||
70 | 73 | ||
71 | /* XXX - some duplication from lookup, generalize later */ | 74 | if (!v9fid->fidcreate) { |
72 | /* basically vfs_lookup is too heavy weight */ | 75 | fid = kmalloc(sizeof(struct v9fs_fid), GFP_KERNEL); |
73 | v9fid = v9fs_fid_lookup(file->f_dentry, FID_OP); | 76 | if (fid == NULL) { |
74 | if (!v9fid) | 77 | dprintk(DEBUG_ERROR, "Out of Memory\n"); |
75 | return -EBADF; | 78 | return -ENOMEM; |
79 | } | ||
76 | 80 | ||
77 | v9fid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); | 81 | fid->fidopen = 0; |
78 | if (!v9fid) | 82 | fid->fidcreate = 0; |
79 | return -EBADF; | 83 | fid->fidclunked = 0; |
84 | fid->iounit = 0; | ||
85 | fid->v9ses = v9ses; | ||
80 | 86 | ||
81 | newfid = v9fs_get_idpool(&v9ses->fidpool); | 87 | newfid = v9fs_get_idpool(&v9ses->fidpool); |
82 | if (newfid < 0) { | 88 | if (newfid < 0) { |
@@ -85,58 +91,16 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
85 | } | 91 | } |
86 | 92 | ||
87 | result = | 93 | result = |
88 | v9fs_t_walk(v9ses, v9fid->fid, newfid, | 94 | v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, NULL); |
89 | (char *)file->f_dentry->d_name.name, NULL); | 95 | |
90 | if (result < 0) { | 96 | if (result < 0) { |
91 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 97 | v9fs_put_idpool(newfid, &v9ses->fidpool); |
92 | dprintk(DEBUG_ERROR, "rewalk didn't work\n"); | 98 | dprintk(DEBUG_ERROR, "rewalk didn't work\n"); |
93 | return -EBADF; | 99 | return -EBADF; |
94 | } | 100 | } |
95 | 101 | ||
96 | v9fid = v9fs_fid_create(dentry); | 102 | fid->fid = newfid; |
97 | if (v9fid == NULL) { | 103 | v9fid = fid; |
98 | dprintk(DEBUG_ERROR, "couldn't insert\n"); | ||
99 | return -ENOMEM; | ||
100 | } | ||
101 | v9fid->fid = newfid; | ||
102 | } | ||
103 | |||
104 | if (v9fid->fidcreate) { | ||
105 | /* create case */ | ||
106 | newfid = v9fid->fid; | ||
107 | iounit = v9fid->iounit; | ||
108 | v9fid->fidcreate = 0; | ||
109 | } else { | ||
110 | if (!S_ISDIR(inode->i_mode)) | ||
111 | newfid = v9fid->fid; | ||
112 | else { | ||
113 | newfid = v9fs_get_idpool(&v9ses->fidpool); | ||
114 | if (newfid < 0) { | ||
115 | eprintk(KERN_WARNING, "allocation failed\n"); | ||
116 | return -ENOSPC; | ||
117 | } | ||
118 | /* This would be a somewhat critical clone */ | ||
119 | result = | ||
120 | v9fs_t_walk(v9ses, v9fid->fid, newfid, NULL, | ||
121 | &fcall); | ||
122 | if (result < 0) { | ||
123 | dprintk(DEBUG_ERROR, "clone error: %s\n", | ||
124 | FCALL_ERROR(fcall)); | ||
125 | kfree(fcall); | ||
126 | return result; | ||
127 | } | ||
128 | |||
129 | v9newfid = v9fs_fid_create(file->f_dentry); | ||
130 | v9newfid->fid = newfid; | ||
131 | v9newfid->qid = v9fid->qid; | ||
132 | v9newfid->iounit = v9fid->iounit; | ||
133 | v9newfid->fidopen = 0; | ||
134 | v9newfid->fidclunked = 0; | ||
135 | v9newfid->v9ses = v9ses; | ||
136 | v9fid = v9newfid; | ||
137 | kfree(fcall); | ||
138 | } | ||
139 | |||
140 | /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ | 104 | /* TODO: do special things for O_EXCL, O_NOFOLLOW, O_SYNC */ |
141 | /* translate open mode appropriately */ | 105 | /* translate open mode appropriately */ |
142 | open_mode = file->f_flags & 0x3; | 106 | open_mode = file->f_flags & 0x3; |
@@ -163,9 +127,13 @@ int v9fs_file_open(struct inode *inode, struct file *file) | |||
163 | 127 | ||
164 | iounit = fcall->params.ropen.iounit; | 128 | iounit = fcall->params.ropen.iounit; |
165 | kfree(fcall); | 129 | kfree(fcall); |
130 | } else { | ||
131 | /* create case */ | ||
132 | newfid = v9fid->fid; | ||
133 | iounit = v9fid->iounit; | ||
134 | v9fid->fidcreate = 0; | ||
166 | } | 135 | } |
167 | 136 | ||
168 | |||
169 | file->private_data = v9fid; | 137 | file->private_data = v9fid; |
170 | 138 | ||
171 | v9fid->rdir_pos = 0; | 139 | v9fid->rdir_pos = 0; |
diff --git a/fs/9p/vfs_inode.c b/fs/9p/vfs_inode.c index b16322db5ce6..2b696ae6655a 100644 --- a/fs/9p/vfs_inode.c +++ b/fs/9p/vfs_inode.c | |||
@@ -307,7 +307,7 @@ v9fs_create(struct inode *dir, | |||
307 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); | 307 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); |
308 | struct super_block *sb = dir->i_sb; | 308 | struct super_block *sb = dir->i_sb; |
309 | struct v9fs_fid *dirfid = | 309 | struct v9fs_fid *dirfid = |
310 | v9fs_fid_lookup(file_dentry->d_parent, FID_WALK); | 310 | v9fs_fid_lookup(file_dentry->d_parent); |
311 | struct v9fs_fid *fid = NULL; | 311 | struct v9fs_fid *fid = NULL; |
312 | struct inode *file_inode = NULL; | 312 | struct inode *file_inode = NULL; |
313 | struct v9fs_fcall *fcall = NULL; | 313 | struct v9fs_fcall *fcall = NULL; |
@@ -317,6 +317,7 @@ v9fs_create(struct inode *dir, | |||
317 | long newfid = -1; | 317 | long newfid = -1; |
318 | int result = 0; | 318 | int result = 0; |
319 | unsigned int iounit = 0; | 319 | unsigned int iounit = 0; |
320 | int wfidno = -1; | ||
320 | 321 | ||
321 | perm = unixmode2p9mode(v9ses, perm); | 322 | perm = unixmode2p9mode(v9ses, perm); |
322 | 323 | ||
@@ -350,7 +351,7 @@ v9fs_create(struct inode *dir, | |||
350 | if (result < 0) { | 351 | if (result < 0) { |
351 | dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); | 352 | dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); |
352 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 353 | v9fs_put_idpool(newfid, &v9ses->fidpool); |
353 | newfid = 0; | 354 | newfid = -1; |
354 | goto CleanUpFid; | 355 | goto CleanUpFid; |
355 | } | 356 | } |
356 | 357 | ||
@@ -369,20 +370,39 @@ v9fs_create(struct inode *dir, | |||
369 | qid = fcall->params.rcreate.qid; | 370 | qid = fcall->params.rcreate.qid; |
370 | kfree(fcall); | 371 | kfree(fcall); |
371 | 372 | ||
372 | fid = v9fs_fid_create(file_dentry); | 373 | fid = v9fs_fid_create(file_dentry, v9ses, newfid, 1); |
374 | dprintk(DEBUG_VFS, "fid %p %d\n", fid, fid->fidcreate); | ||
373 | if (!fid) { | 375 | if (!fid) { |
374 | result = -ENOMEM; | 376 | result = -ENOMEM; |
375 | goto CleanUpFid; | 377 | goto CleanUpFid; |
376 | } | 378 | } |
377 | 379 | ||
378 | fid->fid = newfid; | ||
379 | fid->fidopen = 0; | ||
380 | fid->fidcreate = 1; | ||
381 | fid->qid = qid; | 380 | fid->qid = qid; |
382 | fid->iounit = iounit; | 381 | fid->iounit = iounit; |
383 | fid->rdir_pos = 0; | 382 | |
384 | fid->rdir_fcall = NULL; | 383 | /* walk to the newly created file and put the fid in the dentry */ |
385 | fid->v9ses = v9ses; | 384 | wfidno = v9fs_get_idpool(&v9ses->fidpool); |
385 | if (newfid < 0) { | ||
386 | eprintk(KERN_WARNING, "no free fids available\n"); | ||
387 | return -ENOSPC; | ||
388 | } | ||
389 | |||
390 | result = v9fs_t_walk(v9ses, dirfidnum, wfidno, | ||
391 | (char *) file_dentry->d_name.name, NULL); | ||
392 | if (result < 0) { | ||
393 | dprintk(DEBUG_ERROR, "clone error: %s\n", FCALL_ERROR(fcall)); | ||
394 | v9fs_put_idpool(wfidno, &v9ses->fidpool); | ||
395 | wfidno = -1; | ||
396 | goto CleanUpFid; | ||
397 | } | ||
398 | |||
399 | if (!v9fs_fid_create(file_dentry, v9ses, wfidno, 0)) { | ||
400 | if (!v9fs_t_clunk(v9ses, newfid, &fcall)) { | ||
401 | v9fs_put_idpool(wfidno, &v9ses->fidpool); | ||
402 | } | ||
403 | |||
404 | goto CleanUpFid; | ||
405 | } | ||
386 | 406 | ||
387 | if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || | 407 | if ((perm & V9FS_DMSYMLINK) || (perm & V9FS_DMLINK) || |
388 | (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || | 408 | (perm & V9FS_DMNAMEDPIPE) || (perm & V9FS_DMSOCKET) || |
@@ -410,11 +430,11 @@ v9fs_create(struct inode *dir, | |||
410 | d_instantiate(file_dentry, file_inode); | 430 | d_instantiate(file_dentry, file_inode); |
411 | 431 | ||
412 | if (perm & V9FS_DMDIR) { | 432 | if (perm & V9FS_DMDIR) { |
413 | if (v9fs_t_clunk(v9ses, newfid, &fcall)) | 433 | if (!v9fs_t_clunk(v9ses, newfid, &fcall)) |
434 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
435 | else | ||
414 | dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", | 436 | dprintk(DEBUG_ERROR, "clunk for mkdir failed: %s\n", |
415 | FCALL_ERROR(fcall)); | 437 | FCALL_ERROR(fcall)); |
416 | |||
417 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
418 | kfree(fcall); | 438 | kfree(fcall); |
419 | fid->fidopen = 0; | 439 | fid->fidopen = 0; |
420 | fid->fidcreate = 0; | 440 | fid->fidcreate = 0; |
@@ -426,12 +446,22 @@ v9fs_create(struct inode *dir, | |||
426 | CleanUpFid: | 446 | CleanUpFid: |
427 | kfree(fcall); | 447 | kfree(fcall); |
428 | 448 | ||
429 | if (newfid) { | 449 | if (newfid >= 0) { |
430 | if (v9fs_t_clunk(v9ses, newfid, &fcall)) | 450 | if (!v9fs_t_clunk(v9ses, newfid, &fcall)) |
451 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
452 | else | ||
453 | dprintk(DEBUG_ERROR, "clunk failed: %s\n", | ||
454 | FCALL_ERROR(fcall)); | ||
455 | |||
456 | kfree(fcall); | ||
457 | } | ||
458 | if (wfidno >= 0) { | ||
459 | if (!v9fs_t_clunk(v9ses, wfidno, &fcall)) | ||
460 | v9fs_put_idpool(wfidno, &v9ses->fidpool); | ||
461 | else | ||
431 | dprintk(DEBUG_ERROR, "clunk failed: %s\n", | 462 | dprintk(DEBUG_ERROR, "clunk failed: %s\n", |
432 | FCALL_ERROR(fcall)); | 463 | FCALL_ERROR(fcall)); |
433 | 464 | ||
434 | v9fs_put_idpool(newfid, &v9ses->fidpool); | ||
435 | kfree(fcall); | 465 | kfree(fcall); |
436 | } | 466 | } |
437 | return result; | 467 | return result; |
@@ -461,7 +491,7 @@ static int v9fs_remove(struct inode *dir, struct dentry *file, int rmdir) | |||
461 | file_inode = file->d_inode; | 491 | file_inode = file->d_inode; |
462 | sb = file_inode->i_sb; | 492 | sb = file_inode->i_sb; |
463 | v9ses = v9fs_inode2v9ses(file_inode); | 493 | v9ses = v9fs_inode2v9ses(file_inode); |
464 | v9fid = v9fs_fid_lookup(file, FID_OP); | 494 | v9fid = v9fs_fid_lookup(file); |
465 | 495 | ||
466 | if (!v9fid) { | 496 | if (!v9fid) { |
467 | dprintk(DEBUG_ERROR, | 497 | dprintk(DEBUG_ERROR, |
@@ -545,7 +575,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
545 | 575 | ||
546 | sb = dir->i_sb; | 576 | sb = dir->i_sb; |
547 | v9ses = v9fs_inode2v9ses(dir); | 577 | v9ses = v9fs_inode2v9ses(dir); |
548 | dirfid = v9fs_fid_lookup(dentry->d_parent, FID_WALK); | 578 | dirfid = v9fs_fid_lookup(dentry->d_parent); |
549 | 579 | ||
550 | if (!dirfid) { | 580 | if (!dirfid) { |
551 | dprintk(DEBUG_ERROR, "no dirfid\n"); | 581 | dprintk(DEBUG_ERROR, "no dirfid\n"); |
@@ -573,7 +603,7 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
573 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 603 | v9fs_put_idpool(newfid, &v9ses->fidpool); |
574 | if (result == -ENOENT) { | 604 | if (result == -ENOENT) { |
575 | d_add(dentry, NULL); | 605 | d_add(dentry, NULL); |
576 | dprintk(DEBUG_ERROR, | 606 | dprintk(DEBUG_VFS, |
577 | "Return negative dentry %p count %d\n", | 607 | "Return negative dentry %p count %d\n", |
578 | dentry, atomic_read(&dentry->d_count)); | 608 | dentry, atomic_read(&dentry->d_count)); |
579 | return NULL; | 609 | return NULL; |
@@ -601,16 +631,13 @@ static struct dentry *v9fs_vfs_lookup(struct inode *dir, struct dentry *dentry, | |||
601 | 631 | ||
602 | inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); | 632 | inode->i_ino = v9fs_qid2ino(&fcall->params.rstat.stat->qid); |
603 | 633 | ||
604 | fid = v9fs_fid_create(dentry); | 634 | fid = v9fs_fid_create(dentry, v9ses, newfid, 0); |
605 | if (fid == NULL) { | 635 | if (fid == NULL) { |
606 | dprintk(DEBUG_ERROR, "couldn't insert\n"); | 636 | dprintk(DEBUG_ERROR, "couldn't insert\n"); |
607 | result = -ENOMEM; | 637 | result = -ENOMEM; |
608 | goto FreeFcall; | 638 | goto FreeFcall; |
609 | } | 639 | } |
610 | 640 | ||
611 | fid->fid = newfid; | ||
612 | fid->fidopen = 0; | ||
613 | fid->v9ses = v9ses; | ||
614 | fid->qid = fcall->params.rstat.stat->qid; | 641 | fid->qid = fcall->params.rstat.stat->qid; |
615 | 642 | ||
616 | dentry->d_op = &v9fs_dentry_operations; | 643 | dentry->d_op = &v9fs_dentry_operations; |
@@ -665,11 +692,11 @@ v9fs_vfs_rename(struct inode *old_dir, struct dentry *old_dentry, | |||
665 | { | 692 | { |
666 | struct inode *old_inode = old_dentry->d_inode; | 693 | struct inode *old_inode = old_dentry->d_inode; |
667 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); | 694 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(old_inode); |
668 | struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_WALK); | 695 | struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry); |
669 | struct v9fs_fid *olddirfid = | 696 | struct v9fs_fid *olddirfid = |
670 | v9fs_fid_lookup(old_dentry->d_parent, FID_WALK); | 697 | v9fs_fid_lookup(old_dentry->d_parent); |
671 | struct v9fs_fid *newdirfid = | 698 | struct v9fs_fid *newdirfid = |
672 | v9fs_fid_lookup(new_dentry->d_parent, FID_WALK); | 699 | v9fs_fid_lookup(new_dentry->d_parent); |
673 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); | 700 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); |
674 | struct v9fs_fcall *fcall = NULL; | 701 | struct v9fs_fcall *fcall = NULL; |
675 | int fid = -1; | 702 | int fid = -1; |
@@ -744,7 +771,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
744 | { | 771 | { |
745 | struct v9fs_fcall *fcall = NULL; | 772 | struct v9fs_fcall *fcall = NULL; |
746 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); | 773 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); |
747 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); | 774 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry); |
748 | int err = -EPERM; | 775 | int err = -EPERM; |
749 | 776 | ||
750 | dprintk(DEBUG_VFS, "dentry: %p\n", dentry); | 777 | dprintk(DEBUG_VFS, "dentry: %p\n", dentry); |
@@ -778,7 +805,7 @@ v9fs_vfs_getattr(struct vfsmount *mnt, struct dentry *dentry, | |||
778 | static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) | 805 | static int v9fs_vfs_setattr(struct dentry *dentry, struct iattr *iattr) |
779 | { | 806 | { |
780 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); | 807 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); |
781 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); | 808 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry); |
782 | struct v9fs_fcall *fcall = NULL; | 809 | struct v9fs_fcall *fcall = NULL; |
783 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); | 810 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); |
784 | int res = -EPERM; | 811 | int res = -EPERM; |
@@ -960,7 +987,7 @@ v9fs_vfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) | |||
960 | if (retval != 0) | 987 | if (retval != 0) |
961 | goto FreeFcall; | 988 | goto FreeFcall; |
962 | 989 | ||
963 | newfid = v9fs_fid_lookup(dentry, FID_OP); | 990 | newfid = v9fs_fid_lookup(dentry); |
964 | 991 | ||
965 | /* issue a twstat */ | 992 | /* issue a twstat */ |
966 | v9fs_blank_mistat(v9ses, mistat); | 993 | v9fs_blank_mistat(v9ses, mistat); |
@@ -1004,7 +1031,7 @@ static int v9fs_readlink(struct dentry *dentry, char *buffer, int buflen) | |||
1004 | 1031 | ||
1005 | struct v9fs_fcall *fcall = NULL; | 1032 | struct v9fs_fcall *fcall = NULL; |
1006 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); | 1033 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dentry->d_inode); |
1007 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry, FID_OP); | 1034 | struct v9fs_fid *fid = v9fs_fid_lookup(dentry); |
1008 | 1035 | ||
1009 | if (!fid) { | 1036 | if (!fid) { |
1010 | dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); | 1037 | dprintk(DEBUG_ERROR, "could not resolve fid from dentry\n"); |
@@ -1148,7 +1175,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, | |||
1148 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); | 1175 | struct v9fs_session_info *v9ses = v9fs_inode2v9ses(dir); |
1149 | struct v9fs_fcall *fcall = NULL; | 1176 | struct v9fs_fcall *fcall = NULL; |
1150 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); | 1177 | struct v9fs_stat *mistat = kmalloc(v9ses->maxdata, GFP_KERNEL); |
1151 | struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry, FID_OP); | 1178 | struct v9fs_fid *oldfid = v9fs_fid_lookup(old_dentry); |
1152 | struct v9fs_fid *newfid = NULL; | 1179 | struct v9fs_fid *newfid = NULL; |
1153 | char *symname = __getname(); | 1180 | char *symname = __getname(); |
1154 | 1181 | ||
@@ -1168,7 +1195,7 @@ v9fs_vfs_link(struct dentry *old_dentry, struct inode *dir, | |||
1168 | if (retval != 0) | 1195 | if (retval != 0) |
1169 | goto FreeMem; | 1196 | goto FreeMem; |
1170 | 1197 | ||
1171 | newfid = v9fs_fid_lookup(dentry, FID_OP); | 1198 | newfid = v9fs_fid_lookup(dentry); |
1172 | if (!newfid) { | 1199 | if (!newfid) { |
1173 | dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); | 1200 | dprintk(DEBUG_ERROR, "couldn't resolve fid from dentry\n"); |
1174 | goto FreeMem; | 1201 | goto FreeMem; |
@@ -1246,7 +1273,7 @@ v9fs_vfs_mknod(struct inode *dir, struct dentry *dentry, int mode, dev_t rdev) | |||
1246 | if (retval != 0) | 1273 | if (retval != 0) |
1247 | goto FreeMem; | 1274 | goto FreeMem; |
1248 | 1275 | ||
1249 | newfid = v9fs_fid_lookup(dentry, FID_OP); | 1276 | newfid = v9fs_fid_lookup(dentry); |
1250 | if (!newfid) { | 1277 | if (!newfid) { |
1251 | dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); | 1278 | dprintk(DEBUG_ERROR, "coudn't resove fid from dentry\n"); |
1252 | retval = -EINVAL; | 1279 | retval = -EINVAL; |
diff --git a/fs/9p/vfs_super.c b/fs/9p/vfs_super.c index 1e2b2b54d300..0957f4da91d4 100644 --- a/fs/9p/vfs_super.c +++ b/fs/9p/vfs_super.c | |||
@@ -129,8 +129,7 @@ static struct super_block *v9fs_get_sb(struct file_system_type | |||
129 | 129 | ||
130 | if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { | 130 | if ((newfid = v9fs_session_init(v9ses, dev_name, data)) < 0) { |
131 | dprintk(DEBUG_ERROR, "problem initiating session\n"); | 131 | dprintk(DEBUG_ERROR, "problem initiating session\n"); |
132 | kfree(v9ses); | 132 | return newfid; |
133 | return ERR_PTR(newfid); | ||
134 | } | 133 | } |
135 | 134 | ||
136 | sb = sget(fs_type, NULL, v9fs_set_super, v9ses); | 135 | sb = sget(fs_type, NULL, v9fs_set_super, v9ses); |
@@ -155,23 +154,19 @@ static struct super_block *v9fs_get_sb(struct file_system_type | |||
155 | 154 | ||
156 | sb->s_root = root; | 155 | sb->s_root = root; |
157 | 156 | ||
158 | /* Setup the Root Inode */ | ||
159 | root_fid = v9fs_fid_create(root); | ||
160 | if (root_fid == NULL) { | ||
161 | retval = -ENOMEM; | ||
162 | goto put_back_sb; | ||
163 | } | ||
164 | |||
165 | root_fid->fidopen = 0; | ||
166 | root_fid->v9ses = v9ses; | ||
167 | |||
168 | stat_result = v9fs_t_stat(v9ses, newfid, &fcall); | 157 | stat_result = v9fs_t_stat(v9ses, newfid, &fcall); |
169 | if (stat_result < 0) { | 158 | if (stat_result < 0) { |
170 | dprintk(DEBUG_ERROR, "stat error\n"); | 159 | dprintk(DEBUG_ERROR, "stat error\n"); |
171 | v9fs_t_clunk(v9ses, newfid, NULL); | 160 | v9fs_t_clunk(v9ses, newfid, NULL); |
172 | v9fs_put_idpool(newfid, &v9ses->fidpool); | 161 | v9fs_put_idpool(newfid, &v9ses->fidpool); |
173 | } else { | 162 | } else { |
174 | root_fid->fid = newfid; | 163 | /* Setup the Root Inode */ |
164 | root_fid = v9fs_fid_create(root, v9ses, newfid, 0); | ||
165 | if (root_fid == NULL) { | ||
166 | retval = -ENOMEM; | ||
167 | goto put_back_sb; | ||
168 | } | ||
169 | |||
175 | root_fid->qid = fcall->params.rstat.stat->qid; | 170 | root_fid->qid = fcall->params.rstat.stat->qid; |
176 | root->d_inode->i_ino = | 171 | root->d_inode->i_ino = |
177 | v9fs_qid2ino(&fcall->params.rstat.stat->qid); | 172 | v9fs_qid2ino(&fcall->params.rstat.stat->qid); |
diff --git a/fs/Kconfig b/fs/Kconfig index 068ccea2f184..48f5422cb19a 100644 --- a/fs/Kconfig +++ b/fs/Kconfig | |||
@@ -472,6 +472,9 @@ config FUSE_FS | |||
472 | utilities is available from the FUSE homepage: | 472 | utilities is available from the FUSE homepage: |
473 | <http://fuse.sourceforge.net/> | 473 | <http://fuse.sourceforge.net/> |
474 | 474 | ||
475 | See <file:Documentation/filesystems/fuse.txt> for more information. | ||
476 | See <file:Documentation/Changes> for needed library/utility version. | ||
477 | |||
475 | If you want to develop a userspace FS, or if you want to use | 478 | If you want to develop a userspace FS, or if you want to use |
476 | a filesystem based on FUSE, answer Y or M. | 479 | a filesystem based on FUSE, answer Y or M. |
477 | 480 | ||
diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 403b90a1213d..4284cd31eba6 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c | |||
@@ -101,6 +101,10 @@ | |||
101 | /* Maximum number of poll wake up nests we are allowing */ | 101 | /* Maximum number of poll wake up nests we are allowing */ |
102 | #define EP_MAX_POLLWAKE_NESTS 4 | 102 | #define EP_MAX_POLLWAKE_NESTS 4 |
103 | 103 | ||
104 | /* Maximum msec timeout value storeable in a long int */ | ||
105 | #define EP_MAX_MSTIMEO min(1000ULL * MAX_SCHEDULE_TIMEOUT / HZ, (LONG_MAX - 999ULL) / HZ) | ||
106 | |||
107 | |||
104 | struct epoll_filefd { | 108 | struct epoll_filefd { |
105 | struct file *file; | 109 | struct file *file; |
106 | int fd; | 110 | int fd; |
@@ -1506,8 +1510,8 @@ static int ep_poll(struct eventpoll *ep, struct epoll_event __user *events, | |||
1506 | * and the overflow condition. The passed timeout is in milliseconds, | 1510 | * and the overflow condition. The passed timeout is in milliseconds, |
1507 | * that why (t * HZ) / 1000. | 1511 | * that why (t * HZ) / 1000. |
1508 | */ | 1512 | */ |
1509 | jtimeout = timeout == -1 || timeout > (MAX_SCHEDULE_TIMEOUT - 1000) / HZ ? | 1513 | jtimeout = (timeout < 0 || timeout >= EP_MAX_MSTIMEO) ? |
1510 | MAX_SCHEDULE_TIMEOUT: (timeout * HZ + 999) / 1000; | 1514 | MAX_SCHEDULE_TIMEOUT : (timeout * HZ + 999) / 1000; |
1511 | 1515 | ||
1512 | retry: | 1516 | retry: |
1513 | write_lock_irqsave(&ep->lock, flags); | 1517 | write_lock_irqsave(&ep->lock, flags); |
diff --git a/fs/ext2/ialloc.c b/fs/ext2/ialloc.c index c8d07030c897..e2d6208633a7 100644 --- a/fs/ext2/ialloc.c +++ b/fs/ext2/ialloc.c | |||
@@ -605,27 +605,28 @@ got: | |||
605 | insert_inode_hash(inode); | 605 | insert_inode_hash(inode); |
606 | 606 | ||
607 | if (DQUOT_ALLOC_INODE(inode)) { | 607 | if (DQUOT_ALLOC_INODE(inode)) { |
608 | DQUOT_DROP(inode); | ||
609 | err = -ENOSPC; | 608 | err = -ENOSPC; |
610 | goto fail2; | 609 | goto fail_drop; |
611 | } | 610 | } |
611 | |||
612 | err = ext2_init_acl(inode, dir); | 612 | err = ext2_init_acl(inode, dir); |
613 | if (err) { | 613 | if (err) |
614 | DQUOT_FREE_INODE(inode); | 614 | goto fail_free_drop; |
615 | DQUOT_DROP(inode); | 615 | |
616 | goto fail2; | ||
617 | } | ||
618 | err = ext2_init_security(inode,dir); | 616 | err = ext2_init_security(inode,dir); |
619 | if (err) { | 617 | if (err) |
620 | DQUOT_FREE_INODE(inode); | 618 | goto fail_free_drop; |
621 | goto fail2; | 619 | |
622 | } | ||
623 | mark_inode_dirty(inode); | 620 | mark_inode_dirty(inode); |
624 | ext2_debug("allocating inode %lu\n", inode->i_ino); | 621 | ext2_debug("allocating inode %lu\n", inode->i_ino); |
625 | ext2_preread_inode(inode); | 622 | ext2_preread_inode(inode); |
626 | return inode; | 623 | return inode; |
627 | 624 | ||
628 | fail2: | 625 | fail_free_drop: |
626 | DQUOT_FREE_INODE(inode); | ||
627 | |||
628 | fail_drop: | ||
629 | DQUOT_DROP(inode); | ||
629 | inode->i_flags |= S_NOQUOTA; | 630 | inode->i_flags |= S_NOQUOTA; |
630 | inode->i_nlink = 0; | 631 | inode->i_nlink = 0; |
631 | iput(inode); | 632 | iput(inode); |
diff --git a/fs/ext3/ialloc.c b/fs/ext3/ialloc.c index 96552769d039..6549945f9ac1 100644 --- a/fs/ext3/ialloc.c +++ b/fs/ext3/ialloc.c | |||
@@ -597,27 +597,22 @@ got: | |||
597 | 597 | ||
598 | ret = inode; | 598 | ret = inode; |
599 | if(DQUOT_ALLOC_INODE(inode)) { | 599 | if(DQUOT_ALLOC_INODE(inode)) { |
600 | DQUOT_DROP(inode); | ||
601 | err = -EDQUOT; | 600 | err = -EDQUOT; |
602 | goto fail2; | 601 | goto fail_drop; |
603 | } | 602 | } |
603 | |||
604 | err = ext3_init_acl(handle, inode, dir); | 604 | err = ext3_init_acl(handle, inode, dir); |
605 | if (err) { | 605 | if (err) |
606 | DQUOT_FREE_INODE(inode); | 606 | goto fail_free_drop; |
607 | DQUOT_DROP(inode); | 607 | |
608 | goto fail2; | ||
609 | } | ||
610 | err = ext3_init_security(handle,inode, dir); | 608 | err = ext3_init_security(handle,inode, dir); |
611 | if (err) { | 609 | if (err) |
612 | DQUOT_FREE_INODE(inode); | 610 | goto fail_free_drop; |
613 | goto fail2; | 611 | |
614 | } | ||
615 | err = ext3_mark_inode_dirty(handle, inode); | 612 | err = ext3_mark_inode_dirty(handle, inode); |
616 | if (err) { | 613 | if (err) { |
617 | ext3_std_error(sb, err); | 614 | ext3_std_error(sb, err); |
618 | DQUOT_FREE_INODE(inode); | 615 | goto fail_free_drop; |
619 | DQUOT_DROP(inode); | ||
620 | goto fail2; | ||
621 | } | 616 | } |
622 | 617 | ||
623 | ext3_debug("allocating inode %lu\n", inode->i_ino); | 618 | ext3_debug("allocating inode %lu\n", inode->i_ino); |
@@ -631,7 +626,11 @@ really_out: | |||
631 | brelse(bitmap_bh); | 626 | brelse(bitmap_bh); |
632 | return ret; | 627 | return ret; |
633 | 628 | ||
634 | fail2: | 629 | fail_free_drop: |
630 | DQUOT_FREE_INODE(inode); | ||
631 | |||
632 | fail_drop: | ||
633 | DQUOT_DROP(inode); | ||
635 | inode->i_flags |= S_NOQUOTA; | 634 | inode->i_flags |= S_NOQUOTA; |
636 | inode->i_nlink = 0; | 635 | inode->i_nlink = 0; |
637 | iput(inode); | 636 | iput(inode); |
diff --git a/fs/fuse/dir.c b/fs/fuse/dir.c index e79e49b3eec7..29f1e9f6e85c 100644 --- a/fs/fuse/dir.c +++ b/fs/fuse/dir.c | |||
@@ -96,6 +96,8 @@ static int fuse_lookup_iget(struct inode *dir, struct dentry *entry, | |||
96 | fuse_lookup_init(req, dir, entry, &outarg); | 96 | fuse_lookup_init(req, dir, entry, &outarg); |
97 | request_send(fc, req); | 97 | request_send(fc, req); |
98 | err = req->out.h.error; | 98 | err = req->out.h.error; |
99 | if (!err && (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID)) | ||
100 | err = -EIO; | ||
99 | if (!err) { | 101 | if (!err) { |
100 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, | 102 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, |
101 | &outarg.attr); | 103 | &outarg.attr); |
@@ -152,6 +154,10 @@ static int create_new_entry(struct fuse_conn *fc, struct fuse_req *req, | |||
152 | fuse_put_request(fc, req); | 154 | fuse_put_request(fc, req); |
153 | return err; | 155 | return err; |
154 | } | 156 | } |
157 | if (!outarg.nodeid || outarg.nodeid == FUSE_ROOT_ID) { | ||
158 | fuse_put_request(fc, req); | ||
159 | return -EIO; | ||
160 | } | ||
155 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, | 161 | inode = fuse_iget(dir->i_sb, outarg.nodeid, outarg.generation, |
156 | &outarg.attr); | 162 | &outarg.attr); |
157 | if (!inode) { | 163 | if (!inode) { |
diff --git a/include/asm-arm/arch-rpc/hardware.h b/include/asm-arm/arch-rpc/hardware.h index be9754a05c19..9d7f87375aa7 100644 --- a/include/asm-arm/arch-rpc/hardware.h +++ b/include/asm-arm/arch-rpc/hardware.h | |||
@@ -15,7 +15,7 @@ | |||
15 | #include <asm/arch/memory.h> | 15 | #include <asm/arch/memory.h> |
16 | 16 | ||
17 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
18 | #define IOMEM(x) ((void __iomem *)(x)) | 18 | #define IOMEM(x) ((void __iomem *)(unsigned long)(x)) |
19 | #else | 19 | #else |
20 | #define IOMEM(x) x | 20 | #define IOMEM(x) x |
21 | #endif /* __ASSEMBLY__ */ | 21 | #endif /* __ASSEMBLY__ */ |
@@ -52,7 +52,7 @@ | |||
52 | /* | 52 | /* |
53 | * IO Addresses | 53 | * IO Addresses |
54 | */ | 54 | */ |
55 | #define VIDC_BASE (void __iomem *)0xe0400000 | 55 | #define VIDC_BASE IOMEM(0xe0400000) |
56 | #define EXPMASK_BASE 0xe0360000 | 56 | #define EXPMASK_BASE 0xe0360000 |
57 | #define IOMD_BASE IOMEM(0xe0200000) | 57 | #define IOMD_BASE IOMEM(0xe0200000) |
58 | #define IOC_BASE IOMEM(0xe0200000) | 58 | #define IOC_BASE IOMEM(0xe0200000) |
diff --git a/include/asm-arm/arch-versatile/io.h b/include/asm-arm/arch-versatile/io.h index 9f895bf61494..47e904cf25c7 100644 --- a/include/asm-arm/arch-versatile/io.h +++ b/include/asm-arm/arch-versatile/io.h | |||
@@ -22,7 +22,11 @@ | |||
22 | 22 | ||
23 | #define IO_SPACE_LIMIT 0xffffffff | 23 | #define IO_SPACE_LIMIT 0xffffffff |
24 | 24 | ||
25 | #define __io(a) ((void __iomem *)(a)) | 25 | static inline void __iomem *__io(unsigned long addr) |
26 | { | ||
27 | return (void __iomem *)addr; | ||
28 | } | ||
29 | #define __io(a) __io(a) | ||
26 | #define __mem_pci(a) (a) | 30 | #define __mem_pci(a) (a) |
27 | #define __mem_isa(a) (a) | 31 | #define __mem_isa(a) (a) |
28 | 32 | ||
diff --git a/include/asm-generic/pgtable.h b/include/asm-generic/pgtable.h index f86c1e549466..ff28c8b31f58 100644 --- a/include/asm-generic/pgtable.h +++ b/include/asm-generic/pgtable.h | |||
@@ -158,6 +158,19 @@ static inline void ptep_set_wrprotect(struct mm_struct *mm, unsigned long addres | |||
158 | #define lazy_mmu_prot_update(pte) do { } while (0) | 158 | #define lazy_mmu_prot_update(pte) do { } while (0) |
159 | #endif | 159 | #endif |
160 | 160 | ||
161 | #ifndef __HAVE_ARCH_MULTIPLE_ZERO_PAGE | ||
162 | #define move_pte(pte, prot, old_addr, new_addr) (pte) | ||
163 | #else | ||
164 | #define move_pte(pte, prot, old_addr, new_addr) \ | ||
165 | ({ \ | ||
166 | pte_t newpte = (pte); \ | ||
167 | if (pte_present(pte) && pfn_valid(pte_pfn(pte)) && \ | ||
168 | pte_page(pte) == ZERO_PAGE(old_addr)) \ | ||
169 | newpte = mk_pte(ZERO_PAGE(new_addr), (prot)); \ | ||
170 | newpte; \ | ||
171 | }) | ||
172 | #endif | ||
173 | |||
161 | /* | 174 | /* |
162 | * When walking page tables, get the address of the next boundary, | 175 | * When walking page tables, get the address of the next boundary, |
163 | * or the end address of the range if that comes earlier. Although no | 176 | * or the end address of the range if that comes earlier. Although no |
diff --git a/include/asm-ia64/uaccess.h b/include/asm-ia64/uaccess.h index 3a7829bb5954..9adb51211c22 100644 --- a/include/asm-ia64/uaccess.h +++ b/include/asm-ia64/uaccess.h | |||
@@ -187,8 +187,8 @@ extern void __get_user_unknown (void); | |||
187 | ({ \ | 187 | ({ \ |
188 | const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ | 188 | const __typeof__(*(ptr)) __user *__gu_ptr = (ptr); \ |
189 | __typeof__ (size) __gu_size = (size); \ | 189 | __typeof__ (size) __gu_size = (size); \ |
190 | long __gu_err = -EFAULT, __gu_val = 0; \ | 190 | long __gu_err = -EFAULT; \ |
191 | \ | 191 | unsigned long __gu_val = 0; \ |
192 | if (!check || __access_ok(__gu_ptr, size, segment)) \ | 192 | if (!check || __access_ok(__gu_ptr, size, segment)) \ |
193 | switch (__gu_size) { \ | 193 | switch (__gu_size) { \ |
194 | case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ | 194 | case 1: __get_user_size(__gu_val, __gu_ptr, 1, __gu_err); break; \ |
@@ -240,13 +240,13 @@ extern unsigned long __must_check __copy_user (void __user *to, const void __use | |||
240 | static inline unsigned long | 240 | static inline unsigned long |
241 | __copy_to_user (void __user *to, const void *from, unsigned long count) | 241 | __copy_to_user (void __user *to, const void *from, unsigned long count) |
242 | { | 242 | { |
243 | return __copy_user(to, (void __user *) from, count); | 243 | return __copy_user(to, (__force void __user *) from, count); |
244 | } | 244 | } |
245 | 245 | ||
246 | static inline unsigned long | 246 | static inline unsigned long |
247 | __copy_from_user (void *to, const void __user *from, unsigned long count) | 247 | __copy_from_user (void *to, const void __user *from, unsigned long count) |
248 | { | 248 | { |
249 | return __copy_user((void __user *) to, from, count); | 249 | return __copy_user((__force void __user *) to, from, count); |
250 | } | 250 | } |
251 | 251 | ||
252 | #define __copy_to_user_inatomic __copy_to_user | 252 | #define __copy_to_user_inatomic __copy_to_user |
@@ -258,7 +258,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) | |||
258 | long __cu_len = (n); \ | 258 | long __cu_len = (n); \ |
259 | \ | 259 | \ |
260 | if (__access_ok(__cu_to, __cu_len, get_fs())) \ | 260 | if (__access_ok(__cu_to, __cu_len, get_fs())) \ |
261 | __cu_len = __copy_user(__cu_to, (void __user *) __cu_from, __cu_len); \ | 261 | __cu_len = __copy_user(__cu_to, (__force void __user *) __cu_from, __cu_len); \ |
262 | __cu_len; \ | 262 | __cu_len; \ |
263 | }) | 263 | }) |
264 | 264 | ||
@@ -270,7 +270,7 @@ __copy_from_user (void *to, const void __user *from, unsigned long count) | |||
270 | \ | 270 | \ |
271 | __chk_user_ptr(__cu_from); \ | 271 | __chk_user_ptr(__cu_from); \ |
272 | if (__access_ok(__cu_from, __cu_len, get_fs())) \ | 272 | if (__access_ok(__cu_from, __cu_len, get_fs())) \ |
273 | __cu_len = __copy_user((void __user *) __cu_to, __cu_from, __cu_len); \ | 273 | __cu_len = __copy_user((__force void __user *) __cu_to, __cu_from, __cu_len); \ |
274 | __cu_len; \ | 274 | __cu_len; \ |
275 | }) | 275 | }) |
276 | 276 | ||
diff --git a/include/asm-mips/pgtable.h b/include/asm-mips/pgtable.h index cbd1672c94cb..eaf5d9b3a0e1 100644 --- a/include/asm-mips/pgtable.h +++ b/include/asm-mips/pgtable.h | |||
@@ -68,6 +68,8 @@ extern unsigned long zero_page_mask; | |||
68 | #define ZERO_PAGE(vaddr) \ | 68 | #define ZERO_PAGE(vaddr) \ |
69 | (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) | 69 | (virt_to_page(empty_zero_page + (((unsigned long)(vaddr)) & zero_page_mask))) |
70 | 70 | ||
71 | #define __HAVE_ARCH_MULTIPLE_ZERO_PAGE | ||
72 | |||
71 | extern void paging_init(void); | 73 | extern void paging_init(void); |
72 | 74 | ||
73 | /* | 75 | /* |
diff --git a/include/asm-ppc/mv64x60.h b/include/asm-ppc/mv64x60.h index 75c2ffa26b26..ee2f9188cc64 100644 --- a/include/asm-ppc/mv64x60.h +++ b/include/asm-ppc/mv64x60.h | |||
@@ -233,7 +233,7 @@ struct mv64x60_chip_info { | |||
233 | struct mv64x60_handle { | 233 | struct mv64x60_handle { |
234 | u32 type; /* type of bridge */ | 234 | u32 type; /* type of bridge */ |
235 | u32 rev; /* revision of bridge */ | 235 | u32 rev; /* revision of bridge */ |
236 | void *v_base; /* virtual base addr of bridge regs */ | 236 | void __iomem *v_base;/* virtual base addr of bridge regs */ |
237 | phys_addr_t p_base; /* physical base addr of bridge regs */ | 237 | phys_addr_t p_base; /* physical base addr of bridge regs */ |
238 | 238 | ||
239 | u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/ | 239 | u32 pci_mode_a; /* pci 0 mode: conventional pci, pci-x*/ |
@@ -303,7 +303,7 @@ void mv64x60_alloc_hose(struct mv64x60_handle *bh, u32 cfg_addr, | |||
303 | u32 cfg_data, struct pci_controller **hose); | 303 | u32 cfg_data, struct pci_controller **hose); |
304 | int mv64x60_get_type(struct mv64x60_handle *bh); | 304 | int mv64x60_get_type(struct mv64x60_handle *bh); |
305 | int mv64x60_setup_for_chip(struct mv64x60_handle *bh); | 305 | int mv64x60_setup_for_chip(struct mv64x60_handle *bh); |
306 | void *mv64x60_get_bridge_vbase(void); | 306 | void __iomem *mv64x60_get_bridge_vbase(void); |
307 | u32 mv64x60_get_bridge_type(void); | 307 | u32 mv64x60_get_bridge_type(void); |
308 | u32 mv64x60_get_bridge_rev(void); | 308 | u32 mv64x60_get_bridge_rev(void); |
309 | void mv64x60_get_mem_windows(struct mv64x60_handle *bh, | 309 | void mv64x60_get_mem_windows(struct mv64x60_handle *bh, |
diff --git a/include/asm-ppc64/tlbflush.h b/include/asm-ppc64/tlbflush.h index 45411a67e082..74271d7c1d16 100644 --- a/include/asm-ppc64/tlbflush.h +++ b/include/asm-ppc64/tlbflush.h | |||
@@ -25,6 +25,7 @@ struct ppc64_tlb_batch { | |||
25 | pte_t pte[PPC64_TLB_BATCH_NR]; | 25 | pte_t pte[PPC64_TLB_BATCH_NR]; |
26 | unsigned long addr[PPC64_TLB_BATCH_NR]; | 26 | unsigned long addr[PPC64_TLB_BATCH_NR]; |
27 | unsigned long vaddr[PPC64_TLB_BATCH_NR]; | 27 | unsigned long vaddr[PPC64_TLB_BATCH_NR]; |
28 | unsigned int large; | ||
28 | }; | 29 | }; |
29 | DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); | 30 | DECLARE_PER_CPU(struct ppc64_tlb_batch, ppc64_tlb_batch); |
30 | 31 | ||
diff --git a/include/asm-ppc64/uaccess.h b/include/asm-ppc64/uaccess.h index c181a60d868c..132c1276547b 100644 --- a/include/asm-ppc64/uaccess.h +++ b/include/asm-ppc64/uaccess.h | |||
@@ -164,7 +164,8 @@ do { \ | |||
164 | 164 | ||
165 | #define __get_user_nocheck(x,ptr,size) \ | 165 | #define __get_user_nocheck(x,ptr,size) \ |
166 | ({ \ | 166 | ({ \ |
167 | long __gu_err, __gu_val; \ | 167 | long __gu_err; \ |
168 | unsigned long __gu_val; \ | ||
168 | might_sleep(); \ | 169 | might_sleep(); \ |
169 | __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ | 170 | __get_user_size(__gu_val,(ptr),(size),__gu_err,-EFAULT);\ |
170 | (x) = (__typeof__(*(ptr)))__gu_val; \ | 171 | (x) = (__typeof__(*(ptr)))__gu_val; \ |
@@ -173,7 +174,8 @@ do { \ | |||
173 | 174 | ||
174 | #define __get_user_check(x,ptr,size) \ | 175 | #define __get_user_check(x,ptr,size) \ |
175 | ({ \ | 176 | ({ \ |
176 | long __gu_err = -EFAULT, __gu_val = 0; \ | 177 | long __gu_err = -EFAULT; \ |
178 | unsigned long __gu_val = 0; \ | ||
177 | const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ | 179 | const __typeof__(*(ptr)) __user *__gu_addr = (ptr); \ |
178 | might_sleep(); \ | 180 | might_sleep(); \ |
179 | if (access_ok(VERIFY_READ,__gu_addr,size)) \ | 181 | if (access_ok(VERIFY_READ,__gu_addr,size)) \ |
diff --git a/include/asm-s390/sigcontext.h b/include/asm-s390/sigcontext.h index d57bc0cebdce..803545351dd8 100644 --- a/include/asm-s390/sigcontext.h +++ b/include/asm-s390/sigcontext.h | |||
@@ -61,7 +61,7 @@ typedef struct | |||
61 | struct sigcontext | 61 | struct sigcontext |
62 | { | 62 | { |
63 | unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS]; | 63 | unsigned long oldmask[_SIGCONTEXT_NSIG_WORDS]; |
64 | _sigregs *sregs; | 64 | _sigregs __user *sregs; |
65 | }; | 65 | }; |
66 | 66 | ||
67 | 67 | ||
diff --git a/include/asm-s390/signal.h b/include/asm-s390/signal.h index 3d6e11c6c1fd..7084626de215 100644 --- a/include/asm-s390/signal.h +++ b/include/asm-s390/signal.h | |||
@@ -165,7 +165,7 @@ struct sigaction { | |||
165 | #endif /* __KERNEL__ */ | 165 | #endif /* __KERNEL__ */ |
166 | 166 | ||
167 | typedef struct sigaltstack { | 167 | typedef struct sigaltstack { |
168 | void *ss_sp; | 168 | void __user *ss_sp; |
169 | int ss_flags; | 169 | int ss_flags; |
170 | size_t ss_size; | 170 | size_t ss_size; |
171 | } stack_t; | 171 | } stack_t; |
diff --git a/include/linux/key-ui.h b/include/linux/key-ui.h index cc326174a808..918c34a8347e 100644 --- a/include/linux/key-ui.h +++ b/include/linux/key-ui.h | |||
@@ -42,11 +42,14 @@ struct keyring_list { | |||
42 | /* | 42 | /* |
43 | * check to see whether permission is granted to use a key in the desired way | 43 | * check to see whether permission is granted to use a key in the desired way |
44 | */ | 44 | */ |
45 | static inline int key_permission(const struct key *key, key_perm_t perm) | 45 | static inline int key_permission(const key_ref_t key_ref, key_perm_t perm) |
46 | { | 46 | { |
47 | struct key *key = key_ref_to_ptr(key_ref); | ||
47 | key_perm_t kperm; | 48 | key_perm_t kperm; |
48 | 49 | ||
49 | if (key->uid == current->fsuid) | 50 | if (is_key_possessed(key_ref)) |
51 | kperm = key->perm >> 24; | ||
52 | else if (key->uid == current->fsuid) | ||
50 | kperm = key->perm >> 16; | 53 | kperm = key->perm >> 16; |
51 | else if (key->gid != -1 && | 54 | else if (key->gid != -1 && |
52 | key->perm & KEY_GRP_ALL && | 55 | key->perm & KEY_GRP_ALL && |
@@ -65,11 +68,14 @@ static inline int key_permission(const struct key *key, key_perm_t perm) | |||
65 | * check to see whether permission is granted to use a key in at least one of | 68 | * check to see whether permission is granted to use a key in at least one of |
66 | * the desired ways | 69 | * the desired ways |
67 | */ | 70 | */ |
68 | static inline int key_any_permission(const struct key *key, key_perm_t perm) | 71 | static inline int key_any_permission(const key_ref_t key_ref, key_perm_t perm) |
69 | { | 72 | { |
73 | struct key *key = key_ref_to_ptr(key_ref); | ||
70 | key_perm_t kperm; | 74 | key_perm_t kperm; |
71 | 75 | ||
72 | if (key->uid == current->fsuid) | 76 | if (is_key_possessed(key_ref)) |
77 | kperm = key->perm >> 24; | ||
78 | else if (key->uid == current->fsuid) | ||
73 | kperm = key->perm >> 16; | 79 | kperm = key->perm >> 16; |
74 | else if (key->gid != -1 && | 80 | else if (key->gid != -1 && |
75 | key->perm & KEY_GRP_ALL && | 81 | key->perm & KEY_GRP_ALL && |
@@ -94,13 +100,17 @@ static inline int key_task_groups_search(struct task_struct *tsk, gid_t gid) | |||
94 | return ret; | 100 | return ret; |
95 | } | 101 | } |
96 | 102 | ||
97 | static inline int key_task_permission(const struct key *key, | 103 | static inline int key_task_permission(const key_ref_t key_ref, |
98 | struct task_struct *context, | 104 | struct task_struct *context, |
99 | key_perm_t perm) | 105 | key_perm_t perm) |
100 | { | 106 | { |
107 | struct key *key = key_ref_to_ptr(key_ref); | ||
101 | key_perm_t kperm; | 108 | key_perm_t kperm; |
102 | 109 | ||
103 | if (key->uid == context->fsuid) { | 110 | if (is_key_possessed(key_ref)) { |
111 | kperm = key->perm >> 24; | ||
112 | } | ||
113 | else if (key->uid == context->fsuid) { | ||
104 | kperm = key->perm >> 16; | 114 | kperm = key->perm >> 16; |
105 | } | 115 | } |
106 | else if (key->gid != -1 && | 116 | else if (key->gid != -1 && |
@@ -121,9 +131,9 @@ static inline int key_task_permission(const struct key *key, | |||
121 | 131 | ||
122 | } | 132 | } |
123 | 133 | ||
124 | extern struct key *lookup_user_key(struct task_struct *context, | 134 | extern key_ref_t lookup_user_key(struct task_struct *context, |
125 | key_serial_t id, int create, int partial, | 135 | key_serial_t id, int create, int partial, |
126 | key_perm_t perm); | 136 | key_perm_t perm); |
127 | 137 | ||
128 | extern long join_session_keyring(const char *name); | 138 | extern long join_session_keyring(const char *name); |
129 | 139 | ||
diff --git a/include/linux/key.h b/include/linux/key.h index 970bbd916cf4..f1efa016dbf3 100644 --- a/include/linux/key.h +++ b/include/linux/key.h | |||
@@ -35,11 +35,18 @@ struct key; | |||
35 | 35 | ||
36 | #undef KEY_DEBUGGING | 36 | #undef KEY_DEBUGGING |
37 | 37 | ||
38 | #define KEY_USR_VIEW 0x00010000 /* user can view a key's attributes */ | 38 | #define KEY_POS_VIEW 0x01000000 /* possessor can view a key's attributes */ |
39 | #define KEY_USR_READ 0x00020000 /* user can read key payload / view keyring */ | 39 | #define KEY_POS_READ 0x02000000 /* possessor can read key payload / view keyring */ |
40 | #define KEY_USR_WRITE 0x00040000 /* user can update key payload / add link to keyring */ | 40 | #define KEY_POS_WRITE 0x04000000 /* possessor can update key payload / add link to keyring */ |
41 | #define KEY_USR_SEARCH 0x00080000 /* user can find a key in search / search a keyring */ | 41 | #define KEY_POS_SEARCH 0x08000000 /* possessor can find a key in search / search a keyring */ |
42 | #define KEY_USR_LINK 0x00100000 /* user can create a link to a key/keyring */ | 42 | #define KEY_POS_LINK 0x10000000 /* possessor can create a link to a key/keyring */ |
43 | #define KEY_POS_ALL 0x1f000000 | ||
44 | |||
45 | #define KEY_USR_VIEW 0x00010000 /* user permissions... */ | ||
46 | #define KEY_USR_READ 0x00020000 | ||
47 | #define KEY_USR_WRITE 0x00040000 | ||
48 | #define KEY_USR_SEARCH 0x00080000 | ||
49 | #define KEY_USR_LINK 0x00100000 | ||
43 | #define KEY_USR_ALL 0x001f0000 | 50 | #define KEY_USR_ALL 0x001f0000 |
44 | 51 | ||
45 | #define KEY_GRP_VIEW 0x00000100 /* group permissions... */ | 52 | #define KEY_GRP_VIEW 0x00000100 /* group permissions... */ |
@@ -67,6 +74,38 @@ struct keyring_name; | |||
67 | 74 | ||
68 | /*****************************************************************************/ | 75 | /*****************************************************************************/ |
69 | /* | 76 | /* |
77 | * key reference with possession attribute handling | ||
78 | * | ||
79 | * NOTE! key_ref_t is a typedef'd pointer to a type that is not actually | ||
80 | * defined. This is because we abuse the bottom bit of the reference to carry a | ||
81 | * flag to indicate whether the calling process possesses that key in one of | ||
82 | * its keyrings. | ||
83 | * | ||
84 | * the key_ref_t has been made a separate type so that the compiler can reject | ||
85 | * attempts to dereference it without proper conversion. | ||
86 | * | ||
87 | * the three functions are used to assemble and disassemble references | ||
88 | */ | ||
89 | typedef struct __key_reference_with_attributes *key_ref_t; | ||
90 | |||
91 | static inline key_ref_t make_key_ref(const struct key *key, | ||
92 | unsigned long possession) | ||
93 | { | ||
94 | return (key_ref_t) ((unsigned long) key | possession); | ||
95 | } | ||
96 | |||
97 | static inline struct key *key_ref_to_ptr(const key_ref_t key_ref) | ||
98 | { | ||
99 | return (struct key *) ((unsigned long) key_ref & ~1UL); | ||
100 | } | ||
101 | |||
102 | static inline unsigned long is_key_possessed(const key_ref_t key_ref) | ||
103 | { | ||
104 | return (unsigned long) key_ref & 1UL; | ||
105 | } | ||
106 | |||
107 | /*****************************************************************************/ | ||
108 | /* | ||
70 | * authentication token / access credential / keyring | 109 | * authentication token / access credential / keyring |
71 | * - types of key include: | 110 | * - types of key include: |
72 | * - keyrings | 111 | * - keyrings |
@@ -215,20 +254,25 @@ static inline struct key *key_get(struct key *key) | |||
215 | return key; | 254 | return key; |
216 | } | 255 | } |
217 | 256 | ||
257 | static inline void key_ref_put(key_ref_t key_ref) | ||
258 | { | ||
259 | key_put(key_ref_to_ptr(key_ref)); | ||
260 | } | ||
261 | |||
218 | extern struct key *request_key(struct key_type *type, | 262 | extern struct key *request_key(struct key_type *type, |
219 | const char *description, | 263 | const char *description, |
220 | const char *callout_info); | 264 | const char *callout_info); |
221 | 265 | ||
222 | extern int key_validate(struct key *key); | 266 | extern int key_validate(struct key *key); |
223 | 267 | ||
224 | extern struct key *key_create_or_update(struct key *keyring, | 268 | extern key_ref_t key_create_or_update(key_ref_t keyring, |
225 | const char *type, | 269 | const char *type, |
226 | const char *description, | 270 | const char *description, |
227 | const void *payload, | 271 | const void *payload, |
228 | size_t plen, | 272 | size_t plen, |
229 | int not_in_quota); | 273 | int not_in_quota); |
230 | 274 | ||
231 | extern int key_update(struct key *key, | 275 | extern int key_update(key_ref_t key, |
232 | const void *payload, | 276 | const void *payload, |
233 | size_t plen); | 277 | size_t plen); |
234 | 278 | ||
@@ -243,9 +287,9 @@ extern struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, | |||
243 | 287 | ||
244 | extern int keyring_clear(struct key *keyring); | 288 | extern int keyring_clear(struct key *keyring); |
245 | 289 | ||
246 | extern struct key *keyring_search(struct key *keyring, | 290 | extern key_ref_t keyring_search(key_ref_t keyring, |
247 | struct key_type *type, | 291 | struct key_type *type, |
248 | const char *description); | 292 | const char *description); |
249 | 293 | ||
250 | extern int keyring_add_key(struct key *keyring, | 294 | extern int keyring_add_key(struct key *keyring, |
251 | struct key *key); | 295 | struct key *key); |
@@ -285,6 +329,10 @@ extern void key_init(void); | |||
285 | #define key_serial(k) 0 | 329 | #define key_serial(k) 0 |
286 | #define key_get(k) ({ NULL; }) | 330 | #define key_get(k) ({ NULL; }) |
287 | #define key_put(k) do { } while(0) | 331 | #define key_put(k) do { } while(0) |
332 | #define key_ref_put(k) do { } while(0) | ||
333 | #define make_key_ref(k) ({ NULL; }) | ||
334 | #define key_ref_to_ptr(k) ({ NULL; }) | ||
335 | #define is_key_possessed(k) 0 | ||
288 | #define alloc_uid_keyring(u) 0 | 336 | #define alloc_uid_keyring(u) 0 |
289 | #define switch_uid_keyring(u) do { } while(0) | 337 | #define switch_uid_keyring(u) do { } while(0) |
290 | #define __install_session_keyring(t, k) ({ NULL; }) | 338 | #define __install_session_keyring(t, k) ({ NULL; }) |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index e16cf94870f2..e6f4c9e55df7 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
@@ -665,7 +665,6 @@ struct ib_ucontext { | |||
665 | struct list_head qp_list; | 665 | struct list_head qp_list; |
666 | struct list_head srq_list; | 666 | struct list_head srq_list; |
667 | struct list_head ah_list; | 667 | struct list_head ah_list; |
668 | spinlock_t lock; | ||
669 | }; | 668 | }; |
670 | 669 | ||
671 | struct ib_uobject { | 670 | struct ib_uobject { |
diff --git a/kernel/cpuset.c b/kernel/cpuset.c index 79866bc6b3a1..6a6e87b2f2fd 100644 --- a/kernel/cpuset.c +++ b/kernel/cpuset.c | |||
@@ -969,7 +969,7 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, | |||
969 | ssize_t retval = 0; | 969 | ssize_t retval = 0; |
970 | char *s; | 970 | char *s; |
971 | char *start; | 971 | char *start; |
972 | size_t n; | 972 | ssize_t n; |
973 | 973 | ||
974 | if (!(page = (char *)__get_free_page(GFP_KERNEL))) | 974 | if (!(page = (char *)__get_free_page(GFP_KERNEL))) |
975 | return -ENOMEM; | 975 | return -ENOMEM; |
@@ -999,12 +999,13 @@ static ssize_t cpuset_common_file_read(struct file *file, char __user *buf, | |||
999 | *s++ = '\n'; | 999 | *s++ = '\n'; |
1000 | *s = '\0'; | 1000 | *s = '\0'; |
1001 | 1001 | ||
1002 | /* Do nothing if *ppos is at the eof or beyond the eof. */ | ||
1003 | if (s - page <= *ppos) | ||
1004 | return 0; | ||
1005 | |||
1006 | start = page + *ppos; | 1002 | start = page + *ppos; |
1007 | n = s - start; | 1003 | n = s - start; |
1004 | |||
1005 | /* Do nothing if *ppos is at the eof or beyond the eof. */ | ||
1006 | if (n <= 0) | ||
1007 | goto out; | ||
1008 | |||
1008 | retval = n - copy_to_user(buf, start, min(n, nbytes)); | 1009 | retval = n - copy_to_user(buf, start, min(n, nbytes)); |
1009 | *ppos += retval; | 1010 | *ppos += retval; |
1010 | out: | 1011 | out: |
diff --git a/kernel/params.c b/kernel/params.c index fbf173215fd2..1a8614bac5d5 100644 --- a/kernel/params.c +++ b/kernel/params.c | |||
@@ -80,8 +80,6 @@ static char *next_arg(char *args, char **param, char **val) | |||
80 | int in_quote = 0, quoted = 0; | 80 | int in_quote = 0, quoted = 0; |
81 | char *next; | 81 | char *next; |
82 | 82 | ||
83 | /* Chew any extra spaces */ | ||
84 | while (*args == ' ') args++; | ||
85 | if (*args == '"') { | 83 | if (*args == '"') { |
86 | args++; | 84 | args++; |
87 | in_quote = 1; | 85 | in_quote = 1; |
@@ -121,6 +119,10 @@ static char *next_arg(char *args, char **param, char **val) | |||
121 | next = args + i + 1; | 119 | next = args + i + 1; |
122 | } else | 120 | } else |
123 | next = args + i; | 121 | next = args + i; |
122 | |||
123 | /* Chew up trailing spaces. */ | ||
124 | while (*next == ' ') | ||
125 | next++; | ||
124 | return next; | 126 | return next; |
125 | } | 127 | } |
126 | 128 | ||
@@ -135,6 +137,10 @@ int parse_args(const char *name, | |||
135 | 137 | ||
136 | DEBUGP("Parsing ARGS: %s\n", args); | 138 | DEBUGP("Parsing ARGS: %s\n", args); |
137 | 139 | ||
140 | /* Chew leading spaces */ | ||
141 | while (*args == ' ') | ||
142 | args++; | ||
143 | |||
138 | while (*args) { | 144 | while (*args) { |
139 | int ret; | 145 | int ret; |
140 | 146 | ||
diff --git a/kernel/power/power.h b/kernel/power/power.h index 9c9167d910dd..6748de23e83c 100644 --- a/kernel/power/power.h +++ b/kernel/power/power.h | |||
@@ -9,6 +9,9 @@ | |||
9 | #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) | 9 | #define SUSPEND_CONSOLE (MAX_NR_CONSOLES-1) |
10 | #endif | 10 | #endif |
11 | 11 | ||
12 | #define MAX_PBES ((PAGE_SIZE - sizeof(struct new_utsname) \ | ||
13 | - 4 - 3*sizeof(unsigned long) - sizeof(int) \ | ||
14 | - sizeof(void *)) / sizeof(swp_entry_t)) | ||
12 | 15 | ||
13 | struct swsusp_info { | 16 | struct swsusp_info { |
14 | struct new_utsname uts; | 17 | struct new_utsname uts; |
@@ -18,7 +21,7 @@ struct swsusp_info { | |||
18 | unsigned long image_pages; | 21 | unsigned long image_pages; |
19 | unsigned long pagedir_pages; | 22 | unsigned long pagedir_pages; |
20 | suspend_pagedir_t * suspend_pagedir; | 23 | suspend_pagedir_t * suspend_pagedir; |
21 | swp_entry_t pagedir[768]; | 24 | swp_entry_t pagedir[MAX_PBES]; |
22 | } __attribute__((aligned(PAGE_SIZE))); | 25 | } __attribute__((aligned(PAGE_SIZE))); |
23 | 26 | ||
24 | 27 | ||
diff --git a/kernel/power/swsusp.c b/kernel/power/swsusp.c index 1cc9ff25e479..acf79ac1cb6d 100644 --- a/kernel/power/swsusp.c +++ b/kernel/power/swsusp.c | |||
@@ -402,15 +402,14 @@ static int write_page(unsigned long addr, swp_entry_t * loc) | |||
402 | static void data_free(void) | 402 | static void data_free(void) |
403 | { | 403 | { |
404 | swp_entry_t entry; | 404 | swp_entry_t entry; |
405 | int i; | 405 | struct pbe * p; |
406 | 406 | ||
407 | for (i = 0; i < nr_copy_pages; i++) { | 407 | for_each_pbe(p, pagedir_nosave) { |
408 | entry = (pagedir_nosave + i)->swap_address; | 408 | entry = p->swap_address; |
409 | if (entry.val) | 409 | if (entry.val) |
410 | swap_free(entry); | 410 | swap_free(entry); |
411 | else | 411 | else |
412 | break; | 412 | break; |
413 | (pagedir_nosave + i)->swap_address = (swp_entry_t){0}; | ||
414 | } | 413 | } |
415 | } | 414 | } |
416 | 415 | ||
@@ -932,6 +931,10 @@ static int swsusp_alloc(void) | |||
932 | if (!enough_swap()) | 931 | if (!enough_swap()) |
933 | return -ENOSPC; | 932 | return -ENOSPC; |
934 | 933 | ||
934 | if (MAX_PBES < nr_copy_pages / PBES_PER_PAGE + | ||
935 | !!(nr_copy_pages % PBES_PER_PAGE)) | ||
936 | return -ENOSPC; | ||
937 | |||
935 | if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) { | 938 | if (!(pagedir_save = alloc_pagedir(nr_copy_pages))) { |
936 | printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); | 939 | printk(KERN_ERR "suspend: Allocating pagedir failed.\n"); |
937 | return -ENOMEM; | 940 | return -ENOMEM; |
@@ -1438,9 +1441,9 @@ static int read_pagedir(struct pbe *pblist) | |||
1438 | } | 1441 | } |
1439 | 1442 | ||
1440 | if (error) | 1443 | if (error) |
1441 | free_page((unsigned long)pblist); | 1444 | free_pagedir(pblist); |
1442 | 1445 | else | |
1443 | BUG_ON(i != swsusp_info.pagedir_pages); | 1446 | BUG_ON(i != swsusp_info.pagedir_pages); |
1444 | 1447 | ||
1445 | return error; | 1448 | return error; |
1446 | } | 1449 | } |
diff --git a/mm/mremap.c b/mm/mremap.c index a32fed454bd7..f343fc73a8bd 100644 --- a/mm/mremap.c +++ b/mm/mremap.c | |||
@@ -141,10 +141,10 @@ move_one_page(struct vm_area_struct *vma, unsigned long old_addr, | |||
141 | if (dst) { | 141 | if (dst) { |
142 | pte_t pte; | 142 | pte_t pte; |
143 | pte = ptep_clear_flush(vma, old_addr, src); | 143 | pte = ptep_clear_flush(vma, old_addr, src); |
144 | |||
144 | /* ZERO_PAGE can be dependant on virtual addr */ | 145 | /* ZERO_PAGE can be dependant on virtual addr */ |
145 | if (pfn_valid(pte_pfn(pte)) && | 146 | pte = move_pte(pte, new_vma->vm_page_prot, |
146 | pte_page(pte) == ZERO_PAGE(old_addr)) | 147 | old_addr, new_addr); |
147 | pte = pte_wrprotect(mk_pte(ZERO_PAGE(new_addr), new_vma->vm_page_prot)); | ||
148 | set_pte_at(mm, new_addr, dst, pte); | 148 | set_pte_at(mm, new_addr, dst, pte); |
149 | } else | 149 | } else |
150 | error = -ENOMEM; | 150 | error = -ENOMEM; |
@@ -2510,16 +2510,12 @@ cache_alloc_debugcheck_after(kmem_cache_t *cachep, | |||
2510 | #define cache_alloc_debugcheck_after(a,b,objp,d) (objp) | 2510 | #define cache_alloc_debugcheck_after(a,b,objp,d) (objp) |
2511 | #endif | 2511 | #endif |
2512 | 2512 | ||
2513 | 2513 | static inline void *____cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) | |
2514 | static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) | ||
2515 | { | 2514 | { |
2516 | unsigned long save_flags; | ||
2517 | void* objp; | 2515 | void* objp; |
2518 | struct array_cache *ac; | 2516 | struct array_cache *ac; |
2519 | 2517 | ||
2520 | cache_alloc_debugcheck_before(cachep, flags); | 2518 | check_irq_off(); |
2521 | |||
2522 | local_irq_save(save_flags); | ||
2523 | ac = ac_data(cachep); | 2519 | ac = ac_data(cachep); |
2524 | if (likely(ac->avail)) { | 2520 | if (likely(ac->avail)) { |
2525 | STATS_INC_ALLOCHIT(cachep); | 2521 | STATS_INC_ALLOCHIT(cachep); |
@@ -2529,6 +2525,18 @@ static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast fl | |||
2529 | STATS_INC_ALLOCMISS(cachep); | 2525 | STATS_INC_ALLOCMISS(cachep); |
2530 | objp = cache_alloc_refill(cachep, flags); | 2526 | objp = cache_alloc_refill(cachep, flags); |
2531 | } | 2527 | } |
2528 | return objp; | ||
2529 | } | ||
2530 | |||
2531 | static inline void *__cache_alloc(kmem_cache_t *cachep, unsigned int __nocast flags) | ||
2532 | { | ||
2533 | unsigned long save_flags; | ||
2534 | void* objp; | ||
2535 | |||
2536 | cache_alloc_debugcheck_before(cachep, flags); | ||
2537 | |||
2538 | local_irq_save(save_flags); | ||
2539 | objp = ____cache_alloc(cachep, flags); | ||
2532 | local_irq_restore(save_flags); | 2540 | local_irq_restore(save_flags); |
2533 | objp = cache_alloc_debugcheck_after(cachep, flags, objp, | 2541 | objp = cache_alloc_debugcheck_after(cachep, flags, objp, |
2534 | __builtin_return_address(0)); | 2542 | __builtin_return_address(0)); |
@@ -2856,7 +2864,10 @@ void *kmem_cache_alloc_node(kmem_cache_t *cachep, unsigned int __nocast flags, i | |||
2856 | 2864 | ||
2857 | cache_alloc_debugcheck_before(cachep, flags); | 2865 | cache_alloc_debugcheck_before(cachep, flags); |
2858 | local_irq_save(save_flags); | 2866 | local_irq_save(save_flags); |
2859 | ptr = __cache_alloc_node(cachep, flags, nodeid); | 2867 | if (nodeid == numa_node_id()) |
2868 | ptr = ____cache_alloc(cachep, flags); | ||
2869 | else | ||
2870 | ptr = __cache_alloc_node(cachep, flags, nodeid); | ||
2860 | local_irq_restore(save_flags); | 2871 | local_irq_restore(save_flags); |
2861 | ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); | 2872 | ptr = cache_alloc_debugcheck_after(cachep, flags, ptr, __builtin_return_address(0)); |
2862 | 2873 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index ef430b1e8e42..b7f2d65a614f 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
@@ -186,7 +186,7 @@ | |||
186 | 186 | ||
187 | /* Used to help with determining the pkts on receive */ | 187 | /* Used to help with determining the pkts on receive */ |
188 | #define PKTGEN_MAGIC 0xbe9be955 | 188 | #define PKTGEN_MAGIC 0xbe9be955 |
189 | #define PG_PROC_DIR "pktgen" | 189 | #define PG_PROC_DIR "net/pktgen" |
190 | 190 | ||
191 | #define MAX_CFLOWS 65536 | 191 | #define MAX_CFLOWS 65536 |
192 | 192 | ||
@@ -1476,18 +1476,7 @@ static int proc_thread_write(struct file *file, const char __user *user_buffer, | |||
1476 | 1476 | ||
1477 | static int create_proc_dir(void) | 1477 | static int create_proc_dir(void) |
1478 | { | 1478 | { |
1479 | int len; | 1479 | pg_proc_dir = proc_mkdir(PG_PROC_DIR, NULL); |
1480 | /* does proc_dir already exists */ | ||
1481 | len = strlen(PG_PROC_DIR); | ||
1482 | |||
1483 | for (pg_proc_dir = proc_net->subdir; pg_proc_dir; pg_proc_dir=pg_proc_dir->next) { | ||
1484 | if ((pg_proc_dir->namelen == len) && | ||
1485 | (! memcmp(pg_proc_dir->name, PG_PROC_DIR, len))) | ||
1486 | break; | ||
1487 | } | ||
1488 | |||
1489 | if (!pg_proc_dir) | ||
1490 | pg_proc_dir = create_proc_entry(PG_PROC_DIR, S_IFDIR, proc_net); | ||
1491 | 1480 | ||
1492 | if (!pg_proc_dir) | 1481 | if (!pg_proc_dir) |
1493 | return -ENODEV; | 1482 | return -ENODEV; |
@@ -1497,7 +1486,7 @@ static int create_proc_dir(void) | |||
1497 | 1486 | ||
1498 | static int remove_proc_dir(void) | 1487 | static int remove_proc_dir(void) |
1499 | { | 1488 | { |
1500 | remove_proc_entry(PG_PROC_DIR, proc_net); | 1489 | remove_proc_entry(PG_PROC_DIR, NULL); |
1501 | return 0; | 1490 | return 0; |
1502 | } | 1491 | } |
1503 | 1492 | ||
@@ -2908,7 +2897,7 @@ static int pktgen_add_device(struct pktgen_thread *t, const char* ifname) | |||
2908 | pkt_dev->udp_dst_max = 9; | 2897 | pkt_dev->udp_dst_max = 9; |
2909 | 2898 | ||
2910 | strncpy(pkt_dev->ifname, ifname, 31); | 2899 | strncpy(pkt_dev->ifname, ifname, 31); |
2911 | sprintf(pkt_dev->fname, "net/%s/%s", PG_PROC_DIR, ifname); | 2900 | sprintf(pkt_dev->fname, "%s/%s", PG_PROC_DIR, ifname); |
2912 | 2901 | ||
2913 | if (! pktgen_setup_dev(pkt_dev)) { | 2902 | if (! pktgen_setup_dev(pkt_dev)) { |
2914 | printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); | 2903 | printk("pktgen: ERROR: pktgen_setup_dev failed.\n"); |
@@ -2981,7 +2970,7 @@ static int pktgen_create_thread(const char* name, int cpu) | |||
2981 | spin_lock_init(&t->if_lock); | 2970 | spin_lock_init(&t->if_lock); |
2982 | t->cpu = cpu; | 2971 | t->cpu = cpu; |
2983 | 2972 | ||
2984 | sprintf(t->fname, "net/%s/%s", PG_PROC_DIR, t->name); | 2973 | sprintf(t->fname, "%s/%s", PG_PROC_DIR, t->name); |
2985 | t->proc_ent = create_proc_entry(t->fname, 0600, NULL); | 2974 | t->proc_ent = create_proc_entry(t->fname, 0600, NULL); |
2986 | if (!t->proc_ent) { | 2975 | if (!t->proc_ent) { |
2987 | printk("pktgen: cannot create %s procfs entry.\n", t->fname); | 2976 | printk("pktgen: cannot create %s procfs entry.\n", t->fname); |
@@ -3064,7 +3053,7 @@ static int __init pg_init(void) | |||
3064 | 3053 | ||
3065 | create_proc_dir(); | 3054 | create_proc_dir(); |
3066 | 3055 | ||
3067 | sprintf(module_fname, "net/%s/pgctrl", PG_PROC_DIR); | 3056 | sprintf(module_fname, "%s/pgctrl", PG_PROC_DIR); |
3068 | module_proc_ent = create_proc_entry(module_fname, 0600, NULL); | 3057 | module_proc_ent = create_proc_entry(module_fname, 0600, NULL); |
3069 | if (!module_proc_ent) { | 3058 | if (!module_proc_ent) { |
3070 | printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); | 3059 | printk("pktgen: ERROR: cannot create %s procfs entry.\n", module_fname); |
diff --git a/net/ieee80211/ieee80211_module.c b/net/ieee80211/ieee80211_module.c index 03a47343ddc7..6059e9e37123 100644 --- a/net/ieee80211/ieee80211_module.c +++ b/net/ieee80211/ieee80211_module.c | |||
@@ -230,7 +230,7 @@ static int __init ieee80211_init(void) | |||
230 | struct proc_dir_entry *e; | 230 | struct proc_dir_entry *e; |
231 | 231 | ||
232 | ieee80211_debug_level = debug; | 232 | ieee80211_debug_level = debug; |
233 | ieee80211_proc = create_proc_entry(DRV_NAME, S_IFDIR, proc_net); | 233 | ieee80211_proc = proc_mkdir(DRV_NAME, proc_net); |
234 | if (ieee80211_proc == NULL) { | 234 | if (ieee80211_proc == NULL) { |
235 | IEEE80211_ERROR("Unable to create " DRV_NAME | 235 | IEEE80211_ERROR("Unable to create " DRV_NAME |
236 | " proc directory\n"); | 236 | " proc directory\n"); |
diff --git a/security/keys/internal.h b/security/keys/internal.h index 46c8602661c9..db99ed434f3a 100644 --- a/security/keys/internal.h +++ b/security/keys/internal.h | |||
@@ -71,26 +71,26 @@ extern void keyring_publish_name(struct key *keyring); | |||
71 | 71 | ||
72 | extern int __key_link(struct key *keyring, struct key *key); | 72 | extern int __key_link(struct key *keyring, struct key *key); |
73 | 73 | ||
74 | extern struct key *__keyring_search_one(struct key *keyring, | 74 | extern key_ref_t __keyring_search_one(key_ref_t keyring_ref, |
75 | const struct key_type *type, | 75 | const struct key_type *type, |
76 | const char *description, | 76 | const char *description, |
77 | key_perm_t perm); | 77 | key_perm_t perm); |
78 | 78 | ||
79 | extern struct key *keyring_search_instkey(struct key *keyring, | 79 | extern struct key *keyring_search_instkey(struct key *keyring, |
80 | key_serial_t target_id); | 80 | key_serial_t target_id); |
81 | 81 | ||
82 | typedef int (*key_match_func_t)(const struct key *, const void *); | 82 | typedef int (*key_match_func_t)(const struct key *, const void *); |
83 | 83 | ||
84 | extern struct key *keyring_search_aux(struct key *keyring, | 84 | extern key_ref_t keyring_search_aux(key_ref_t keyring_ref, |
85 | struct task_struct *tsk, | 85 | struct task_struct *tsk, |
86 | struct key_type *type, | 86 | struct key_type *type, |
87 | const void *description, | 87 | const void *description, |
88 | key_match_func_t match); | 88 | key_match_func_t match); |
89 | 89 | ||
90 | extern struct key *search_process_keyrings(struct key_type *type, | 90 | extern key_ref_t search_process_keyrings(struct key_type *type, |
91 | const void *description, | 91 | const void *description, |
92 | key_match_func_t match, | 92 | key_match_func_t match, |
93 | struct task_struct *tsk); | 93 | struct task_struct *tsk); |
94 | 94 | ||
95 | extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); | 95 | extern struct key *find_keyring_by_name(const char *name, key_serial_t bound); |
96 | 96 | ||
diff --git a/security/keys/key.c b/security/keys/key.c index fb89f9844465..2182be9e9309 100644 --- a/security/keys/key.c +++ b/security/keys/key.c | |||
@@ -693,14 +693,15 @@ void key_type_put(struct key_type *ktype) | |||
693 | * - the key has an incremented refcount | 693 | * - the key has an incremented refcount |
694 | * - we need to put the key if we get an error | 694 | * - we need to put the key if we get an error |
695 | */ | 695 | */ |
696 | static inline struct key *__key_update(struct key *key, const void *payload, | 696 | static inline key_ref_t __key_update(key_ref_t key_ref, |
697 | size_t plen) | 697 | const void *payload, size_t plen) |
698 | { | 698 | { |
699 | struct key *key = key_ref_to_ptr(key_ref); | ||
699 | int ret; | 700 | int ret; |
700 | 701 | ||
701 | /* need write permission on the key to update it */ | 702 | /* need write permission on the key to update it */ |
702 | ret = -EACCES; | 703 | ret = -EACCES; |
703 | if (!key_permission(key, KEY_WRITE)) | 704 | if (!key_permission(key_ref, KEY_WRITE)) |
704 | goto error; | 705 | goto error; |
705 | 706 | ||
706 | ret = -EEXIST; | 707 | ret = -EEXIST; |
@@ -719,12 +720,12 @@ static inline struct key *__key_update(struct key *key, const void *payload, | |||
719 | 720 | ||
720 | if (ret < 0) | 721 | if (ret < 0) |
721 | goto error; | 722 | goto error; |
722 | out: | 723 | out: |
723 | return key; | 724 | return key_ref; |
724 | 725 | ||
725 | error: | 726 | error: |
726 | key_put(key); | 727 | key_put(key); |
727 | key = ERR_PTR(ret); | 728 | key_ref = ERR_PTR(ret); |
728 | goto out; | 729 | goto out; |
729 | 730 | ||
730 | } /* end __key_update() */ | 731 | } /* end __key_update() */ |
@@ -734,52 +735,56 @@ static inline struct key *__key_update(struct key *key, const void *payload, | |||
734 | * search the specified keyring for a key of the same description; if one is | 735 | * search the specified keyring for a key of the same description; if one is |
735 | * found, update it, otherwise add a new one | 736 | * found, update it, otherwise add a new one |
736 | */ | 737 | */ |
737 | struct key *key_create_or_update(struct key *keyring, | 738 | key_ref_t key_create_or_update(key_ref_t keyring_ref, |
738 | const char *type, | 739 | const char *type, |
739 | const char *description, | 740 | const char *description, |
740 | const void *payload, | 741 | const void *payload, |
741 | size_t plen, | 742 | size_t plen, |
742 | int not_in_quota) | 743 | int not_in_quota) |
743 | { | 744 | { |
744 | struct key_type *ktype; | 745 | struct key_type *ktype; |
745 | struct key *key = NULL; | 746 | struct key *keyring, *key = NULL; |
746 | key_perm_t perm; | 747 | key_perm_t perm; |
748 | key_ref_t key_ref; | ||
747 | int ret; | 749 | int ret; |
748 | 750 | ||
749 | key_check(keyring); | ||
750 | |||
751 | /* look up the key type to see if it's one of the registered kernel | 751 | /* look up the key type to see if it's one of the registered kernel |
752 | * types */ | 752 | * types */ |
753 | ktype = key_type_lookup(type); | 753 | ktype = key_type_lookup(type); |
754 | if (IS_ERR(ktype)) { | 754 | if (IS_ERR(ktype)) { |
755 | key = ERR_PTR(-ENODEV); | 755 | key_ref = ERR_PTR(-ENODEV); |
756 | goto error; | 756 | goto error; |
757 | } | 757 | } |
758 | 758 | ||
759 | ret = -EINVAL; | 759 | key_ref = ERR_PTR(-EINVAL); |
760 | if (!ktype->match || !ktype->instantiate) | 760 | if (!ktype->match || !ktype->instantiate) |
761 | goto error_2; | 761 | goto error_2; |
762 | 762 | ||
763 | keyring = key_ref_to_ptr(keyring_ref); | ||
764 | |||
765 | key_check(keyring); | ||
766 | |||
767 | down_write(&keyring->sem); | ||
768 | |||
769 | /* if we're going to allocate a new key, we're going to have | ||
770 | * to modify the keyring */ | ||
771 | key_ref = ERR_PTR(-EACCES); | ||
772 | if (!key_permission(keyring_ref, KEY_WRITE)) | ||
773 | goto error_3; | ||
774 | |||
763 | /* search for an existing key of the same type and description in the | 775 | /* search for an existing key of the same type and description in the |
764 | * destination keyring | 776 | * destination keyring |
765 | */ | 777 | */ |
766 | down_write(&keyring->sem); | 778 | key_ref = __keyring_search_one(keyring_ref, ktype, description, 0); |
767 | 779 | if (!IS_ERR(key_ref)) | |
768 | key = __keyring_search_one(keyring, ktype, description, 0); | ||
769 | if (!IS_ERR(key)) | ||
770 | goto found_matching_key; | 780 | goto found_matching_key; |
771 | 781 | ||
772 | /* if we're going to allocate a new key, we're going to have to modify | ||
773 | * the keyring */ | ||
774 | ret = -EACCES; | ||
775 | if (!key_permission(keyring, KEY_WRITE)) | ||
776 | goto error_3; | ||
777 | |||
778 | /* decide on the permissions we want */ | 782 | /* decide on the permissions we want */ |
779 | perm = KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; | 783 | perm = KEY_POS_VIEW | KEY_POS_SEARCH | KEY_POS_LINK; |
784 | perm |= KEY_USR_VIEW | KEY_USR_SEARCH | KEY_USR_LINK; | ||
780 | 785 | ||
781 | if (ktype->read) | 786 | if (ktype->read) |
782 | perm |= KEY_USR_READ; | 787 | perm |= KEY_POS_READ | KEY_USR_READ; |
783 | 788 | ||
784 | if (ktype == &key_type_keyring || ktype->update) | 789 | if (ktype == &key_type_keyring || ktype->update) |
785 | perm |= KEY_USR_WRITE; | 790 | perm |= KEY_USR_WRITE; |
@@ -788,7 +793,7 @@ struct key *key_create_or_update(struct key *keyring, | |||
788 | key = key_alloc(ktype, description, current->fsuid, current->fsgid, | 793 | key = key_alloc(ktype, description, current->fsuid, current->fsgid, |
789 | perm, not_in_quota); | 794 | perm, not_in_quota); |
790 | if (IS_ERR(key)) { | 795 | if (IS_ERR(key)) { |
791 | ret = PTR_ERR(key); | 796 | key_ref = ERR_PTR(PTR_ERR(key)); |
792 | goto error_3; | 797 | goto error_3; |
793 | } | 798 | } |
794 | 799 | ||
@@ -796,15 +801,18 @@ struct key *key_create_or_update(struct key *keyring, | |||
796 | ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL); | 801 | ret = __key_instantiate_and_link(key, payload, plen, keyring, NULL); |
797 | if (ret < 0) { | 802 | if (ret < 0) { |
798 | key_put(key); | 803 | key_put(key); |
799 | key = ERR_PTR(ret); | 804 | key_ref = ERR_PTR(ret); |
805 | goto error_3; | ||
800 | } | 806 | } |
801 | 807 | ||
808 | key_ref = make_key_ref(key, is_key_possessed(keyring_ref)); | ||
809 | |||
802 | error_3: | 810 | error_3: |
803 | up_write(&keyring->sem); | 811 | up_write(&keyring->sem); |
804 | error_2: | 812 | error_2: |
805 | key_type_put(ktype); | 813 | key_type_put(ktype); |
806 | error: | 814 | error: |
807 | return key; | 815 | return key_ref; |
808 | 816 | ||
809 | found_matching_key: | 817 | found_matching_key: |
810 | /* we found a matching key, so we're going to try to update it | 818 | /* we found a matching key, so we're going to try to update it |
@@ -813,7 +821,7 @@ struct key *key_create_or_update(struct key *keyring, | |||
813 | up_write(&keyring->sem); | 821 | up_write(&keyring->sem); |
814 | key_type_put(ktype); | 822 | key_type_put(ktype); |
815 | 823 | ||
816 | key = __key_update(key, payload, plen); | 824 | key_ref = __key_update(key_ref, payload, plen); |
817 | goto error; | 825 | goto error; |
818 | 826 | ||
819 | } /* end key_create_or_update() */ | 827 | } /* end key_create_or_update() */ |
@@ -824,15 +832,16 @@ EXPORT_SYMBOL(key_create_or_update); | |||
824 | /* | 832 | /* |
825 | * update a key | 833 | * update a key |
826 | */ | 834 | */ |
827 | int key_update(struct key *key, const void *payload, size_t plen) | 835 | int key_update(key_ref_t key_ref, const void *payload, size_t plen) |
828 | { | 836 | { |
837 | struct key *key = key_ref_to_ptr(key_ref); | ||
829 | int ret; | 838 | int ret; |
830 | 839 | ||
831 | key_check(key); | 840 | key_check(key); |
832 | 841 | ||
833 | /* the key must be writable */ | 842 | /* the key must be writable */ |
834 | ret = -EACCES; | 843 | ret = -EACCES; |
835 | if (!key_permission(key, KEY_WRITE)) | 844 | if (!key_permission(key_ref, KEY_WRITE)) |
836 | goto error; | 845 | goto error; |
837 | 846 | ||
838 | /* attempt to update it if supported */ | 847 | /* attempt to update it if supported */ |
diff --git a/security/keys/keyctl.c b/security/keys/keyctl.c index a6516a64b297..4c670ee6acf9 100644 --- a/security/keys/keyctl.c +++ b/security/keys/keyctl.c | |||
@@ -34,7 +34,7 @@ asmlinkage long sys_add_key(const char __user *_type, | |||
34 | size_t plen, | 34 | size_t plen, |
35 | key_serial_t ringid) | 35 | key_serial_t ringid) |
36 | { | 36 | { |
37 | struct key *keyring, *key; | 37 | key_ref_t keyring_ref, key_ref; |
38 | char type[32], *description; | 38 | char type[32], *description; |
39 | void *payload; | 39 | void *payload; |
40 | long dlen, ret; | 40 | long dlen, ret; |
@@ -86,25 +86,25 @@ asmlinkage long sys_add_key(const char __user *_type, | |||
86 | } | 86 | } |
87 | 87 | ||
88 | /* find the target keyring (which must be writable) */ | 88 | /* find the target keyring (which must be writable) */ |
89 | keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); | 89 | keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); |
90 | if (IS_ERR(keyring)) { | 90 | if (IS_ERR(keyring_ref)) { |
91 | ret = PTR_ERR(keyring); | 91 | ret = PTR_ERR(keyring_ref); |
92 | goto error3; | 92 | goto error3; |
93 | } | 93 | } |
94 | 94 | ||
95 | /* create or update the requested key and add it to the target | 95 | /* create or update the requested key and add it to the target |
96 | * keyring */ | 96 | * keyring */ |
97 | key = key_create_or_update(keyring, type, description, | 97 | key_ref = key_create_or_update(keyring_ref, type, description, |
98 | payload, plen, 0); | 98 | payload, plen, 0); |
99 | if (!IS_ERR(key)) { | 99 | if (!IS_ERR(key_ref)) { |
100 | ret = key->serial; | 100 | ret = key_ref_to_ptr(key_ref)->serial; |
101 | key_put(key); | 101 | key_ref_put(key_ref); |
102 | } | 102 | } |
103 | else { | 103 | else { |
104 | ret = PTR_ERR(key); | 104 | ret = PTR_ERR(key_ref); |
105 | } | 105 | } |
106 | 106 | ||
107 | key_put(keyring); | 107 | key_ref_put(keyring_ref); |
108 | error3: | 108 | error3: |
109 | kfree(payload); | 109 | kfree(payload); |
110 | error2: | 110 | error2: |
@@ -131,7 +131,8 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
131 | key_serial_t destringid) | 131 | key_serial_t destringid) |
132 | { | 132 | { |
133 | struct key_type *ktype; | 133 | struct key_type *ktype; |
134 | struct key *key, *dest; | 134 | struct key *key; |
135 | key_ref_t dest_ref; | ||
135 | char type[32], *description, *callout_info; | 136 | char type[32], *description, *callout_info; |
136 | long dlen, ret; | 137 | long dlen, ret; |
137 | 138 | ||
@@ -187,11 +188,11 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
187 | } | 188 | } |
188 | 189 | ||
189 | /* get the destination keyring if specified */ | 190 | /* get the destination keyring if specified */ |
190 | dest = NULL; | 191 | dest_ref = NULL; |
191 | if (destringid) { | 192 | if (destringid) { |
192 | dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); | 193 | dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); |
193 | if (IS_ERR(dest)) { | 194 | if (IS_ERR(dest_ref)) { |
194 | ret = PTR_ERR(dest); | 195 | ret = PTR_ERR(dest_ref); |
195 | goto error3; | 196 | goto error3; |
196 | } | 197 | } |
197 | } | 198 | } |
@@ -204,7 +205,8 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
204 | } | 205 | } |
205 | 206 | ||
206 | /* do the search */ | 207 | /* do the search */ |
207 | key = request_key_and_link(ktype, description, callout_info, dest); | 208 | key = request_key_and_link(ktype, description, callout_info, |
209 | key_ref_to_ptr(dest_ref)); | ||
208 | if (IS_ERR(key)) { | 210 | if (IS_ERR(key)) { |
209 | ret = PTR_ERR(key); | 211 | ret = PTR_ERR(key); |
210 | goto error5; | 212 | goto error5; |
@@ -216,7 +218,7 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
216 | error5: | 218 | error5: |
217 | key_type_put(ktype); | 219 | key_type_put(ktype); |
218 | error4: | 220 | error4: |
219 | key_put(dest); | 221 | key_ref_put(dest_ref); |
220 | error3: | 222 | error3: |
221 | kfree(callout_info); | 223 | kfree(callout_info); |
222 | error2: | 224 | error2: |
@@ -234,17 +236,17 @@ asmlinkage long sys_request_key(const char __user *_type, | |||
234 | */ | 236 | */ |
235 | long keyctl_get_keyring_ID(key_serial_t id, int create) | 237 | long keyctl_get_keyring_ID(key_serial_t id, int create) |
236 | { | 238 | { |
237 | struct key *key; | 239 | key_ref_t key_ref; |
238 | long ret; | 240 | long ret; |
239 | 241 | ||
240 | key = lookup_user_key(NULL, id, create, 0, KEY_SEARCH); | 242 | key_ref = lookup_user_key(NULL, id, create, 0, KEY_SEARCH); |
241 | if (IS_ERR(key)) { | 243 | if (IS_ERR(key_ref)) { |
242 | ret = PTR_ERR(key); | 244 | ret = PTR_ERR(key_ref); |
243 | goto error; | 245 | goto error; |
244 | } | 246 | } |
245 | 247 | ||
246 | ret = key->serial; | 248 | ret = key_ref_to_ptr(key_ref)->serial; |
247 | key_put(key); | 249 | key_ref_put(key_ref); |
248 | error: | 250 | error: |
249 | return ret; | 251 | return ret; |
250 | 252 | ||
@@ -302,7 +304,7 @@ long keyctl_update_key(key_serial_t id, | |||
302 | const void __user *_payload, | 304 | const void __user *_payload, |
303 | size_t plen) | 305 | size_t plen) |
304 | { | 306 | { |
305 | struct key *key; | 307 | key_ref_t key_ref; |
306 | void *payload; | 308 | void *payload; |
307 | long ret; | 309 | long ret; |
308 | 310 | ||
@@ -324,16 +326,16 @@ long keyctl_update_key(key_serial_t id, | |||
324 | } | 326 | } |
325 | 327 | ||
326 | /* find the target key (which must be writable) */ | 328 | /* find the target key (which must be writable) */ |
327 | key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); | 329 | key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); |
328 | if (IS_ERR(key)) { | 330 | if (IS_ERR(key_ref)) { |
329 | ret = PTR_ERR(key); | 331 | ret = PTR_ERR(key_ref); |
330 | goto error2; | 332 | goto error2; |
331 | } | 333 | } |
332 | 334 | ||
333 | /* update the key */ | 335 | /* update the key */ |
334 | ret = key_update(key, payload, plen); | 336 | ret = key_update(key_ref, payload, plen); |
335 | 337 | ||
336 | key_put(key); | 338 | key_ref_put(key_ref); |
337 | error2: | 339 | error2: |
338 | kfree(payload); | 340 | kfree(payload); |
339 | error: | 341 | error: |
@@ -349,19 +351,19 @@ long keyctl_update_key(key_serial_t id, | |||
349 | */ | 351 | */ |
350 | long keyctl_revoke_key(key_serial_t id) | 352 | long keyctl_revoke_key(key_serial_t id) |
351 | { | 353 | { |
352 | struct key *key; | 354 | key_ref_t key_ref; |
353 | long ret; | 355 | long ret; |
354 | 356 | ||
355 | key = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); | 357 | key_ref = lookup_user_key(NULL, id, 0, 0, KEY_WRITE); |
356 | if (IS_ERR(key)) { | 358 | if (IS_ERR(key_ref)) { |
357 | ret = PTR_ERR(key); | 359 | ret = PTR_ERR(key_ref); |
358 | goto error; | 360 | goto error; |
359 | } | 361 | } |
360 | 362 | ||
361 | key_revoke(key); | 363 | key_revoke(key_ref_to_ptr(key_ref)); |
362 | ret = 0; | 364 | ret = 0; |
363 | 365 | ||
364 | key_put(key); | 366 | key_ref_put(key_ref); |
365 | error: | 367 | error: |
366 | return ret; | 368 | return ret; |
367 | 369 | ||
@@ -375,18 +377,18 @@ long keyctl_revoke_key(key_serial_t id) | |||
375 | */ | 377 | */ |
376 | long keyctl_keyring_clear(key_serial_t ringid) | 378 | long keyctl_keyring_clear(key_serial_t ringid) |
377 | { | 379 | { |
378 | struct key *keyring; | 380 | key_ref_t keyring_ref; |
379 | long ret; | 381 | long ret; |
380 | 382 | ||
381 | keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); | 383 | keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); |
382 | if (IS_ERR(keyring)) { | 384 | if (IS_ERR(keyring_ref)) { |
383 | ret = PTR_ERR(keyring); | 385 | ret = PTR_ERR(keyring_ref); |
384 | goto error; | 386 | goto error; |
385 | } | 387 | } |
386 | 388 | ||
387 | ret = keyring_clear(keyring); | 389 | ret = keyring_clear(key_ref_to_ptr(keyring_ref)); |
388 | 390 | ||
389 | key_put(keyring); | 391 | key_ref_put(keyring_ref); |
390 | error: | 392 | error: |
391 | return ret; | 393 | return ret; |
392 | 394 | ||
@@ -401,26 +403,26 @@ long keyctl_keyring_clear(key_serial_t ringid) | |||
401 | */ | 403 | */ |
402 | long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) | 404 | long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) |
403 | { | 405 | { |
404 | struct key *keyring, *key; | 406 | key_ref_t keyring_ref, key_ref; |
405 | long ret; | 407 | long ret; |
406 | 408 | ||
407 | keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); | 409 | keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); |
408 | if (IS_ERR(keyring)) { | 410 | if (IS_ERR(keyring_ref)) { |
409 | ret = PTR_ERR(keyring); | 411 | ret = PTR_ERR(keyring_ref); |
410 | goto error; | 412 | goto error; |
411 | } | 413 | } |
412 | 414 | ||
413 | key = lookup_user_key(NULL, id, 1, 0, KEY_LINK); | 415 | key_ref = lookup_user_key(NULL, id, 1, 0, KEY_LINK); |
414 | if (IS_ERR(key)) { | 416 | if (IS_ERR(key_ref)) { |
415 | ret = PTR_ERR(key); | 417 | ret = PTR_ERR(key_ref); |
416 | goto error2; | 418 | goto error2; |
417 | } | 419 | } |
418 | 420 | ||
419 | ret = key_link(keyring, key); | 421 | ret = key_link(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref)); |
420 | 422 | ||
421 | key_put(key); | 423 | key_ref_put(key_ref); |
422 | error2: | 424 | error2: |
423 | key_put(keyring); | 425 | key_ref_put(keyring_ref); |
424 | error: | 426 | error: |
425 | return ret; | 427 | return ret; |
426 | 428 | ||
@@ -435,26 +437,26 @@ long keyctl_keyring_link(key_serial_t id, key_serial_t ringid) | |||
435 | */ | 437 | */ |
436 | long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid) | 438 | long keyctl_keyring_unlink(key_serial_t id, key_serial_t ringid) |
437 | { | 439 | { |
438 | struct key *keyring, *key; | 440 | key_ref_t keyring_ref, key_ref; |
439 | long ret; | 441 | long ret; |
440 | 442 | ||
441 | keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE); | 443 | keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_WRITE); |
442 | if (IS_ERR(keyring)) { | 444 | if (IS_ERR(keyring_ref)) { |
443 | ret = PTR_ERR(keyring); | 445 | ret = PTR_ERR(keyring_ref); |
444 | goto error; | 446 | goto error; |
445 | } | 447 | } |
446 | 448 | ||
447 | key = lookup_user_key(NULL, id, 0, 0, 0); | 449 | key_ref = lookup_user_key(NULL, id, 0, 0, 0); |
448 | if (IS_ERR(key)) { | 450 | if (IS_ERR(key_ref)) { |
449 | ret = PTR_ERR(key); | 451 | ret = PTR_ERR(key_ref); |
450 | goto error2; | 452 | goto error2; |
451 | } | 453 | } |
452 | 454 | ||
453 | ret = key_unlink(keyring, key); | 455 | ret = key_unlink(key_ref_to_ptr(keyring_ref), key_ref_to_ptr(key_ref)); |
454 | 456 | ||
455 | key_put(key); | 457 | key_ref_put(key_ref); |
456 | error2: | 458 | error2: |
457 | key_put(keyring); | 459 | key_ref_put(keyring_ref); |
458 | error: | 460 | error: |
459 | return ret; | 461 | return ret; |
460 | 462 | ||
@@ -476,24 +478,26 @@ long keyctl_describe_key(key_serial_t keyid, | |||
476 | size_t buflen) | 478 | size_t buflen) |
477 | { | 479 | { |
478 | struct key *key, *instkey; | 480 | struct key *key, *instkey; |
481 | key_ref_t key_ref; | ||
479 | char *tmpbuf; | 482 | char *tmpbuf; |
480 | long ret; | 483 | long ret; |
481 | 484 | ||
482 | key = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); | 485 | key_ref = lookup_user_key(NULL, keyid, 0, 1, KEY_VIEW); |
483 | if (IS_ERR(key)) { | 486 | if (IS_ERR(key_ref)) { |
484 | /* viewing a key under construction is permitted if we have the | 487 | /* viewing a key under construction is permitted if we have the |
485 | * authorisation token handy */ | 488 | * authorisation token handy */ |
486 | if (PTR_ERR(key) == -EACCES) { | 489 | if (PTR_ERR(key_ref) == -EACCES) { |
487 | instkey = key_get_instantiation_authkey(keyid); | 490 | instkey = key_get_instantiation_authkey(keyid); |
488 | if (!IS_ERR(instkey)) { | 491 | if (!IS_ERR(instkey)) { |
489 | key_put(instkey); | 492 | key_put(instkey); |
490 | key = lookup_user_key(NULL, keyid, 0, 1, 0); | 493 | key_ref = lookup_user_key(NULL, keyid, |
491 | if (!IS_ERR(key)) | 494 | 0, 1, 0); |
495 | if (!IS_ERR(key_ref)) | ||
492 | goto okay; | 496 | goto okay; |
493 | } | 497 | } |
494 | } | 498 | } |
495 | 499 | ||
496 | ret = PTR_ERR(key); | 500 | ret = PTR_ERR(key_ref); |
497 | goto error; | 501 | goto error; |
498 | } | 502 | } |
499 | 503 | ||
@@ -504,13 +508,16 @@ okay: | |||
504 | if (!tmpbuf) | 508 | if (!tmpbuf) |
505 | goto error2; | 509 | goto error2; |
506 | 510 | ||
511 | key = key_ref_to_ptr(key_ref); | ||
512 | |||
507 | ret = snprintf(tmpbuf, PAGE_SIZE - 1, | 513 | ret = snprintf(tmpbuf, PAGE_SIZE - 1, |
508 | "%s;%d;%d;%06x;%s", | 514 | "%s;%d;%d;%08x;%s", |
509 | key->type->name, | 515 | key_ref_to_ptr(key_ref)->type->name, |
510 | key->uid, | 516 | key_ref_to_ptr(key_ref)->uid, |
511 | key->gid, | 517 | key_ref_to_ptr(key_ref)->gid, |
512 | key->perm, | 518 | key_ref_to_ptr(key_ref)->perm, |
513 | key->description ? key->description :"" | 519 | key_ref_to_ptr(key_ref)->description ? |
520 | key_ref_to_ptr(key_ref)->description : "" | ||
514 | ); | 521 | ); |
515 | 522 | ||
516 | /* include a NUL char at the end of the data */ | 523 | /* include a NUL char at the end of the data */ |
@@ -530,7 +537,7 @@ okay: | |||
530 | 537 | ||
531 | kfree(tmpbuf); | 538 | kfree(tmpbuf); |
532 | error2: | 539 | error2: |
533 | key_put(key); | 540 | key_ref_put(key_ref); |
534 | error: | 541 | error: |
535 | return ret; | 542 | return ret; |
536 | 543 | ||
@@ -552,7 +559,7 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
552 | key_serial_t destringid) | 559 | key_serial_t destringid) |
553 | { | 560 | { |
554 | struct key_type *ktype; | 561 | struct key_type *ktype; |
555 | struct key *keyring, *key, *dest; | 562 | key_ref_t keyring_ref, key_ref, dest_ref; |
556 | char type[32], *description; | 563 | char type[32], *description; |
557 | long dlen, ret; | 564 | long dlen, ret; |
558 | 565 | ||
@@ -581,18 +588,18 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
581 | goto error2; | 588 | goto error2; |
582 | 589 | ||
583 | /* get the keyring at which to begin the search */ | 590 | /* get the keyring at which to begin the search */ |
584 | keyring = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); | 591 | keyring_ref = lookup_user_key(NULL, ringid, 0, 0, KEY_SEARCH); |
585 | if (IS_ERR(keyring)) { | 592 | if (IS_ERR(keyring_ref)) { |
586 | ret = PTR_ERR(keyring); | 593 | ret = PTR_ERR(keyring_ref); |
587 | goto error2; | 594 | goto error2; |
588 | } | 595 | } |
589 | 596 | ||
590 | /* get the destination keyring if specified */ | 597 | /* get the destination keyring if specified */ |
591 | dest = NULL; | 598 | dest_ref = NULL; |
592 | if (destringid) { | 599 | if (destringid) { |
593 | dest = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); | 600 | dest_ref = lookup_user_key(NULL, destringid, 1, 0, KEY_WRITE); |
594 | if (IS_ERR(dest)) { | 601 | if (IS_ERR(dest_ref)) { |
595 | ret = PTR_ERR(dest); | 602 | ret = PTR_ERR(dest_ref); |
596 | goto error3; | 603 | goto error3; |
597 | } | 604 | } |
598 | } | 605 | } |
@@ -605,9 +612,9 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
605 | } | 612 | } |
606 | 613 | ||
607 | /* do the search */ | 614 | /* do the search */ |
608 | key = keyring_search(keyring, ktype, description); | 615 | key_ref = keyring_search(keyring_ref, ktype, description); |
609 | if (IS_ERR(key)) { | 616 | if (IS_ERR(key_ref)) { |
610 | ret = PTR_ERR(key); | 617 | ret = PTR_ERR(key_ref); |
611 | 618 | ||
612 | /* treat lack or presence of a negative key the same */ | 619 | /* treat lack or presence of a negative key the same */ |
613 | if (ret == -EAGAIN) | 620 | if (ret == -EAGAIN) |
@@ -616,26 +623,26 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
616 | } | 623 | } |
617 | 624 | ||
618 | /* link the resulting key to the destination keyring if we can */ | 625 | /* link the resulting key to the destination keyring if we can */ |
619 | if (dest) { | 626 | if (dest_ref) { |
620 | ret = -EACCES; | 627 | ret = -EACCES; |
621 | if (!key_permission(key, KEY_LINK)) | 628 | if (!key_permission(key_ref, KEY_LINK)) |
622 | goto error6; | 629 | goto error6; |
623 | 630 | ||
624 | ret = key_link(dest, key); | 631 | ret = key_link(key_ref_to_ptr(dest_ref), key_ref_to_ptr(key_ref)); |
625 | if (ret < 0) | 632 | if (ret < 0) |
626 | goto error6; | 633 | goto error6; |
627 | } | 634 | } |
628 | 635 | ||
629 | ret = key->serial; | 636 | ret = key_ref_to_ptr(key_ref)->serial; |
630 | 637 | ||
631 | error6: | 638 | error6: |
632 | key_put(key); | 639 | key_ref_put(key_ref); |
633 | error5: | 640 | error5: |
634 | key_type_put(ktype); | 641 | key_type_put(ktype); |
635 | error4: | 642 | error4: |
636 | key_put(dest); | 643 | key_ref_put(dest_ref); |
637 | error3: | 644 | error3: |
638 | key_put(keyring); | 645 | key_ref_put(keyring_ref); |
639 | error2: | 646 | error2: |
640 | kfree(description); | 647 | kfree(description); |
641 | error: | 648 | error: |
@@ -645,16 +652,6 @@ long keyctl_keyring_search(key_serial_t ringid, | |||
645 | 652 | ||
646 | /*****************************************************************************/ | 653 | /*****************************************************************************/ |
647 | /* | 654 | /* |
648 | * see if the key we're looking at is the target key | ||
649 | */ | ||
650 | static int keyctl_read_key_same(const struct key *key, const void *target) | ||
651 | { | ||
652 | return key == target; | ||
653 | |||
654 | } /* end keyctl_read_key_same() */ | ||
655 | |||
656 | /*****************************************************************************/ | ||
657 | /* | ||
658 | * read a user key's payload | 655 | * read a user key's payload |
659 | * - the keyring must be readable or the key must be searchable from the | 656 | * - the keyring must be readable or the key must be searchable from the |
660 | * process's keyrings | 657 | * process's keyrings |
@@ -665,38 +662,33 @@ static int keyctl_read_key_same(const struct key *key, const void *target) | |||
665 | */ | 662 | */ |
666 | long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) | 663 | long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) |
667 | { | 664 | { |
668 | struct key *key, *skey; | 665 | struct key *key; |
666 | key_ref_t key_ref; | ||
669 | long ret; | 667 | long ret; |
670 | 668 | ||
671 | /* find the key first */ | 669 | /* find the key first */ |
672 | key = lookup_user_key(NULL, keyid, 0, 0, 0); | 670 | key_ref = lookup_user_key(NULL, keyid, 0, 0, 0); |
673 | if (!IS_ERR(key)) { | 671 | if (IS_ERR(key_ref)) { |
674 | /* see if we can read it directly */ | 672 | ret = -ENOKEY; |
675 | if (key_permission(key, KEY_READ)) | 673 | goto error; |
676 | goto can_read_key; | ||
677 | |||
678 | /* we can't; see if it's searchable from this process's | ||
679 | * keyrings | ||
680 | * - we automatically take account of the fact that it may be | ||
681 | * dangling off an instantiation key | ||
682 | */ | ||
683 | skey = search_process_keyrings(key->type, key, | ||
684 | keyctl_read_key_same, current); | ||
685 | if (!IS_ERR(skey)) | ||
686 | goto can_read_key2; | ||
687 | |||
688 | ret = PTR_ERR(skey); | ||
689 | if (ret == -EAGAIN) | ||
690 | ret = -EACCES; | ||
691 | goto error2; | ||
692 | } | 674 | } |
693 | 675 | ||
694 | ret = -ENOKEY; | 676 | key = key_ref_to_ptr(key_ref); |
695 | goto error; | 677 | |
678 | /* see if we can read it directly */ | ||
679 | if (key_permission(key_ref, KEY_READ)) | ||
680 | goto can_read_key; | ||
681 | |||
682 | /* we can't; see if it's searchable from this process's keyrings | ||
683 | * - we automatically take account of the fact that it may be | ||
684 | * dangling off an instantiation key | ||
685 | */ | ||
686 | if (!is_key_possessed(key_ref)) { | ||
687 | ret = -EACCES; | ||
688 | goto error2; | ||
689 | } | ||
696 | 690 | ||
697 | /* the key is probably readable - now try to read it */ | 691 | /* the key is probably readable - now try to read it */ |
698 | can_read_key2: | ||
699 | key_put(skey); | ||
700 | can_read_key: | 692 | can_read_key: |
701 | ret = key_validate(key); | 693 | ret = key_validate(key); |
702 | if (ret == 0) { | 694 | if (ret == 0) { |
@@ -727,18 +719,21 @@ long keyctl_read_key(key_serial_t keyid, char __user *buffer, size_t buflen) | |||
727 | long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) | 719 | long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) |
728 | { | 720 | { |
729 | struct key *key; | 721 | struct key *key; |
722 | key_ref_t key_ref; | ||
730 | long ret; | 723 | long ret; |
731 | 724 | ||
732 | ret = 0; | 725 | ret = 0; |
733 | if (uid == (uid_t) -1 && gid == (gid_t) -1) | 726 | if (uid == (uid_t) -1 && gid == (gid_t) -1) |
734 | goto error; | 727 | goto error; |
735 | 728 | ||
736 | key = lookup_user_key(NULL, id, 1, 1, 0); | 729 | key_ref = lookup_user_key(NULL, id, 1, 1, 0); |
737 | if (IS_ERR(key)) { | 730 | if (IS_ERR(key_ref)) { |
738 | ret = PTR_ERR(key); | 731 | ret = PTR_ERR(key_ref); |
739 | goto error; | 732 | goto error; |
740 | } | 733 | } |
741 | 734 | ||
735 | key = key_ref_to_ptr(key_ref); | ||
736 | |||
742 | /* make the changes with the locks held to prevent chown/chown races */ | 737 | /* make the changes with the locks held to prevent chown/chown races */ |
743 | ret = -EACCES; | 738 | ret = -EACCES; |
744 | down_write(&key->sem); | 739 | down_write(&key->sem); |
@@ -784,18 +779,21 @@ long keyctl_chown_key(key_serial_t id, uid_t uid, gid_t gid) | |||
784 | long keyctl_setperm_key(key_serial_t id, key_perm_t perm) | 779 | long keyctl_setperm_key(key_serial_t id, key_perm_t perm) |
785 | { | 780 | { |
786 | struct key *key; | 781 | struct key *key; |
782 | key_ref_t key_ref; | ||
787 | long ret; | 783 | long ret; |
788 | 784 | ||
789 | ret = -EINVAL; | 785 | ret = -EINVAL; |
790 | if (perm & ~(KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) | 786 | if (perm & ~(KEY_POS_ALL | KEY_USR_ALL | KEY_GRP_ALL | KEY_OTH_ALL)) |
791 | goto error; | 787 | goto error; |
792 | 788 | ||
793 | key = lookup_user_key(NULL, id, 1, 1, 0); | 789 | key_ref = lookup_user_key(NULL, id, 1, 1, 0); |
794 | if (IS_ERR(key)) { | 790 | if (IS_ERR(key_ref)) { |
795 | ret = PTR_ERR(key); | 791 | ret = PTR_ERR(key_ref); |
796 | goto error; | 792 | goto error; |
797 | } | 793 | } |
798 | 794 | ||
795 | key = key_ref_to_ptr(key_ref); | ||
796 | |||
799 | /* make the changes with the locks held to prevent chown/chmod races */ | 797 | /* make the changes with the locks held to prevent chown/chmod races */ |
800 | ret = -EACCES; | 798 | ret = -EACCES; |
801 | down_write(&key->sem); | 799 | down_write(&key->sem); |
@@ -824,7 +822,8 @@ long keyctl_instantiate_key(key_serial_t id, | |||
824 | key_serial_t ringid) | 822 | key_serial_t ringid) |
825 | { | 823 | { |
826 | struct request_key_auth *rka; | 824 | struct request_key_auth *rka; |
827 | struct key *instkey, *keyring; | 825 | struct key *instkey; |
826 | key_ref_t keyring_ref; | ||
828 | void *payload; | 827 | void *payload; |
829 | long ret; | 828 | long ret; |
830 | 829 | ||
@@ -857,21 +856,21 @@ long keyctl_instantiate_key(key_serial_t id, | |||
857 | 856 | ||
858 | /* find the destination keyring amongst those belonging to the | 857 | /* find the destination keyring amongst those belonging to the |
859 | * requesting task */ | 858 | * requesting task */ |
860 | keyring = NULL; | 859 | keyring_ref = NULL; |
861 | if (ringid) { | 860 | if (ringid) { |
862 | keyring = lookup_user_key(rka->context, ringid, 1, 0, | 861 | keyring_ref = lookup_user_key(rka->context, ringid, 1, 0, |
863 | KEY_WRITE); | 862 | KEY_WRITE); |
864 | if (IS_ERR(keyring)) { | 863 | if (IS_ERR(keyring_ref)) { |
865 | ret = PTR_ERR(keyring); | 864 | ret = PTR_ERR(keyring_ref); |
866 | goto error3; | 865 | goto error3; |
867 | } | 866 | } |
868 | } | 867 | } |
869 | 868 | ||
870 | /* instantiate the key and link it into a keyring */ | 869 | /* instantiate the key and link it into a keyring */ |
871 | ret = key_instantiate_and_link(rka->target_key, payload, plen, | 870 | ret = key_instantiate_and_link(rka->target_key, payload, plen, |
872 | keyring, instkey); | 871 | key_ref_to_ptr(keyring_ref), instkey); |
873 | 872 | ||
874 | key_put(keyring); | 873 | key_ref_put(keyring_ref); |
875 | error3: | 874 | error3: |
876 | key_put(instkey); | 875 | key_put(instkey); |
877 | error2: | 876 | error2: |
@@ -889,7 +888,8 @@ long keyctl_instantiate_key(key_serial_t id, | |||
889 | long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) | 888 | long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) |
890 | { | 889 | { |
891 | struct request_key_auth *rka; | 890 | struct request_key_auth *rka; |
892 | struct key *instkey, *keyring; | 891 | struct key *instkey; |
892 | key_ref_t keyring_ref; | ||
893 | long ret; | 893 | long ret; |
894 | 894 | ||
895 | /* find the instantiation authorisation key */ | 895 | /* find the instantiation authorisation key */ |
@@ -903,19 +903,20 @@ long keyctl_negate_key(key_serial_t id, unsigned timeout, key_serial_t ringid) | |||
903 | 903 | ||
904 | /* find the destination keyring if present (which must also be | 904 | /* find the destination keyring if present (which must also be |
905 | * writable) */ | 905 | * writable) */ |
906 | keyring = NULL; | 906 | keyring_ref = NULL; |
907 | if (ringid) { | 907 | if (ringid) { |
908 | keyring = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); | 908 | keyring_ref = lookup_user_key(NULL, ringid, 1, 0, KEY_WRITE); |
909 | if (IS_ERR(keyring)) { | 909 | if (IS_ERR(keyring_ref)) { |
910 | ret = PTR_ERR(keyring); | 910 | ret = PTR_ERR(keyring_ref); |
911 | goto error2; | 911 | goto error2; |
912 | } | 912 | } |
913 | } | 913 | } |
914 | 914 | ||
915 | /* instantiate the key and link it into a keyring */ | 915 | /* instantiate the key and link it into a keyring */ |
916 | ret = key_negate_and_link(rka->target_key, timeout, keyring, instkey); | 916 | ret = key_negate_and_link(rka->target_key, timeout, |
917 | key_ref_to_ptr(keyring_ref), instkey); | ||
917 | 918 | ||
918 | key_put(keyring); | 919 | key_ref_put(keyring_ref); |
919 | error2: | 920 | error2: |
920 | key_put(instkey); | 921 | key_put(instkey); |
921 | error: | 922 | error: |
diff --git a/security/keys/keyring.c b/security/keys/keyring.c index 9c208c756df8..0639396dd441 100644 --- a/security/keys/keyring.c +++ b/security/keys/keyring.c | |||
@@ -309,7 +309,7 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, | |||
309 | int ret; | 309 | int ret; |
310 | 310 | ||
311 | keyring = key_alloc(&key_type_keyring, description, | 311 | keyring = key_alloc(&key_type_keyring, description, |
312 | uid, gid, KEY_USR_ALL, not_in_quota); | 312 | uid, gid, KEY_POS_ALL | KEY_USR_ALL, not_in_quota); |
313 | 313 | ||
314 | if (!IS_ERR(keyring)) { | 314 | if (!IS_ERR(keyring)) { |
315 | ret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL); | 315 | ret = key_instantiate_and_link(keyring, NULL, 0, dest, NULL); |
@@ -333,12 +333,13 @@ struct key *keyring_alloc(const char *description, uid_t uid, gid_t gid, | |||
333 | * - we rely on RCU to prevent the keyring lists from disappearing on us | 333 | * - we rely on RCU to prevent the keyring lists from disappearing on us |
334 | * - we return -EAGAIN if we didn't find any matching key | 334 | * - we return -EAGAIN if we didn't find any matching key |
335 | * - we return -ENOKEY if we only found negative matching keys | 335 | * - we return -ENOKEY if we only found negative matching keys |
336 | * - we propagate the possession attribute from the keyring ref to the key ref | ||
336 | */ | 337 | */ |
337 | struct key *keyring_search_aux(struct key *keyring, | 338 | key_ref_t keyring_search_aux(key_ref_t keyring_ref, |
338 | struct task_struct *context, | 339 | struct task_struct *context, |
339 | struct key_type *type, | 340 | struct key_type *type, |
340 | const void *description, | 341 | const void *description, |
341 | key_match_func_t match) | 342 | key_match_func_t match) |
342 | { | 343 | { |
343 | struct { | 344 | struct { |
344 | struct keyring_list *keylist; | 345 | struct keyring_list *keylist; |
@@ -347,29 +348,33 @@ struct key *keyring_search_aux(struct key *keyring, | |||
347 | 348 | ||
348 | struct keyring_list *keylist; | 349 | struct keyring_list *keylist; |
349 | struct timespec now; | 350 | struct timespec now; |
350 | struct key *key; | 351 | unsigned long possessed; |
352 | struct key *keyring, *key; | ||
353 | key_ref_t key_ref; | ||
351 | long err; | 354 | long err; |
352 | int sp, kix; | 355 | int sp, kix; |
353 | 356 | ||
357 | keyring = key_ref_to_ptr(keyring_ref); | ||
358 | possessed = is_key_possessed(keyring_ref); | ||
354 | key_check(keyring); | 359 | key_check(keyring); |
355 | 360 | ||
356 | rcu_read_lock(); | ||
357 | |||
358 | /* top keyring must have search permission to begin the search */ | 361 | /* top keyring must have search permission to begin the search */ |
359 | key = ERR_PTR(-EACCES); | 362 | key_ref = ERR_PTR(-EACCES); |
360 | if (!key_task_permission(keyring, context, KEY_SEARCH)) | 363 | if (!key_task_permission(keyring_ref, context, KEY_SEARCH)) |
361 | goto error; | 364 | goto error; |
362 | 365 | ||
363 | key = ERR_PTR(-ENOTDIR); | 366 | key_ref = ERR_PTR(-ENOTDIR); |
364 | if (keyring->type != &key_type_keyring) | 367 | if (keyring->type != &key_type_keyring) |
365 | goto error; | 368 | goto error; |
366 | 369 | ||
370 | rcu_read_lock(); | ||
371 | |||
367 | now = current_kernel_time(); | 372 | now = current_kernel_time(); |
368 | err = -EAGAIN; | 373 | err = -EAGAIN; |
369 | sp = 0; | 374 | sp = 0; |
370 | 375 | ||
371 | /* start processing a new keyring */ | 376 | /* start processing a new keyring */ |
372 | descend: | 377 | descend: |
373 | if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) | 378 | if (test_bit(KEY_FLAG_REVOKED, &keyring->flags)) |
374 | goto not_this_keyring; | 379 | goto not_this_keyring; |
375 | 380 | ||
@@ -397,7 +402,8 @@ struct key *keyring_search_aux(struct key *keyring, | |||
397 | continue; | 402 | continue; |
398 | 403 | ||
399 | /* key must have search permissions */ | 404 | /* key must have search permissions */ |
400 | if (!key_task_permission(key, context, KEY_SEARCH)) | 405 | if (!key_task_permission(make_key_ref(key, possessed), |
406 | context, KEY_SEARCH)) | ||
401 | continue; | 407 | continue; |
402 | 408 | ||
403 | /* we set a different error code if we find a negative key */ | 409 | /* we set a different error code if we find a negative key */ |
@@ -411,7 +417,7 @@ struct key *keyring_search_aux(struct key *keyring, | |||
411 | 417 | ||
412 | /* search through the keyrings nested in this one */ | 418 | /* search through the keyrings nested in this one */ |
413 | kix = 0; | 419 | kix = 0; |
414 | ascend: | 420 | ascend: |
415 | for (; kix < keylist->nkeys; kix++) { | 421 | for (; kix < keylist->nkeys; kix++) { |
416 | key = keylist->keys[kix]; | 422 | key = keylist->keys[kix]; |
417 | if (key->type != &key_type_keyring) | 423 | if (key->type != &key_type_keyring) |
@@ -423,7 +429,8 @@ struct key *keyring_search_aux(struct key *keyring, | |||
423 | if (sp >= KEYRING_SEARCH_MAX_DEPTH) | 429 | if (sp >= KEYRING_SEARCH_MAX_DEPTH) |
424 | continue; | 430 | continue; |
425 | 431 | ||
426 | if (!key_task_permission(key, context, KEY_SEARCH)) | 432 | if (!key_task_permission(make_key_ref(key, possessed), |
433 | context, KEY_SEARCH)) | ||
427 | continue; | 434 | continue; |
428 | 435 | ||
429 | /* stack the current position */ | 436 | /* stack the current position */ |
@@ -438,7 +445,7 @@ struct key *keyring_search_aux(struct key *keyring, | |||
438 | 445 | ||
439 | /* the keyring we're looking at was disqualified or didn't contain a | 446 | /* the keyring we're looking at was disqualified or didn't contain a |
440 | * matching key */ | 447 | * matching key */ |
441 | not_this_keyring: | 448 | not_this_keyring: |
442 | if (sp > 0) { | 449 | if (sp > 0) { |
443 | /* resume the processing of a keyring higher up in the tree */ | 450 | /* resume the processing of a keyring higher up in the tree */ |
444 | sp--; | 451 | sp--; |
@@ -447,16 +454,18 @@ struct key *keyring_search_aux(struct key *keyring, | |||
447 | goto ascend; | 454 | goto ascend; |
448 | } | 455 | } |
449 | 456 | ||
450 | key = ERR_PTR(err); | 457 | key_ref = ERR_PTR(err); |
451 | goto error; | 458 | goto error_2; |
452 | 459 | ||
453 | /* we found a viable match */ | 460 | /* we found a viable match */ |
454 | found: | 461 | found: |
455 | atomic_inc(&key->usage); | 462 | atomic_inc(&key->usage); |
456 | key_check(key); | 463 | key_check(key); |
457 | error: | 464 | key_ref = make_key_ref(key, possessed); |
465 | error_2: | ||
458 | rcu_read_unlock(); | 466 | rcu_read_unlock(); |
459 | return key; | 467 | error: |
468 | return key_ref; | ||
460 | 469 | ||
461 | } /* end keyring_search_aux() */ | 470 | } /* end keyring_search_aux() */ |
462 | 471 | ||
@@ -469,9 +478,9 @@ struct key *keyring_search_aux(struct key *keyring, | |||
469 | * - we return -EAGAIN if we didn't find any matching key | 478 | * - we return -EAGAIN if we didn't find any matching key |
470 | * - we return -ENOKEY if we only found negative matching keys | 479 | * - we return -ENOKEY if we only found negative matching keys |
471 | */ | 480 | */ |
472 | struct key *keyring_search(struct key *keyring, | 481 | key_ref_t keyring_search(key_ref_t keyring, |
473 | struct key_type *type, | 482 | struct key_type *type, |
474 | const char *description) | 483 | const char *description) |
475 | { | 484 | { |
476 | if (!type->match) | 485 | if (!type->match) |
477 | return ERR_PTR(-ENOKEY); | 486 | return ERR_PTR(-ENOKEY); |
@@ -488,15 +497,19 @@ EXPORT_SYMBOL(keyring_search); | |||
488 | * search the given keyring only (no recursion) | 497 | * search the given keyring only (no recursion) |
489 | * - keyring must be locked by caller | 498 | * - keyring must be locked by caller |
490 | */ | 499 | */ |
491 | struct key *__keyring_search_one(struct key *keyring, | 500 | key_ref_t __keyring_search_one(key_ref_t keyring_ref, |
492 | const struct key_type *ktype, | 501 | const struct key_type *ktype, |
493 | const char *description, | 502 | const char *description, |
494 | key_perm_t perm) | 503 | key_perm_t perm) |
495 | { | 504 | { |
496 | struct keyring_list *klist; | 505 | struct keyring_list *klist; |
497 | struct key *key; | 506 | unsigned long possessed; |
507 | struct key *keyring, *key; | ||
498 | int loop; | 508 | int loop; |
499 | 509 | ||
510 | keyring = key_ref_to_ptr(keyring_ref); | ||
511 | possessed = is_key_possessed(keyring_ref); | ||
512 | |||
500 | rcu_read_lock(); | 513 | rcu_read_lock(); |
501 | 514 | ||
502 | klist = rcu_dereference(keyring->payload.subscriptions); | 515 | klist = rcu_dereference(keyring->payload.subscriptions); |
@@ -507,21 +520,21 @@ struct key *__keyring_search_one(struct key *keyring, | |||
507 | if (key->type == ktype && | 520 | if (key->type == ktype && |
508 | (!key->type->match || | 521 | (!key->type->match || |
509 | key->type->match(key, description)) && | 522 | key->type->match(key, description)) && |
510 | key_permission(key, perm) && | 523 | key_permission(make_key_ref(key, possessed), |
524 | perm) && | ||
511 | !test_bit(KEY_FLAG_REVOKED, &key->flags) | 525 | !test_bit(KEY_FLAG_REVOKED, &key->flags) |
512 | ) | 526 | ) |
513 | goto found; | 527 | goto found; |
514 | } | 528 | } |
515 | } | 529 | } |
516 | 530 | ||
517 | key = ERR_PTR(-ENOKEY); | 531 | rcu_read_unlock(); |
518 | goto error; | 532 | return ERR_PTR(-ENOKEY); |
519 | 533 | ||
520 | found: | 534 | found: |
521 | atomic_inc(&key->usage); | 535 | atomic_inc(&key->usage); |
522 | error: | ||
523 | rcu_read_unlock(); | 536 | rcu_read_unlock(); |
524 | return key; | 537 | return make_key_ref(key, possessed); |
525 | 538 | ||
526 | } /* end __keyring_search_one() */ | 539 | } /* end __keyring_search_one() */ |
527 | 540 | ||
@@ -603,7 +616,8 @@ struct key *find_keyring_by_name(const char *name, key_serial_t bound) | |||
603 | if (strcmp(keyring->description, name) != 0) | 616 | if (strcmp(keyring->description, name) != 0) |
604 | continue; | 617 | continue; |
605 | 618 | ||
606 | if (!key_permission(keyring, KEY_SEARCH)) | 619 | if (!key_permission(make_key_ref(keyring, 0), |
620 | KEY_SEARCH)) | ||
607 | continue; | 621 | continue; |
608 | 622 | ||
609 | /* found a potential candidate, but we still need to | 623 | /* found a potential candidate, but we still need to |
diff --git a/security/keys/proc.c b/security/keys/proc.c index c55cf1fd0826..12b750e51fbf 100644 --- a/security/keys/proc.c +++ b/security/keys/proc.c | |||
@@ -167,7 +167,7 @@ static int proc_keys_show(struct seq_file *m, void *v) | |||
167 | #define showflag(KEY, LETTER, FLAG) \ | 167 | #define showflag(KEY, LETTER, FLAG) \ |
168 | (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-') | 168 | (test_bit(FLAG, &(KEY)->flags) ? LETTER : '-') |
169 | 169 | ||
170 | seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %06x %5d %5d %-9.9s ", | 170 | seq_printf(m, "%08x %c%c%c%c%c%c %5d %4s %08x %5d %5d %-9.9s ", |
171 | key->serial, | 171 | key->serial, |
172 | showflag(key, 'I', KEY_FLAG_INSTANTIATED), | 172 | showflag(key, 'I', KEY_FLAG_INSTANTIATED), |
173 | showflag(key, 'R', KEY_FLAG_REVOKED), | 173 | showflag(key, 'R', KEY_FLAG_REVOKED), |
diff --git a/security/keys/process_keys.c b/security/keys/process_keys.c index c089f78fb94e..d42d2158ce13 100644 --- a/security/keys/process_keys.c +++ b/security/keys/process_keys.c | |||
@@ -39,7 +39,7 @@ struct key root_user_keyring = { | |||
39 | .type = &key_type_keyring, | 39 | .type = &key_type_keyring, |
40 | .user = &root_key_user, | 40 | .user = &root_key_user, |
41 | .sem = __RWSEM_INITIALIZER(root_user_keyring.sem), | 41 | .sem = __RWSEM_INITIALIZER(root_user_keyring.sem), |
42 | .perm = KEY_USR_ALL, | 42 | .perm = KEY_POS_ALL | KEY_USR_ALL, |
43 | .flags = 1 << KEY_FLAG_INSTANTIATED, | 43 | .flags = 1 << KEY_FLAG_INSTANTIATED, |
44 | .description = "_uid.0", | 44 | .description = "_uid.0", |
45 | #ifdef KEY_DEBUGGING | 45 | #ifdef KEY_DEBUGGING |
@@ -54,7 +54,7 @@ struct key root_session_keyring = { | |||
54 | .type = &key_type_keyring, | 54 | .type = &key_type_keyring, |
55 | .user = &root_key_user, | 55 | .user = &root_key_user, |
56 | .sem = __RWSEM_INITIALIZER(root_session_keyring.sem), | 56 | .sem = __RWSEM_INITIALIZER(root_session_keyring.sem), |
57 | .perm = KEY_USR_ALL, | 57 | .perm = KEY_POS_ALL | KEY_USR_ALL, |
58 | .flags = 1 << KEY_FLAG_INSTANTIATED, | 58 | .flags = 1 << KEY_FLAG_INSTANTIATED, |
59 | .description = "_uid_ses.0", | 59 | .description = "_uid_ses.0", |
60 | #ifdef KEY_DEBUGGING | 60 | #ifdef KEY_DEBUGGING |
@@ -98,7 +98,7 @@ int alloc_uid_keyring(struct user_struct *user) | |||
98 | user->session_keyring = session_keyring; | 98 | user->session_keyring = session_keyring; |
99 | ret = 0; | 99 | ret = 0; |
100 | 100 | ||
101 | error: | 101 | error: |
102 | return ret; | 102 | return ret; |
103 | 103 | ||
104 | } /* end alloc_uid_keyring() */ | 104 | } /* end alloc_uid_keyring() */ |
@@ -156,7 +156,7 @@ int install_thread_keyring(struct task_struct *tsk) | |||
156 | ret = 0; | 156 | ret = 0; |
157 | 157 | ||
158 | key_put(old); | 158 | key_put(old); |
159 | error: | 159 | error: |
160 | return ret; | 160 | return ret; |
161 | 161 | ||
162 | } /* end install_thread_keyring() */ | 162 | } /* end install_thread_keyring() */ |
@@ -193,7 +193,7 @@ int install_process_keyring(struct task_struct *tsk) | |||
193 | } | 193 | } |
194 | 194 | ||
195 | ret = 0; | 195 | ret = 0; |
196 | error: | 196 | error: |
197 | return ret; | 197 | return ret; |
198 | 198 | ||
199 | } /* end install_process_keyring() */ | 199 | } /* end install_process_keyring() */ |
@@ -236,7 +236,7 @@ static int install_session_keyring(struct task_struct *tsk, | |||
236 | /* we're using RCU on the pointer */ | 236 | /* we're using RCU on the pointer */ |
237 | synchronize_rcu(); | 237 | synchronize_rcu(); |
238 | key_put(old); | 238 | key_put(old); |
239 | error: | 239 | error: |
240 | return ret; | 240 | return ret; |
241 | 241 | ||
242 | } /* end install_session_keyring() */ | 242 | } /* end install_session_keyring() */ |
@@ -376,13 +376,13 @@ void key_fsgid_changed(struct task_struct *tsk) | |||
376 | * - we return -EAGAIN if we didn't find any matching key | 376 | * - we return -EAGAIN if we didn't find any matching key |
377 | * - we return -ENOKEY if we found only negative matching keys | 377 | * - we return -ENOKEY if we found only negative matching keys |
378 | */ | 378 | */ |
379 | struct key *search_process_keyrings(struct key_type *type, | 379 | key_ref_t search_process_keyrings(struct key_type *type, |
380 | const void *description, | 380 | const void *description, |
381 | key_match_func_t match, | 381 | key_match_func_t match, |
382 | struct task_struct *context) | 382 | struct task_struct *context) |
383 | { | 383 | { |
384 | struct request_key_auth *rka; | 384 | struct request_key_auth *rka; |
385 | struct key *key, *ret, *err, *instkey; | 385 | key_ref_t key_ref, ret, err, instkey_ref; |
386 | 386 | ||
387 | /* we want to return -EAGAIN or -ENOKEY if any of the keyrings were | 387 | /* we want to return -EAGAIN or -ENOKEY if any of the keyrings were |
388 | * searchable, but we failed to find a key or we found a negative key; | 388 | * searchable, but we failed to find a key or we found a negative key; |
@@ -391,46 +391,48 @@ struct key *search_process_keyrings(struct key_type *type, | |||
391 | * | 391 | * |
392 | * in terms of priority: success > -ENOKEY > -EAGAIN > other error | 392 | * in terms of priority: success > -ENOKEY > -EAGAIN > other error |
393 | */ | 393 | */ |
394 | key = NULL; | 394 | key_ref = NULL; |
395 | ret = NULL; | 395 | ret = NULL; |
396 | err = ERR_PTR(-EAGAIN); | 396 | err = ERR_PTR(-EAGAIN); |
397 | 397 | ||
398 | /* search the thread keyring first */ | 398 | /* search the thread keyring first */ |
399 | if (context->thread_keyring) { | 399 | if (context->thread_keyring) { |
400 | key = keyring_search_aux(context->thread_keyring, | 400 | key_ref = keyring_search_aux( |
401 | context, type, description, match); | 401 | make_key_ref(context->thread_keyring, 1), |
402 | if (!IS_ERR(key)) | 402 | context, type, description, match); |
403 | if (!IS_ERR(key_ref)) | ||
403 | goto found; | 404 | goto found; |
404 | 405 | ||
405 | switch (PTR_ERR(key)) { | 406 | switch (PTR_ERR(key_ref)) { |
406 | case -EAGAIN: /* no key */ | 407 | case -EAGAIN: /* no key */ |
407 | if (ret) | 408 | if (ret) |
408 | break; | 409 | break; |
409 | case -ENOKEY: /* negative key */ | 410 | case -ENOKEY: /* negative key */ |
410 | ret = key; | 411 | ret = key_ref; |
411 | break; | 412 | break; |
412 | default: | 413 | default: |
413 | err = key; | 414 | err = key_ref; |
414 | break; | 415 | break; |
415 | } | 416 | } |
416 | } | 417 | } |
417 | 418 | ||
418 | /* search the process keyring second */ | 419 | /* search the process keyring second */ |
419 | if (context->signal->process_keyring) { | 420 | if (context->signal->process_keyring) { |
420 | key = keyring_search_aux(context->signal->process_keyring, | 421 | key_ref = keyring_search_aux( |
421 | context, type, description, match); | 422 | make_key_ref(context->signal->process_keyring, 1), |
422 | if (!IS_ERR(key)) | 423 | context, type, description, match); |
424 | if (!IS_ERR(key_ref)) | ||
423 | goto found; | 425 | goto found; |
424 | 426 | ||
425 | switch (PTR_ERR(key)) { | 427 | switch (PTR_ERR(key_ref)) { |
426 | case -EAGAIN: /* no key */ | 428 | case -EAGAIN: /* no key */ |
427 | if (ret) | 429 | if (ret) |
428 | break; | 430 | break; |
429 | case -ENOKEY: /* negative key */ | 431 | case -ENOKEY: /* negative key */ |
430 | ret = key; | 432 | ret = key_ref; |
431 | break; | 433 | break; |
432 | default: | 434 | default: |
433 | err = key; | 435 | err = key_ref; |
434 | break; | 436 | break; |
435 | } | 437 | } |
436 | } | 438 | } |
@@ -438,23 +440,25 @@ struct key *search_process_keyrings(struct key_type *type, | |||
438 | /* search the session keyring */ | 440 | /* search the session keyring */ |
439 | if (context->signal->session_keyring) { | 441 | if (context->signal->session_keyring) { |
440 | rcu_read_lock(); | 442 | rcu_read_lock(); |
441 | key = keyring_search_aux( | 443 | key_ref = keyring_search_aux( |
442 | rcu_dereference(context->signal->session_keyring), | 444 | make_key_ref(rcu_dereference( |
445 | context->signal->session_keyring), | ||
446 | 1), | ||
443 | context, type, description, match); | 447 | context, type, description, match); |
444 | rcu_read_unlock(); | 448 | rcu_read_unlock(); |
445 | 449 | ||
446 | if (!IS_ERR(key)) | 450 | if (!IS_ERR(key_ref)) |
447 | goto found; | 451 | goto found; |
448 | 452 | ||
449 | switch (PTR_ERR(key)) { | 453 | switch (PTR_ERR(key_ref)) { |
450 | case -EAGAIN: /* no key */ | 454 | case -EAGAIN: /* no key */ |
451 | if (ret) | 455 | if (ret) |
452 | break; | 456 | break; |
453 | case -ENOKEY: /* negative key */ | 457 | case -ENOKEY: /* negative key */ |
454 | ret = key; | 458 | ret = key_ref; |
455 | break; | 459 | break; |
456 | default: | 460 | default: |
457 | err = key; | 461 | err = key_ref; |
458 | break; | 462 | break; |
459 | } | 463 | } |
460 | 464 | ||
@@ -465,51 +469,54 @@ struct key *search_process_keyrings(struct key_type *type, | |||
465 | goto no_key; | 469 | goto no_key; |
466 | 470 | ||
467 | rcu_read_lock(); | 471 | rcu_read_lock(); |
468 | instkey = __keyring_search_one( | 472 | instkey_ref = __keyring_search_one( |
469 | rcu_dereference(context->signal->session_keyring), | 473 | make_key_ref(rcu_dereference( |
474 | context->signal->session_keyring), | ||
475 | 1), | ||
470 | &key_type_request_key_auth, NULL, 0); | 476 | &key_type_request_key_auth, NULL, 0); |
471 | rcu_read_unlock(); | 477 | rcu_read_unlock(); |
472 | 478 | ||
473 | if (IS_ERR(instkey)) | 479 | if (IS_ERR(instkey_ref)) |
474 | goto no_key; | 480 | goto no_key; |
475 | 481 | ||
476 | rka = instkey->payload.data; | 482 | rka = key_ref_to_ptr(instkey_ref)->payload.data; |
477 | 483 | ||
478 | key = search_process_keyrings(type, description, match, | 484 | key_ref = search_process_keyrings(type, description, match, |
479 | rka->context); | 485 | rka->context); |
480 | key_put(instkey); | 486 | key_ref_put(instkey_ref); |
481 | 487 | ||
482 | if (!IS_ERR(key)) | 488 | if (!IS_ERR(key_ref)) |
483 | goto found; | 489 | goto found; |
484 | 490 | ||
485 | switch (PTR_ERR(key)) { | 491 | switch (PTR_ERR(key_ref)) { |
486 | case -EAGAIN: /* no key */ | 492 | case -EAGAIN: /* no key */ |
487 | if (ret) | 493 | if (ret) |
488 | break; | 494 | break; |
489 | case -ENOKEY: /* negative key */ | 495 | case -ENOKEY: /* negative key */ |
490 | ret = key; | 496 | ret = key_ref; |
491 | break; | 497 | break; |
492 | default: | 498 | default: |
493 | err = key; | 499 | err = key_ref; |
494 | break; | 500 | break; |
495 | } | 501 | } |
496 | } | 502 | } |
497 | /* or search the user-session keyring */ | 503 | /* or search the user-session keyring */ |
498 | else { | 504 | else { |
499 | key = keyring_search_aux(context->user->session_keyring, | 505 | key_ref = keyring_search_aux( |
500 | context, type, description, match); | 506 | make_key_ref(context->user->session_keyring, 1), |
501 | if (!IS_ERR(key)) | 507 | context, type, description, match); |
508 | if (!IS_ERR(key_ref)) | ||
502 | goto found; | 509 | goto found; |
503 | 510 | ||
504 | switch (PTR_ERR(key)) { | 511 | switch (PTR_ERR(key_ref)) { |
505 | case -EAGAIN: /* no key */ | 512 | case -EAGAIN: /* no key */ |
506 | if (ret) | 513 | if (ret) |
507 | break; | 514 | break; |
508 | case -ENOKEY: /* negative key */ | 515 | case -ENOKEY: /* negative key */ |
509 | ret = key; | 516 | ret = key_ref; |
510 | break; | 517 | break; |
511 | default: | 518 | default: |
512 | err = key; | 519 | err = key_ref; |
513 | break; | 520 | break; |
514 | } | 521 | } |
515 | } | 522 | } |
@@ -517,29 +524,40 @@ struct key *search_process_keyrings(struct key_type *type, | |||
517 | 524 | ||
518 | no_key: | 525 | no_key: |
519 | /* no key - decide on the error we're going to go for */ | 526 | /* no key - decide on the error we're going to go for */ |
520 | key = ret ? ret : err; | 527 | key_ref = ret ? ret : err; |
521 | 528 | ||
522 | found: | 529 | found: |
523 | return key; | 530 | return key_ref; |
524 | 531 | ||
525 | } /* end search_process_keyrings() */ | 532 | } /* end search_process_keyrings() */ |
526 | 533 | ||
527 | /*****************************************************************************/ | 534 | /*****************************************************************************/ |
528 | /* | 535 | /* |
536 | * see if the key we're looking at is the target key | ||
537 | */ | ||
538 | static int lookup_user_key_possessed(const struct key *key, const void *target) | ||
539 | { | ||
540 | return key == target; | ||
541 | |||
542 | } /* end lookup_user_key_possessed() */ | ||
543 | |||
544 | /*****************************************************************************/ | ||
545 | /* | ||
529 | * lookup a key given a key ID from userspace with a given permissions mask | 546 | * lookup a key given a key ID from userspace with a given permissions mask |
530 | * - don't create special keyrings unless so requested | 547 | * - don't create special keyrings unless so requested |
531 | * - partially constructed keys aren't found unless requested | 548 | * - partially constructed keys aren't found unless requested |
532 | */ | 549 | */ |
533 | struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | 550 | key_ref_t lookup_user_key(struct task_struct *context, key_serial_t id, |
534 | int create, int partial, key_perm_t perm) | 551 | int create, int partial, key_perm_t perm) |
535 | { | 552 | { |
553 | key_ref_t key_ref, skey_ref; | ||
536 | struct key *key; | 554 | struct key *key; |
537 | int ret; | 555 | int ret; |
538 | 556 | ||
539 | if (!context) | 557 | if (!context) |
540 | context = current; | 558 | context = current; |
541 | 559 | ||
542 | key = ERR_PTR(-ENOKEY); | 560 | key_ref = ERR_PTR(-ENOKEY); |
543 | 561 | ||
544 | switch (id) { | 562 | switch (id) { |
545 | case KEY_SPEC_THREAD_KEYRING: | 563 | case KEY_SPEC_THREAD_KEYRING: |
@@ -556,6 +574,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
556 | 574 | ||
557 | key = context->thread_keyring; | 575 | key = context->thread_keyring; |
558 | atomic_inc(&key->usage); | 576 | atomic_inc(&key->usage); |
577 | key_ref = make_key_ref(key, 1); | ||
559 | break; | 578 | break; |
560 | 579 | ||
561 | case KEY_SPEC_PROCESS_KEYRING: | 580 | case KEY_SPEC_PROCESS_KEYRING: |
@@ -572,6 +591,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
572 | 591 | ||
573 | key = context->signal->process_keyring; | 592 | key = context->signal->process_keyring; |
574 | atomic_inc(&key->usage); | 593 | atomic_inc(&key->usage); |
594 | key_ref = make_key_ref(key, 1); | ||
575 | break; | 595 | break; |
576 | 596 | ||
577 | case KEY_SPEC_SESSION_KEYRING: | 597 | case KEY_SPEC_SESSION_KEYRING: |
@@ -579,7 +599,7 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
579 | /* always install a session keyring upon access if one | 599 | /* always install a session keyring upon access if one |
580 | * doesn't exist yet */ | 600 | * doesn't exist yet */ |
581 | ret = install_session_keyring( | 601 | ret = install_session_keyring( |
582 | context, context->user->session_keyring); | 602 | context, context->user->session_keyring); |
583 | if (ret < 0) | 603 | if (ret < 0) |
584 | goto error; | 604 | goto error; |
585 | } | 605 | } |
@@ -588,16 +608,19 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
588 | key = rcu_dereference(context->signal->session_keyring); | 608 | key = rcu_dereference(context->signal->session_keyring); |
589 | atomic_inc(&key->usage); | 609 | atomic_inc(&key->usage); |
590 | rcu_read_unlock(); | 610 | rcu_read_unlock(); |
611 | key_ref = make_key_ref(key, 1); | ||
591 | break; | 612 | break; |
592 | 613 | ||
593 | case KEY_SPEC_USER_KEYRING: | 614 | case KEY_SPEC_USER_KEYRING: |
594 | key = context->user->uid_keyring; | 615 | key = context->user->uid_keyring; |
595 | atomic_inc(&key->usage); | 616 | atomic_inc(&key->usage); |
617 | key_ref = make_key_ref(key, 1); | ||
596 | break; | 618 | break; |
597 | 619 | ||
598 | case KEY_SPEC_USER_SESSION_KEYRING: | 620 | case KEY_SPEC_USER_SESSION_KEYRING: |
599 | key = context->user->session_keyring; | 621 | key = context->user->session_keyring; |
600 | atomic_inc(&key->usage); | 622 | atomic_inc(&key->usage); |
623 | key_ref = make_key_ref(key, 1); | ||
601 | break; | 624 | break; |
602 | 625 | ||
603 | case KEY_SPEC_GROUP_KEYRING: | 626 | case KEY_SPEC_GROUP_KEYRING: |
@@ -606,13 +629,28 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
606 | goto error; | 629 | goto error; |
607 | 630 | ||
608 | default: | 631 | default: |
609 | key = ERR_PTR(-EINVAL); | 632 | key_ref = ERR_PTR(-EINVAL); |
610 | if (id < 1) | 633 | if (id < 1) |
611 | goto error; | 634 | goto error; |
612 | 635 | ||
613 | key = key_lookup(id); | 636 | key = key_lookup(id); |
614 | if (IS_ERR(key)) | 637 | if (IS_ERR(key)) { |
638 | key_ref = ERR_PTR(PTR_ERR(key)); | ||
615 | goto error; | 639 | goto error; |
640 | } | ||
641 | |||
642 | key_ref = make_key_ref(key, 0); | ||
643 | |||
644 | /* check to see if we possess the key */ | ||
645 | skey_ref = search_process_keyrings(key->type, key, | ||
646 | lookup_user_key_possessed, | ||
647 | current); | ||
648 | |||
649 | if (!IS_ERR(skey_ref)) { | ||
650 | key_put(key); | ||
651 | key_ref = skey_ref; | ||
652 | } | ||
653 | |||
616 | break; | 654 | break; |
617 | } | 655 | } |
618 | 656 | ||
@@ -630,15 +668,15 @@ struct key *lookup_user_key(struct task_struct *context, key_serial_t id, | |||
630 | /* check the permissions */ | 668 | /* check the permissions */ |
631 | ret = -EACCES; | 669 | ret = -EACCES; |
632 | 670 | ||
633 | if (!key_task_permission(key, context, perm)) | 671 | if (!key_task_permission(key_ref, context, perm)) |
634 | goto invalid_key; | 672 | goto invalid_key; |
635 | 673 | ||
636 | error: | 674 | error: |
637 | return key; | 675 | return key_ref; |
638 | 676 | ||
639 | invalid_key: | 677 | invalid_key: |
640 | key_put(key); | 678 | key_ref_put(key_ref); |
641 | key = ERR_PTR(ret); | 679 | key_ref = ERR_PTR(ret); |
642 | goto error; | 680 | goto error; |
643 | 681 | ||
644 | } /* end lookup_user_key() */ | 682 | } /* end lookup_user_key() */ |
@@ -694,9 +732,9 @@ long join_session_keyring(const char *name) | |||
694 | ret = keyring->serial; | 732 | ret = keyring->serial; |
695 | key_put(keyring); | 733 | key_put(keyring); |
696 | 734 | ||
697 | error2: | 735 | error2: |
698 | up(&key_session_sem); | 736 | up(&key_session_sem); |
699 | error: | 737 | error: |
700 | return ret; | 738 | return ret; |
701 | 739 | ||
702 | } /* end join_session_keyring() */ | 740 | } /* end join_session_keyring() */ |
diff --git a/security/keys/request_key.c b/security/keys/request_key.c index 90c1506d007c..e6dd366d43a3 100644 --- a/security/keys/request_key.c +++ b/security/keys/request_key.c | |||
@@ -129,7 +129,7 @@ static struct key *__request_key_construction(struct key_type *type, | |||
129 | 129 | ||
130 | /* create a key and add it to the queue */ | 130 | /* create a key and add it to the queue */ |
131 | key = key_alloc(type, description, | 131 | key = key_alloc(type, description, |
132 | current->fsuid, current->fsgid, KEY_USR_ALL, 0); | 132 | current->fsuid, current->fsgid, KEY_POS_ALL, 0); |
133 | if (IS_ERR(key)) | 133 | if (IS_ERR(key)) |
134 | goto alloc_failed; | 134 | goto alloc_failed; |
135 | 135 | ||
@@ -365,14 +365,24 @@ struct key *request_key_and_link(struct key_type *type, | |||
365 | { | 365 | { |
366 | struct key_user *user; | 366 | struct key_user *user; |
367 | struct key *key; | 367 | struct key *key; |
368 | key_ref_t key_ref; | ||
368 | 369 | ||
369 | kenter("%s,%s,%s,%p", | 370 | kenter("%s,%s,%s,%p", |
370 | type->name, description, callout_info, dest_keyring); | 371 | type->name, description, callout_info, dest_keyring); |
371 | 372 | ||
372 | /* search all the process keyrings for a key */ | 373 | /* search all the process keyrings for a key */ |
373 | key = search_process_keyrings(type, description, type->match, current); | 374 | key_ref = search_process_keyrings(type, description, type->match, |
375 | current); | ||
374 | 376 | ||
375 | if (PTR_ERR(key) == -EAGAIN) { | 377 | kdebug("search 1: %p", key_ref); |
378 | |||
379 | if (!IS_ERR(key_ref)) { | ||
380 | key = key_ref_to_ptr(key_ref); | ||
381 | } | ||
382 | else if (PTR_ERR(key_ref) != -EAGAIN) { | ||
383 | key = ERR_PTR(PTR_ERR(key_ref)); | ||
384 | } | ||
385 | else { | ||
376 | /* the search failed, but the keyrings were searchable, so we | 386 | /* the search failed, but the keyrings were searchable, so we |
377 | * should consult userspace if we can */ | 387 | * should consult userspace if we can */ |
378 | key = ERR_PTR(-ENOKEY); | 388 | key = ERR_PTR(-ENOKEY); |
@@ -384,7 +394,7 @@ struct key *request_key_and_link(struct key_type *type, | |||
384 | if (!user) | 394 | if (!user) |
385 | goto nomem; | 395 | goto nomem; |
386 | 396 | ||
387 | do { | 397 | for (;;) { |
388 | if (signal_pending(current)) | 398 | if (signal_pending(current)) |
389 | goto interrupted; | 399 | goto interrupted; |
390 | 400 | ||
@@ -397,10 +407,22 @@ struct key *request_key_and_link(struct key_type *type, | |||
397 | 407 | ||
398 | /* someone else made the key we want, so we need to | 408 | /* someone else made the key we want, so we need to |
399 | * search again as it might now be available to us */ | 409 | * search again as it might now be available to us */ |
400 | key = search_process_keyrings(type, description, | 410 | key_ref = search_process_keyrings(type, description, |
401 | type->match, current); | 411 | type->match, |
412 | current); | ||
413 | |||
414 | kdebug("search 2: %p", key_ref); | ||
402 | 415 | ||
403 | } while (PTR_ERR(key) == -EAGAIN); | 416 | if (!IS_ERR(key_ref)) { |
417 | key = key_ref_to_ptr(key_ref); | ||
418 | break; | ||
419 | } | ||
420 | |||
421 | if (PTR_ERR(key_ref) != -EAGAIN) { | ||
422 | key = ERR_PTR(PTR_ERR(key_ref)); | ||
423 | break; | ||
424 | } | ||
425 | } | ||
404 | 426 | ||
405 | key_user_put(user); | 427 | key_user_put(user); |
406 | 428 | ||
diff --git a/security/keys/request_key_auth.c b/security/keys/request_key_auth.c index f22264632229..1ecd3d3fa9f8 100644 --- a/security/keys/request_key_auth.c +++ b/security/keys/request_key_auth.c | |||
@@ -126,7 +126,7 @@ struct key *request_key_auth_new(struct key *target, struct key **_rkakey) | |||
126 | 126 | ||
127 | rkakey = key_alloc(&key_type_request_key_auth, desc, | 127 | rkakey = key_alloc(&key_type_request_key_auth, desc, |
128 | current->fsuid, current->fsgid, | 128 | current->fsuid, current->fsgid, |
129 | KEY_USR_VIEW, 1); | 129 | KEY_POS_VIEW | KEY_USR_VIEW, 1); |
130 | if (IS_ERR(rkakey)) { | 130 | if (IS_ERR(rkakey)) { |
131 | key_put(keyring); | 131 | key_put(keyring); |
132 | kleave("= %ld", PTR_ERR(rkakey)); | 132 | kleave("= %ld", PTR_ERR(rkakey)); |