Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'modules-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux

Pull modules updates from Petr Pavlu:

- Sign modules with sha512 instead of sha1 by default

- Don't fail module loading when failing to set the
ro_after_init section read-only

- Constify 'struct module_attribute'

- Cleanups and preparation for const struct bin_attribute

- Put known GPL offenders in an array

- Extend the preempt disabled section in
dereference_symbol_descriptor()

* tag 'modules-6.14-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/modules/linux:
module: sign with sha512 instead of sha1 by default
module: Don't fail module loading when setting ro_after_init section RO failed
module: Split module_enable_rodata_ro()
module: sysfs: Use const 'struct bin_attribute'
module: sysfs: Add notes attributes through attribute_group
module: sysfs: Simplify section attribute allocation
module: sysfs: Drop 'struct module_sect_attr'
module: sysfs: Drop member 'module_sect_attr::address'
module: sysfs: Drop member 'module_sect_attrs::nsections'
module: Constify 'struct module_attribute'
module: Handle 'struct module_version_attribute' as const
params: Prepare for 'const struct module_attribute *'
module: Put known GPL offenders in an array
module: Extend the preempt disabled section in dereference_symbol_descriptor().

+128 -121
+1 -1
include/linux/kallsyms.h
··· 57 57 58 58 preempt_disable(); 59 59 mod = __module_address((unsigned long)ptr); 60 - preempt_enable(); 61 60 62 61 if (mod) 63 62 ptr = dereference_module_function_descriptor(mod, ptr); 63 + preempt_enable(); 64 64 #endif 65 65 return ptr; 66 66 }
+5 -5
include/linux/module.h
··· 52 52 53 53 struct module_attribute { 54 54 struct attribute attr; 55 - ssize_t (*show)(struct module_attribute *, struct module_kobject *, 55 + ssize_t (*show)(const struct module_attribute *, struct module_kobject *, 56 56 char *); 57 - ssize_t (*store)(struct module_attribute *, struct module_kobject *, 57 + ssize_t (*store)(const struct module_attribute *, struct module_kobject *, 58 58 const char *, size_t count); 59 59 void (*setup)(struct module *, const char *); 60 60 int (*test)(struct module *); ··· 67 67 const char *version; 68 68 }; 69 69 70 - extern ssize_t __modver_version_show(struct module_attribute *, 70 + extern ssize_t __modver_version_show(const struct module_attribute *, 71 71 struct module_kobject *, char *); 72 72 73 - extern struct module_attribute module_uevent; 73 + extern const struct module_attribute module_uevent; 74 74 75 75 /* These are either module local, or the kernel's dummy ones. */ 76 76 extern int init_module(void); ··· 275 275 #else 276 276 #define MODULE_VERSION(_version) \ 277 277 MODULE_INFO(version, _version); \ 278 - static struct module_version_attribute __modver_attr \ 278 + static const struct module_version_attribute __modver_attr \ 279 279 __used __section("__modver") \ 280 280 __aligned(__alignof__(struct module_version_attribute)) \ 281 281 = { \
+1
kernel/module/Kconfig
··· 231 231 choice 232 232 prompt "Hash algorithm to sign modules" 233 233 depends on MODULE_SIG || IMA_APPRAISE_MODSIG 234 + default MODULE_SIG_SHA512 234 235 help 235 236 This determines which sort of hashing algorithm will be used during 236 237 signature generation. This algorithm _must_ be built into the kernel
+4 -3
kernel/module/internal.h
··· 47 47 extern struct mutex module_mutex; 48 48 extern struct list_head modules; 49 49 50 - extern struct module_attribute *modinfo_attrs[]; 51 - extern size_t modinfo_attrs_count; 50 + extern const struct module_attribute *const modinfo_attrs[]; 51 + extern const size_t modinfo_attrs_count; 52 52 53 53 /* Provided by the linker */ 54 54 extern const struct kernel_symbol __start___ksymtab[]; ··· 327 327 } 328 328 #endif /* CONFIG_MODULES_TREE_LOOKUP */ 329 329 330 - int module_enable_rodata_ro(const struct module *mod, bool after_init); 330 + int module_enable_rodata_ro(const struct module *mod); 331 + int module_enable_rodata_ro_after_init(const struct module *mod); 331 332 int module_enable_data_nx(const struct module *mod); 332 333 int module_enable_text_rox(const struct module *mod); 333 334 int module_enforce_rwx_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
+40 -34
kernel/module/main.c
··· 538 538 { \ 539 539 mod->field = kstrdup(s, GFP_KERNEL); \ 540 540 } \ 541 - static ssize_t show_modinfo_##field(struct module_attribute *mattr, \ 541 + static ssize_t show_modinfo_##field(const struct module_attribute *mattr, \ 542 542 struct module_kobject *mk, char *buffer) \ 543 543 { \ 544 544 return scnprintf(buffer, PAGE_SIZE, "%s\n", mk->mod->field); \ ··· 552 552 kfree(mod->field); \ 553 553 mod->field = NULL; \ 554 554 } \ 555 - static struct module_attribute modinfo_##field = { \ 555 + static const struct module_attribute modinfo_##field = { \ 556 556 .attr = { .name = __stringify(field), .mode = 0444 }, \ 557 557 .show = show_modinfo_##field, \ 558 558 .setup = setup_modinfo_##field, \ ··· 842 842 } 843 843 EXPORT_SYMBOL_GPL(symbol_put_addr); 844 844 845 - static ssize_t show_refcnt(struct module_attribute *mattr, 845 + static ssize_t show_refcnt(const struct module_attribute *mattr, 846 846 struct module_kobject *mk, char *buffer) 847 847 { 848 848 return sprintf(buffer, "%i\n", module_refcount(mk->mod)); 849 849 } 850 850 851 - static struct module_attribute modinfo_refcnt = 851 + static const struct module_attribute modinfo_refcnt = 852 852 __ATTR(refcnt, 0444, show_refcnt, NULL); 853 853 854 854 void __module_get(struct module *module) ··· 917 917 return l; 918 918 } 919 919 920 - static ssize_t show_initstate(struct module_attribute *mattr, 920 + static ssize_t show_initstate(const struct module_attribute *mattr, 921 921 struct module_kobject *mk, char *buffer) 922 922 { 923 923 const char *state = "unknown"; ··· 938 938 return sprintf(buffer, "%s\n", state); 939 939 } 940 940 941 - static struct module_attribute modinfo_initstate = 941 + static const struct module_attribute modinfo_initstate = 942 942 __ATTR(initstate, 0444, show_initstate, NULL); 943 943 944 - static ssize_t store_uevent(struct module_attribute *mattr, 944 + static ssize_t store_uevent(const struct module_attribute *mattr, 945 945 struct module_kobject *mk, 946 946 const char *buffer, size_t count) 947 947 { ··· 951 951 return rc ? rc : count; 952 952 } 953 953 954 - struct module_attribute module_uevent = 954 + const struct module_attribute module_uevent = 955 955 __ATTR(uevent, 0200, NULL, store_uevent); 956 956 957 - static ssize_t show_coresize(struct module_attribute *mattr, 957 + static ssize_t show_coresize(const struct module_attribute *mattr, 958 958 struct module_kobject *mk, char *buffer) 959 959 { 960 960 unsigned int size = mk->mod->mem[MOD_TEXT].size; ··· 966 966 return sprintf(buffer, "%u\n", size); 967 967 } 968 968 969 - static struct module_attribute modinfo_coresize = 969 + static const struct module_attribute modinfo_coresize = 970 970 __ATTR(coresize, 0444, show_coresize, NULL); 971 971 972 972 #ifdef CONFIG_ARCH_WANTS_MODULES_DATA_IN_VMALLOC 973 - static ssize_t show_datasize(struct module_attribute *mattr, 973 + static ssize_t show_datasize(const struct module_attribute *mattr, 974 974 struct module_kobject *mk, char *buffer) 975 975 { 976 976 unsigned int size = 0; ··· 980 980 return sprintf(buffer, "%u\n", size); 981 981 } 982 982 983 - static struct module_attribute modinfo_datasize = 983 + static const struct module_attribute modinfo_datasize = 984 984 __ATTR(datasize, 0444, show_datasize, NULL); 985 985 #endif 986 986 987 - static ssize_t show_initsize(struct module_attribute *mattr, 987 + static ssize_t show_initsize(const struct module_attribute *mattr, 988 988 struct module_kobject *mk, char *buffer) 989 989 { 990 990 unsigned int size = 0; ··· 994 994 return sprintf(buffer, "%u\n", size); 995 995 } 996 996 997 - static struct module_attribute modinfo_initsize = 997 + static const struct module_attribute modinfo_initsize = 998 998 __ATTR(initsize, 0444, show_initsize, NULL); 999 999 1000 - static ssize_t show_taint(struct module_attribute *mattr, 1000 + static ssize_t show_taint(const struct module_attribute *mattr, 1001 1001 struct module_kobject *mk, char *buffer) 1002 1002 { 1003 1003 size_t l; ··· 1007 1007 return l; 1008 1008 } 1009 1009 1010 - static struct module_attribute modinfo_taint = 1010 + static const struct module_attribute modinfo_taint = 1011 1011 __ATTR(taint, 0444, show_taint, NULL); 1012 1012 1013 - struct module_attribute *modinfo_attrs[] = { 1013 + const struct module_attribute *const modinfo_attrs[] = { 1014 1014 &module_uevent, 1015 1015 &modinfo_version, 1016 1016 &modinfo_srcversion, ··· 1027 1027 NULL, 1028 1028 }; 1029 1029 1030 - size_t modinfo_attrs_count = ARRAY_SIZE(modinfo_attrs); 1030 + const size_t modinfo_attrs_count = ARRAY_SIZE(modinfo_attrs); 1031 1031 1032 1032 static const char vermagic[] = VERMAGIC_STRING; 1033 1033 ··· 1681 1681 1682 1682 static void setup_modinfo(struct module *mod, struct load_info *info) 1683 1683 { 1684 - struct module_attribute *attr; 1684 + const struct module_attribute *attr; 1685 1685 int i; 1686 1686 1687 1687 for (i = 0; (attr = modinfo_attrs[i]); i++) { ··· 1692 1692 1693 1693 static void free_modinfo(struct module *mod) 1694 1694 { 1695 - struct module_attribute *attr; 1695 + const struct module_attribute *attr; 1696 1696 int i; 1697 1697 1698 1698 for (i = 0; (attr = modinfo_attrs[i]); i++) { ··· 2332 2332 return 0; 2333 2333 } 2334 2334 2335 + static const char *const module_license_offenders[] = { 2336 + /* driverloader was caught wrongly pretending to be under GPL */ 2337 + "driverloader", 2338 + 2339 + /* lve claims to be GPL but upstream won't provide source */ 2340 + "lve", 2341 + }; 2342 + 2335 2343 /* 2336 2344 * These calls taint the kernel depending certain module circumstances */ 2337 2345 static void module_augment_kernel_taints(struct module *mod, struct load_info *info) 2338 2346 { 2339 2347 int prev_taint = test_taint(TAINT_PROPRIETARY_MODULE); 2348 + size_t i; 2340 2349 2341 2350 if (!get_modinfo(info, "intree")) { 2342 2351 if (!test_taint(TAINT_OOT_MODULE)) ··· 2394 2385 if (strcmp(mod->name, "ndiswrapper") == 0) 2395 2386 add_taint(TAINT_PROPRIETARY_MODULE, LOCKDEP_NOW_UNRELIABLE); 2396 2387 2397 - /* driverloader was caught wrongly pretending to be under GPL */ 2398 - if (strcmp(mod->name, "driverloader") == 0) 2399 - add_taint_module(mod, TAINT_PROPRIETARY_MODULE, 2400 - LOCKDEP_NOW_UNRELIABLE); 2401 - 2402 - /* lve claims to be GPL but upstream won't provide source */ 2403 - if (strcmp(mod->name, "lve") == 0) 2404 - add_taint_module(mod, TAINT_PROPRIETARY_MODULE, 2405 - LOCKDEP_NOW_UNRELIABLE); 2388 + for (i = 0; i < ARRAY_SIZE(module_license_offenders); ++i) { 2389 + if (strcmp(mod->name, module_license_offenders[i]) == 0) 2390 + add_taint_module(mod, TAINT_PROPRIETARY_MODULE, 2391 + LOCKDEP_NOW_UNRELIABLE); 2392 + } 2406 2393 2407 2394 if (!prev_taint && test_taint(TAINT_PROPRIETARY_MODULE)) 2408 2395 pr_warn("%s: module license taints kernel.\n", mod->name); ··· 2953 2948 /* Switch to core kallsyms now init is done: kallsyms may be walking! */ 2954 2949 rcu_assign_pointer(mod->kallsyms, &mod->core_kallsyms); 2955 2950 #endif 2956 - ret = module_enable_rodata_ro(mod, true); 2951 + ret = module_enable_rodata_ro_after_init(mod); 2957 2952 if (ret) 2958 - goto fail_mutex_unlock; 2953 + pr_warn("%s: module_enable_rodata_ro_after_init() returned %d, " 2954 + "ro_after_init data might still be writable\n", 2955 + mod->name, ret); 2956 + 2959 2957 mod_tree_remove_init(mod); 2960 2958 module_arch_freeing_init(mod); 2961 2959 for_class_mod_mem_type(type, init) { ··· 2997 2989 2998 2990 return 0; 2999 2991 3000 - fail_mutex_unlock: 3001 - mutex_unlock(&module_mutex); 3002 2992 fail_free_freeinit: 3003 2993 kfree(freeinit); 3004 2994 fail: ··· 3124 3118 module_bug_finalize(info->hdr, info->sechdrs, mod); 3125 3119 module_cfi_finalize(info->hdr, info->sechdrs, mod); 3126 3120 3127 - err = module_enable_rodata_ro(mod, false); 3121 + err = module_enable_rodata_ro(mod); 3128 3122 if (err) 3129 3123 goto out_strict_rwx; 3130 3124 err = module_enable_data_nx(mod);
+9 -4
kernel/module/strict_rwx.c
··· 47 47 return 0; 48 48 } 49 49 50 - int module_enable_rodata_ro(const struct module *mod, bool after_init) 50 + int module_enable_rodata_ro(const struct module *mod) 51 51 { 52 52 int ret; 53 53 ··· 61 61 if (ret) 62 62 return ret; 63 63 64 - if (after_init) 65 - return module_set_memory(mod, MOD_RO_AFTER_INIT, set_memory_ro); 66 - 67 64 return 0; 65 + } 66 + 67 + int module_enable_rodata_ro_after_init(const struct module *mod) 68 + { 69 + if (!IS_ENABLED(CONFIG_STRICT_MODULE_RWX) || !rodata_enabled) 70 + return 0; 71 + 72 + return module_set_memory(mod, MOD_RO_AFTER_INIT, set_memory_ro); 68 73 } 69 74 70 75 int module_enable_data_nx(const struct module *mod)
+57 -63
kernel/module/sysfs.c
··· 19 19 * J. Corbet <corbet@lwn.net> 20 20 */ 21 21 #ifdef CONFIG_KALLSYMS 22 - struct module_sect_attr { 23 - struct bin_attribute battr; 24 - unsigned long address; 25 - }; 26 - 27 22 struct module_sect_attrs { 28 23 struct attribute_group grp; 29 - unsigned int nsections; 30 - struct module_sect_attr attrs[]; 24 + struct bin_attribute attrs[]; 31 25 }; 32 26 33 27 #define MODULE_SECT_READ_SIZE (3 /* "0x", "\n" */ + (BITS_PER_LONG / 4)) 34 28 static ssize_t module_sect_read(struct file *file, struct kobject *kobj, 35 - struct bin_attribute *battr, 29 + const struct bin_attribute *battr, 36 30 char *buf, loff_t pos, size_t count) 37 31 { 38 - struct module_sect_attr *sattr = 39 - container_of(battr, struct module_sect_attr, battr); 40 32 char bounce[MODULE_SECT_READ_SIZE + 1]; 41 33 size_t wrote; 42 34 ··· 45 53 */ 46 54 wrote = scnprintf(bounce, sizeof(bounce), "0x%px\n", 47 55 kallsyms_show_value(file->f_cred) 48 - ? (void *)sattr->address : NULL); 56 + ? battr->private : NULL); 49 57 count = min(count, wrote); 50 58 memcpy(buf, bounce, count); 51 59 ··· 54 62 55 63 static void free_sect_attrs(struct module_sect_attrs *sect_attrs) 56 64 { 57 - unsigned int section; 65 + const struct bin_attribute *const *bin_attr; 58 66 59 - for (section = 0; section < sect_attrs->nsections; section++) 60 - kfree(sect_attrs->attrs[section].battr.attr.name); 67 + for (bin_attr = sect_attrs->grp.bin_attrs_new; *bin_attr; bin_attr++) 68 + kfree((*bin_attr)->attr.name); 69 + kfree(sect_attrs->grp.bin_attrs_new); 61 70 kfree(sect_attrs); 62 71 } 63 72 64 73 static int add_sect_attrs(struct module *mod, const struct load_info *info) 65 74 { 66 - unsigned int nloaded = 0, i, size[2]; 67 75 struct module_sect_attrs *sect_attrs; 68 - struct module_sect_attr *sattr; 69 - struct bin_attribute **gattr; 76 + const struct bin_attribute **gattr; 77 + struct bin_attribute *sattr; 78 + unsigned int nloaded = 0, i; 70 79 int ret; 71 80 72 81 /* Count loaded sections and allocate structures */ 73 82 for (i = 0; i < info->hdr->e_shnum; i++) 74 83 if (!sect_empty(&info->sechdrs[i])) 75 84 nloaded++; 76 - size[0] = ALIGN(struct_size(sect_attrs, attrs, nloaded), 77 - sizeof(sect_attrs->grp.bin_attrs[0])); 78 - size[1] = (nloaded + 1) * sizeof(sect_attrs->grp.bin_attrs[0]); 79 - sect_attrs = kzalloc(size[0] + size[1], GFP_KERNEL); 85 + sect_attrs = kzalloc(struct_size(sect_attrs, attrs, nloaded), GFP_KERNEL); 80 86 if (!sect_attrs) 81 87 return -ENOMEM; 82 88 89 + gattr = kcalloc(nloaded + 1, sizeof(*gattr), GFP_KERNEL); 90 + if (!gattr) { 91 + kfree(sect_attrs); 92 + return -ENOMEM; 93 + } 94 + 83 95 /* Setup section attributes. */ 84 96 sect_attrs->grp.name = "sections"; 85 - sect_attrs->grp.bin_attrs = (void *)sect_attrs + size[0]; 97 + sect_attrs->grp.bin_attrs_new = gattr; 86 98 87 - sect_attrs->nsections = 0; 88 99 sattr = &sect_attrs->attrs[0]; 89 - gattr = &sect_attrs->grp.bin_attrs[0]; 90 100 for (i = 0; i < info->hdr->e_shnum; i++) { 91 101 Elf_Shdr *sec = &info->sechdrs[i]; 92 102 93 103 if (sect_empty(sec)) 94 104 continue; 95 - sysfs_bin_attr_init(&sattr->battr); 96 - sattr->address = sec->sh_addr; 97 - sattr->battr.attr.name = 105 + sysfs_bin_attr_init(sattr); 106 + sattr->attr.name = 98 107 kstrdup(info->secstrings + sec->sh_name, GFP_KERNEL); 99 - if (!sattr->battr.attr.name) { 108 + if (!sattr->attr.name) { 100 109 ret = -ENOMEM; 101 110 goto out; 102 111 } 103 - sect_attrs->nsections++; 104 - sattr->battr.read = module_sect_read; 105 - sattr->battr.size = MODULE_SECT_READ_SIZE; 106 - sattr->battr.attr.mode = 0400; 107 - *(gattr++) = &(sattr++)->battr; 112 + sattr->read_new = module_sect_read; 113 + sattr->private = (void *)sec->sh_addr; 114 + sattr->size = MODULE_SECT_READ_SIZE; 115 + sattr->attr.mode = 0400; 116 + *(gattr++) = sattr++; 108 117 } 109 - *gattr = NULL; 110 118 111 119 ret = sysfs_create_group(&mod->mkobj.kobj, &sect_attrs->grp); 112 120 if (ret) ··· 138 146 */ 139 147 140 148 struct module_notes_attrs { 141 - struct kobject *dir; 142 - unsigned int notes; 143 - struct bin_attribute attrs[] __counted_by(notes); 149 + struct attribute_group grp; 150 + struct bin_attribute attrs[]; 144 151 }; 145 152 146 - static void free_notes_attrs(struct module_notes_attrs *notes_attrs, 147 - unsigned int i) 153 + static void free_notes_attrs(struct module_notes_attrs *notes_attrs) 148 154 { 149 - if (notes_attrs->dir) { 150 - while (i-- > 0) 151 - sysfs_remove_bin_file(notes_attrs->dir, 152 - &notes_attrs->attrs[i]); 153 - kobject_put(notes_attrs->dir); 154 - } 155 + kfree(notes_attrs->grp.bin_attrs_new); 155 156 kfree(notes_attrs); 156 157 } 157 158 ··· 152 167 { 153 168 unsigned int notes, loaded, i; 154 169 struct module_notes_attrs *notes_attrs; 170 + const struct bin_attribute **gattr; 155 171 struct bin_attribute *nattr; 156 172 int ret; 157 173 ··· 171 185 if (!notes_attrs) 172 186 return -ENOMEM; 173 187 174 - notes_attrs->notes = notes; 188 + gattr = kcalloc(notes + 1, sizeof(*gattr), GFP_KERNEL); 189 + if (!gattr) { 190 + kfree(notes_attrs); 191 + return -ENOMEM; 192 + } 193 + 194 + notes_attrs->grp.name = "notes"; 195 + notes_attrs->grp.bin_attrs_new = gattr; 196 + 175 197 nattr = &notes_attrs->attrs[0]; 176 198 for (loaded = i = 0; i < info->hdr->e_shnum; ++i) { 177 199 if (sect_empty(&info->sechdrs[i])) 178 200 continue; 179 201 if (info->sechdrs[i].sh_type == SHT_NOTE) { 180 202 sysfs_bin_attr_init(nattr); 181 - nattr->attr.name = mod->sect_attrs->attrs[loaded].battr.attr.name; 203 + nattr->attr.name = mod->sect_attrs->attrs[loaded].attr.name; 182 204 nattr->attr.mode = 0444; 183 205 nattr->size = info->sechdrs[i].sh_size; 184 206 nattr->private = (void *)info->sechdrs[i].sh_addr; 185 207 nattr->read = sysfs_bin_attr_simple_read; 186 - ++nattr; 208 + *(gattr++) = nattr++; 187 209 } 188 210 ++loaded; 189 211 } 190 212 191 - notes_attrs->dir = kobject_create_and_add("notes", &mod->mkobj.kobj); 192 - if (!notes_attrs->dir) { 193 - ret = -ENOMEM; 213 + ret = sysfs_create_group(&mod->mkobj.kobj, &notes_attrs->grp); 214 + if (ret) 194 215 goto out; 195 - } 196 - 197 - for (i = 0; i < notes; ++i) { 198 - ret = sysfs_create_bin_file(notes_attrs->dir, &notes_attrs->attrs[i]); 199 - if (ret) 200 - goto out; 201 - } 202 216 203 217 mod->notes_attrs = notes_attrs; 204 218 return 0; 205 219 206 220 out: 207 - free_notes_attrs(notes_attrs, i); 221 + free_notes_attrs(notes_attrs); 208 222 return ret; 209 223 } 210 224 211 225 static void remove_notes_attrs(struct module *mod) 212 226 { 213 - if (mod->notes_attrs) 214 - free_notes_attrs(mod->notes_attrs, mod->notes_attrs->notes); 227 + if (mod->notes_attrs) { 228 + sysfs_remove_group(&mod->mkobj.kobj, 229 + &mod->notes_attrs->grp); 230 + /* 231 + * We are positive that no one is using any notes attrs 232 + * at this point. Deallocate immediately. 233 + */ 234 + free_notes_attrs(mod->notes_attrs); 235 + mod->notes_attrs = NULL; 236 + } 215 237 } 216 238 217 239 #else /* !CONFIG_KALLSYMS */ ··· 269 275 270 276 static void module_remove_modinfo_attrs(struct module *mod, int end) 271 277 { 272 - struct module_attribute *attr; 278 + const struct module_attribute *attr; 273 279 int i; 274 280 275 281 for (i = 0; (attr = &mod->modinfo_attrs[i]); i++) { ··· 287 293 288 294 static int module_add_modinfo_attrs(struct module *mod) 289 295 { 290 - struct module_attribute *attr; 296 + const struct module_attribute *attr; 291 297 struct module_attribute *temp_attr; 292 298 int error = 0; 293 299 int i;
+11 -11
kernel/params.c
··· 538 538 EXPORT_SYMBOL(param_ops_string); 539 539 540 540 /* sysfs output in /sys/modules/XYZ/parameters/ */ 541 - #define to_module_attr(n) container_of(n, struct module_attribute, attr) 541 + #define to_module_attr(n) container_of_const(n, struct module_attribute, attr) 542 542 #define to_module_kobject(n) container_of(n, struct module_kobject, kobj) 543 543 544 544 struct param_attribute ··· 555 555 }; 556 556 557 557 #ifdef CONFIG_SYSFS 558 - #define to_param_attr(n) container_of(n, struct param_attribute, mattr) 558 + #define to_param_attr(n) container_of_const(n, struct param_attribute, mattr) 559 559 560 - static ssize_t param_attr_show(struct module_attribute *mattr, 560 + static ssize_t param_attr_show(const struct module_attribute *mattr, 561 561 struct module_kobject *mk, char *buf) 562 562 { 563 563 int count; 564 - struct param_attribute *attribute = to_param_attr(mattr); 564 + const struct param_attribute *attribute = to_param_attr(mattr); 565 565 566 566 if (!attribute->param->ops->get) 567 567 return -EPERM; ··· 573 573 } 574 574 575 575 /* sysfs always hands a nul-terminated string in buf. We rely on that. */ 576 - static ssize_t param_attr_store(struct module_attribute *mattr, 576 + static ssize_t param_attr_store(const struct module_attribute *mattr, 577 577 struct module_kobject *mk, 578 578 const char *buf, size_t len) 579 579 { 580 580 int err; 581 - struct param_attribute *attribute = to_param_attr(mattr); 581 + const struct param_attribute *attribute = to_param_attr(mattr); 582 582 583 583 if (!attribute->param->ops->set) 584 584 return -EPERM; ··· 857 857 } 858 858 } 859 859 860 - ssize_t __modver_version_show(struct module_attribute *mattr, 860 + ssize_t __modver_version_show(const struct module_attribute *mattr, 861 861 struct module_kobject *mk, char *buf) 862 862 { 863 - struct module_version_attribute *vattr = 864 - container_of(mattr, struct module_version_attribute, mattr); 863 + const struct module_version_attribute *vattr = 864 + container_of_const(mattr, struct module_version_attribute, mattr); 865 865 866 866 return scnprintf(buf, PAGE_SIZE, "%s\n", vattr->version); 867 867 } ··· 892 892 struct attribute *attr, 893 893 char *buf) 894 894 { 895 - struct module_attribute *attribute; 895 + const struct module_attribute *attribute; 896 896 struct module_kobject *mk; 897 897 int ret; 898 898 ··· 911 911 struct attribute *attr, 912 912 const char *buf, size_t len) 913 913 { 914 - struct module_attribute *attribute; 914 + const struct module_attribute *attribute; 915 915 struct module_kobject *mk; 916 916 int ret; 917 917