diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-11 00:31:58 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-11 00:31:58 -0400 |
commit | c8d6637d0497d62093dbba0694c7b3a80b79bfe1 (patch) | |
tree | 4ef432511fa6fa959429e1fc961fb186f1745e54 /scripts | |
parent | 801a71a858631109a64bf30b1c480b0a18386605 (diff) | |
parent | 76215b04fd297c008b91ece732ed36e67e0181fa (diff) |
Merge tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux
Pull module updates from Rusty Russell:
"This finally applies the stricter sysfs perms checking we pulled out
before last merge window. A few stragglers are fixed (thanks
linux-next!)"
* tag 'modules-next-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/rusty/linux:
arch/powerpc/platforms/powernv/opal-dump.c: fix world-writable sysfs files
arch/powerpc/platforms/powernv/opal-elog.c: fix world-writable sysfs files
drivers/video/fbdev/s3c2410fb.c: don't make debug world-writable.
ARM: avoid ARM binutils leaking ELF local symbols
scripts: modpost: Remove numeric suffix pattern matching
scripts: modpost: fix compilation warning
sysfs: disallow world-writable files.
module: return bool from within_module*()
module: add within_module() function
modules: Fix build error in moduleloader.h
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/mod/modpost.c | 58 |
1 files changed, 14 insertions, 44 deletions
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9d9c5b905b35..091d90573b63 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -772,32 +772,10 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | |||
772 | sechdr->sh_name; | 772 | sechdr->sh_name; |
773 | } | 773 | } |
774 | 774 | ||
775 | /* if sym is empty or point to a string | ||
776 | * like ".[0-9]+" then return 1. | ||
777 | * This is the optional prefix added by ld to some sections | ||
778 | */ | ||
779 | static int number_prefix(const char *sym) | ||
780 | { | ||
781 | if (*sym++ == '\0') | ||
782 | return 1; | ||
783 | if (*sym != '.') | ||
784 | return 0; | ||
785 | do { | ||
786 | char c = *sym++; | ||
787 | if (c < '0' || c > '9') | ||
788 | return 0; | ||
789 | } while (*sym); | ||
790 | return 1; | ||
791 | } | ||
792 | |||
793 | /* The pattern is an array of simple patterns. | 775 | /* The pattern is an array of simple patterns. |
794 | * "foo" will match an exact string equal to "foo" | 776 | * "foo" will match an exact string equal to "foo" |
795 | * "*foo" will match a string that ends with "foo" | 777 | * "*foo" will match a string that ends with "foo" |
796 | * "foo*" will match a string that begins with "foo" | 778 | * "foo*" will match a string that begins with "foo" |
797 | * "foo$" will match a string equal to "foo" or "foo.1" | ||
798 | * where the '1' can be any number including several digits. | ||
799 | * The $ syntax is for sections where ld append a dot number | ||
800 | * to make section name unique. | ||
801 | */ | 779 | */ |
802 | static int match(const char *sym, const char * const pat[]) | 780 | static int match(const char *sym, const char * const pat[]) |
803 | { | 781 | { |
@@ -816,13 +794,6 @@ static int match(const char *sym, const char * const pat[]) | |||
816 | if (strncmp(sym, p, strlen(p) - 1) == 0) | 794 | if (strncmp(sym, p, strlen(p) - 1) == 0) |
817 | return 1; | 795 | return 1; |
818 | } | 796 | } |
819 | /* "foo$" */ | ||
820 | else if (*endp == '$') { | ||
821 | if (strncmp(sym, p, strlen(p) - 1) == 0) { | ||
822 | if (number_prefix(sym + strlen(p) - 1)) | ||
823 | return 1; | ||
824 | } | ||
825 | } | ||
826 | /* no wildcards */ | 797 | /* no wildcards */ |
827 | else { | 798 | else { |
828 | if (strcmp(p, sym) == 0) | 799 | if (strcmp(p, sym) == 0) |
@@ -880,20 +851,20 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
880 | 851 | ||
881 | 852 | ||
882 | #define ALL_INIT_DATA_SECTIONS \ | 853 | #define ALL_INIT_DATA_SECTIONS \ |
883 | ".init.setup$", ".init.rodata$", ".meminit.rodata$", \ | 854 | ".init.setup", ".init.rodata", ".meminit.rodata", \ |
884 | ".init.data$", ".meminit.data$" | 855 | ".init.data", ".meminit.data" |
885 | #define ALL_EXIT_DATA_SECTIONS \ | 856 | #define ALL_EXIT_DATA_SECTIONS \ |
886 | ".exit.data$", ".memexit.data$" | 857 | ".exit.data", ".memexit.data" |
887 | 858 | ||
888 | #define ALL_INIT_TEXT_SECTIONS \ | 859 | #define ALL_INIT_TEXT_SECTIONS \ |
889 | ".init.text$", ".meminit.text$" | 860 | ".init.text", ".meminit.text" |
890 | #define ALL_EXIT_TEXT_SECTIONS \ | 861 | #define ALL_EXIT_TEXT_SECTIONS \ |
891 | ".exit.text$", ".memexit.text$" | 862 | ".exit.text", ".memexit.text" |
892 | 863 | ||
893 | #define ALL_PCI_INIT_SECTIONS \ | 864 | #define ALL_PCI_INIT_SECTIONS \ |
894 | ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ | 865 | ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ |
895 | ".pci_fixup_enable$", ".pci_fixup_resume$", \ | 866 | ".pci_fixup_enable", ".pci_fixup_resume", \ |
896 | ".pci_fixup_resume_early$", ".pci_fixup_suspend$" | 867 | ".pci_fixup_resume_early", ".pci_fixup_suspend" |
897 | 868 | ||
898 | #define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS | 869 | #define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS |
899 | #define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS | 870 | #define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS |
@@ -901,8 +872,8 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
901 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS | 872 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS |
902 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS | 873 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS |
903 | 874 | ||
904 | #define DATA_SECTIONS ".data$", ".data.rel$" | 875 | #define DATA_SECTIONS ".data", ".data.rel" |
905 | #define TEXT_SECTIONS ".text$", ".text.unlikely$" | 876 | #define TEXT_SECTIONS ".text", ".text.unlikely" |
906 | 877 | ||
907 | #define INIT_SECTIONS ".init.*" | 878 | #define INIT_SECTIONS ".init.*" |
908 | #define MEM_INIT_SECTIONS ".meminit.*" | 879 | #define MEM_INIT_SECTIONS ".meminit.*" |
@@ -1703,12 +1674,11 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
1703 | 1674 | ||
1704 | static char *remove_dot(char *s) | 1675 | static char *remove_dot(char *s) |
1705 | { | 1676 | { |
1706 | char *end; | 1677 | size_t n = strcspn(s, "."); |
1707 | int n = strcspn(s, "."); | ||
1708 | 1678 | ||
1709 | if (n > 0 && s[n] != 0) { | 1679 | if (n && s[n]) { |
1710 | strtoul(s + n + 1, &end, 10); | 1680 | size_t m = strspn(s + n + 1, "0123456789"); |
1711 | if (end > s + n + 1 && (*end == '.' || *end == 0)) | 1681 | if (m && (s[n + m] == '.' || s[n + m] == 0)) |
1712 | s[n] = 0; | 1682 | s[n] = 0; |
1713 | } | 1683 | } |
1714 | return s; | 1684 | return s; |