History

Merge tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH: "Here are the set of driver core and kernfs changes for 6.8-rc1. Nothing major in here this release cycle, just lots of small cleanups and some tweaks on kernfs that in the very end, got reverted and will come back in a safer way next release cycle. Included in here are: - more driver core 'const' cleanups and fixes - fw_devlink=rpm is now the default behavior - kernfs tiny changes to remove some string functions - cpu handling in the driver core is updated to work better on many systems that add topologies and cpus after booting - other minor changes and cleanups All of the cpu handling patches have been acked by the respective maintainers and are coming in here in one series. Everything has been in linux-next for a while with no reported issues" * tag 'driver-core-6.8-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (51 commits) Revert "kernfs: convert kernfs_idr_lock to an irq safe raw spinlock" kernfs: convert kernfs_idr_lock to an irq safe raw spinlock class: fix use-after-free in class_register() PM: clk: make pm_clk_add_notifier() take a const pointer EDAC: constantify the struct bus_type usage kernfs: fix reference to renamed function driver core: device.h: fix Excess kernel-doc description warning driver core: class: fix Excess kernel-doc description warning driver core: mark remaining local bus_type variables as const driver core: container: make container_subsys const driver core: bus: constantify subsys_register() calls driver core: bus: make bus_sort_breadthfirst() take a const pointer kernfs: d_obtain_alias(NULL) will do the right thing... driver core: Better advertise dev_err_probe() kernfs: Convert kernfs_path_from_node_locked() from strlcpy() to strscpy() kernfs: Convert kernfs_name_locked() from strlcpy() to strscpy() kernfs: Convert kernfs_walk_ns() from strlcpy() to strscpy() initramfs: Expose retained initrd as sysfs file fs/kernfs/dir: obey S_ISGID kernel/cgroup: use kernfs_create_dir_ns() ...

Linus Torvalds committed 2 years ago

Commit 80955ae2 parents 296455a e3977e051 files · +207 −253Browse files

Unified · Split

51 files
  1. Documentation/ABI/testing/sysfs-firmware-initrd +8 −0
  2. Documentation/admin-guide/kernel-parameters.txt +3 −2
  3. arch/arm64/Kconfig +1 −0
  4. arch/arm64/include/asm/cpu.h +0 −1
  5. arch/arm64/kernel/setup.c +2 −11
  6. arch/loongarch/Kconfig +2 −0
  7. arch/loongarch/kernel/topology.c +2 −40
  8. arch/riscv/Kconfig +1 −0
  9. arch/riscv/kernel/setup.c +2 −16
  10. arch/x86/Kconfig +2 −0
  11. arch/x86/include/asm/cpu.h +0 −4
  12. arch/x86/kernel/topology.c +2 −31
  13. drivers/acpi/Kconfig +0 −1
  14. drivers/acpi/acpi_processor.c +0 −18
  15. drivers/acpi/property.c +4 −0
  16. drivers/base/arch_topology.c +26 −12
  17. drivers/base/auxiliary.c +1 −1
  18. drivers/base/bus.c +4 −4
  19. drivers/base/class.c +1 −0
  20. drivers/base/container.c +1 −1
  21. drivers/base/core.c +7 −6
  22. drivers/base/cpu.c +31 −8
  23. drivers/base/dd.c +1 −1
  24. drivers/base/init.c +1 −1
  25. drivers/base/isa.c +1 −1
  26. drivers/base/memory.c +1 −1
  27. drivers/base/node.c +7 −4
  28. drivers/base/power/clock_ops.c +1 −1
  29. drivers/base/property.c +1 −0
  30. drivers/base/soc.c +3 −3
  31. drivers/base/swnode.c +7 −4
  32. drivers/edac/edac_device.h +1 −1
  33. drivers/edac/edac_device_sysfs.c +1 −1
  34. drivers/edac/edac_module.c +2 −2
  35. drivers/edac/edac_pci_sysfs.c +1 −1
  36. drivers/pmdomain/core.c +1 −1
  37. fs/kernfs/dir.c +37 −25
  38. fs/kernfs/file.c +1 −1
  39. fs/kernfs/mount.c +0 −3
  40. fs/sysfs/dir.c +1 −1
  41. include/linux/container.h +1 −1
  42. include/linux/cpu.h +5 −0
  43. include/linux/device.h +3 −5
  44. include/linux/device/bus.h +1 −1
  45. include/linux/device/class.h +0 −2
  46. include/linux/edac.h +2 −2
  47. include/linux/pm_clock.h +2 −2
  48. init/initramfs.c +17 −1
  49. kernel/cgroup/cgroup-v1.c +1 −1
  50. kernel/cgroup/cgroup.c +6 −29
  51. kernel/cgroup/cpuset.c +1 −1
Documentation/ABI/testing/sysfs-firmware-initrd+8−0
@@ -0,0 +1,8 @@
1+What: /sys/firmware/initrd
2+Date: December 2023
3+Contact: Alexander Graf <graf@amazon.com>
4+Description:
5+ When the kernel was booted with an initrd and the
6+ "retain_initrd" option is set on the kernel command
7+ line, /sys/firmware/initrd contains the contents of the
8+ initrd that the kernel was booted with.
Documentation/admin-guide/kernel-parameters.txt+3−2
@@ -2449,7 +2449,7 @@ · 2448 unmodified lines
24492449 between unregistering the boot console and initializing
24502450 the real console.
24512451
2452− keepinitrd [HW,ARM]
2452+ keepinitrd [HW,ARM] See retain_initrd.
24532453
24542454 kernelcore= [KNL,X86,IA-64,PPC]
24552455 Format: nn[KMGTPE] | nn% | "mirror"
@@ -5604,7 +5604,8 @@ · 3148 unmodified lines
56045604 Useful for devices that are detected asynchronously
56055605 (e.g. USB and MMC devices).
56065606
5607− retain_initrd [RAM] Keep initrd memory after extraction
5607+ retain_initrd [RAM] Keep initrd memory after extraction. After boot, it will
5608+ be accessible via /sys/firmware/initrd.
56085609
56095610 retbleed= [X86] Control mitigation of RETBleed (Arbitrary
56105611 Speculative Code Execution with Return Instructions)
arch/arm64/Kconfig+1−0
@@ -133,6 +133,7 @@ config ARM64 · 132 unmodified lines
133133 select GENERIC_ARCH_TOPOLOGY
134134 select GENERIC_CLOCKEVENTS_BROADCAST
135135 select GENERIC_CPU_AUTOPROBE
136+ select GENERIC_CPU_DEVICES
136137 select GENERIC_CPU_VULNERABILITIES
137138 select GENERIC_EARLY_IOREMAP
138139 select GENERIC_IDLE_POLL_SETUP
arch/arm64/include/asm/cpu.h+0−1
@@ -38,7 +38,6 @@ struct cpuinfo_32bit { · 37 unmodified lines
3838 };
3939
4040 struct cpuinfo_arm64 {
41− struct cpu cpu;
4241 struct kobject kobj;
4342 u64 reg_ctr;
4443 u64 reg_cntfrq;
arch/arm64/kernel/setup.c+2−11
@@ -402,19 +402,10 @@ static inline bool cpu_can_disable(unsigned int cpu) · 401 unmodified lines
402402 return false;
403403 }
404404
405−static int __init topology_init(void)
405+bool arch_cpu_is_hotpluggable(int num)
406406 {
407− int i;
408−
409− for_each_possible_cpu(i) {
410− struct cpu *cpu = &per_cpu(cpu_data.cpu, i);
411− cpu->hotpluggable = cpu_can_disable(i);
412− register_cpu(cpu, i);
413− }
414−
415− return 0;
407+ return cpu_can_disable(num);
416408 }
417−subsys_initcall(topology_init);
418409
419410 static void dump_kernel_offset(void)
420411 {
arch/loongarch/Kconfig+2−0
@@ -5,6 +5,7 @@ config LOONGARCH · 4 unmodified lines
55 select ACPI
66 select ACPI_GENERIC_GSI if ACPI
77 select ACPI_MCFG if ACPI
8+ select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
89 select ACPI_PPTT if ACPI
910 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
1011 select ARCH_BINFMT_ELF_STATE
@@ -71,6 +72,7 @@ config LOONGARCH · 60 unmodified lines
7172 select GENERIC_CLOCKEVENTS
7273 select GENERIC_CMOS_UPDATE
7374 select GENERIC_CPU_AUTOPROBE
75+ select GENERIC_CPU_DEVICES
7476 select GENERIC_ENTRY
7577 select GENERIC_GETTIMEOFDAY
7678 select GENERIC_IOREMAP if !ARCH_IOREMAP
arch/loongarch/kernel/topology.c+2−40
@@ -10,47 +10,9 @@ · 9 unmodified lines
1010
1111 #include <acpi/processor.h>
1212
13−static DEFINE_PER_CPU(struct cpu, cpu_devices);
14−
1513 #ifdef CONFIG_HOTPLUG_CPU
16−int arch_register_cpu(int cpu)
14+bool arch_cpu_is_hotpluggable(int cpu)
1715 {
18− int ret;
19− struct cpu *c = &per_cpu(cpu_devices, cpu);
20−
21− c->hotpluggable = 1;
22− ret = register_cpu(c, cpu);
23− if (ret < 0)
24− pr_warn("register_cpu %d failed (%d)\n", cpu, ret);
25−
26− return ret;
27−}
28−EXPORT_SYMBOL(arch_register_cpu);
29−
30−void arch_unregister_cpu(int cpu)
31−{
32− struct cpu *c = &per_cpu(cpu_devices, cpu);
33−
34− c->hotpluggable = 0;
35− unregister_cpu(c);
16+ return !io_master(cpu);
3617 }
37−EXPORT_SYMBOL(arch_unregister_cpu);
3818 #endif
39−
40−static int __init topology_init(void)
41−{
42− int i, ret;
43−
44− for_each_present_cpu(i) {
45− struct cpu *c = &per_cpu(cpu_devices, i);
46−
47− c->hotpluggable = !io_master(i);
48− ret = register_cpu(c, i);
49− if (ret < 0)
50− pr_warn("topology_init: register_cpu %d failed (%d)\n", i, ret);
51− }
52−
53− return 0;
54−}
55−
56−subsys_initcall(topology_init);
arch/riscv/Kconfig+1−0
@@ -72,6 +72,7 @@ config RISCV · 71 unmodified lines
7272 select GENERIC_ARCH_TOPOLOGY
7373 select GENERIC_ATOMIC64 if !64BIT
7474 select GENERIC_CLOCKEVENTS_BROADCAST if SMP
75+ select GENERIC_CPU_DEVICES
7576 select GENERIC_EARLY_IOREMAP
7677 select GENERIC_ENTRY
7778 select GENERIC_GETTIMEOFDAY if HAVE_GENERIC_VDSO
arch/riscv/kernel/setup.c+2−16
@@ -50,7 +50,6 @@ atomic_t hart_lottery __section(".sdata") · 49 unmodified lines
5050 #endif
5151 ;
5252 unsigned long boot_cpu_hartid;
53−static DEFINE_PER_CPU(struct cpu, cpu_devices);
5453
5554 /*
5655 * Place kernel memory regions on the resource tree so that
@@ -298,23 +297,10 @@ void __init setup_arch(char **cmdline_p) · 241 unmodified lines
298297 riscv_user_isa_enable();
299298 }
300299
301−static int __init topology_init(void)
300+bool arch_cpu_is_hotpluggable(int cpu)
302301 {
303− int i, ret;
304−
305− for_each_possible_cpu(i) {
306− struct cpu *cpu = &per_cpu(cpu_devices, i);
307−
308− cpu->hotpluggable = cpu_has_hotplug(i);
309− ret = register_cpu(cpu, i);
310− if (unlikely(ret))
311− pr_warn("Warning: %s: register_cpu %d failed (%d)\n",
312− __func__, i, ret);
313− }
314−
315− return 0;
302+ return cpu_has_hotplug(cpu);
316303 }
317−subsys_initcall(topology_init);
318304
319305 void free_initmem(void)
320306 {
arch/x86/Kconfig+2−0
@@ -59,6 +59,7 @@ config X86 · 58 unmodified lines
5959 #
6060 select ACPI_LEGACY_TABLES_LOOKUP if ACPI
6161 select ACPI_SYSTEM_POWER_STATES_SUPPORT if ACPI
62+ select ACPI_HOTPLUG_CPU if ACPI_PROCESSOR && HOTPLUG_CPU
6263 select ARCH_32BIT_OFF_T if X86_32
6364 select ARCH_CLOCKSOURCE_INIT
6465 select ARCH_CORRECT_STACKTRACE_ON_KRETPROBE
@@ -148,6 +149,7 @@ config X86 · 83 unmodified lines
148149 select GENERIC_CLOCKEVENTS_MIN_ADJUST
149150 select GENERIC_CMOS_UPDATE
150151 select GENERIC_CPU_AUTOPROBE
152+ select GENERIC_CPU_DEVICES
151153 select GENERIC_CPU_VULNERABILITIES
152154 select GENERIC_EARLY_IOREMAP
153155 select GENERIC_ENTRY
arch/x86/include/asm/cpu.h+0−4
@@ -23,10 +23,6 @@ static inline void prefill_possible_map(void) {} · 22 unmodified lines
2323
2424 #endif /* CONFIG_SMP */
2525
26−struct x86_cpu {
27− struct cpu cpu;
28−};
29−
3026 #ifdef CONFIG_HOTPLUG_CPU
3127 extern void soft_restart_cpu(void);
3228 #endif
arch/x86/kernel/topology.c+2−31
@@ -35,38 +35,9 @@ · 34 unmodified lines
3535 #include <asm/io_apic.h>
3636 #include <asm/cpu.h>
3737
38−static DEFINE_PER_CPU(struct x86_cpu, cpu_devices);
39−
4038 #ifdef CONFIG_HOTPLUG_CPU
41−int arch_register_cpu(int cpu)
39+bool arch_cpu_is_hotpluggable(int cpu)
4240 {
43− struct x86_cpu *xc = per_cpu_ptr(&cpu_devices, cpu);
44−
45− xc->cpu.hotpluggable = cpu > 0;
46− return register_cpu(&xc->cpu, cpu);
47−}
48−EXPORT_SYMBOL(arch_register_cpu);
49−
50−void arch_unregister_cpu(int num)
51−{
52− unregister_cpu(&per_cpu(cpu_devices, num).cpu);
53−}
54−EXPORT_SYMBOL(arch_unregister_cpu);
55−#else /* CONFIG_HOTPLUG_CPU */
56−
57−int __init arch_register_cpu(int num)
58−{
59− return register_cpu(&per_cpu(cpu_devices, num).cpu, num);
41+ return cpu > 0;
6042 }
6143 #endif /* CONFIG_HOTPLUG_CPU */
62−
63−static int __init topology_init(void)
64−{
65− int i;
66−
67− for_each_present_cpu(i)
68− arch_register_cpu(i);
69−
70− return 0;
71−}
72−subsys_initcall(topology_init);
drivers/acpi/Kconfig+0−1
@@ -314,7 +314,6 @@ config ACPI_HOTPLUG_CPU · 313 unmodified lines
314314 bool
315315 depends on ACPI_PROCESSOR && HOTPLUG_CPU
316316 select ACPI_CONTAINER
317− default y
318317
319318 config ACPI_PROCESSOR_AGGREGATOR
320319 tristate "Processor Aggregator"
drivers/acpi/acpi_processor.c+0−18
@@ -184,24 +184,6 @@ static void __init acpi_pcc_cpufreq_init(void) {} · 183 unmodified lines
184184
185185 /* Initialization */
186186 #ifdef CONFIG_ACPI_HOTPLUG_CPU
187−int __weak acpi_map_cpu(acpi_handle handle,
188− phys_cpuid_t physid, u32 acpi_id, int *pcpu)
189−{
190− return -ENODEV;
191−}
192−
193−int __weak acpi_unmap_cpu(int cpu)
194−{
195− return -ENODEV;
196−}
197−
198−int __weak arch_register_cpu(int cpu)
199−{
200− return -ENODEV;
201−}
202−
203−void __weak arch_unregister_cpu(int cpu) {}
204−
205187 static int acpi_processor_hotadd_init(struct acpi_processor *pr)
206188 {
207189 unsigned long long sta;
drivers/acpi/property.c+4−0
@@ -881,6 +881,7 @@ static struct fwnode_handle *acpi_parse_string_ref(const struct fwnode_handle *f · 880 unmodified lines
881881 * @index: Index of the reference to return
882882 * @num_args: Maximum number of arguments after each reference
883883 * @args: Location to store the returned reference with optional arguments
884+ * (may be NULL)
884885 *
885886 * Find property with @name, verifify that it is a package containing at least
886887 * one object reference and if so, store the ACPI device object pointer to the
@@ -938,6 +939,9 @@ int __acpi_node_get_property_reference(const struct fwnode_handle *fwnode, · 51 unmodified lines
938939 if (!device)
939940 return -EINVAL;
940941
942+ if (!args)
943+ return 0;
944+
941945 args->fwnode = acpi_fwnode_handle(device);
942946 args->nargs = 0;
943947
drivers/base/arch_topology.c+26−12
@@ -219,20 +219,34 @@ static DECLARE_WORK(update_topology_flags_work, update_topology_flags_workfn); · 218 unmodified lines
219219
220220 static DEVICE_ATTR_RO(cpu_capacity);
221221
222−static int register_cpu_capacity_sysctl(void)
222+static int cpu_capacity_sysctl_add(unsigned int cpu)
223223 {
224− int i;
225− struct device *cpu;
224+ struct device *cpu_dev = get_cpu_device(cpu);
226225
227− for_each_possible_cpu(i) {
228− cpu = get_cpu_device(i);
229− if (!cpu) {
230− pr_err("%s: too early to get CPU%d device!\n",
231− __func__, i);
232− continue;
233− }
234− device_create_file(cpu, &dev_attr_cpu_capacity);
235− }
226+ if (!cpu_dev)
227+ return -ENOENT;
228+
229+ device_create_file(cpu_dev, &dev_attr_cpu_capacity);
230+
231+ return 0;
232+}
233+
234+static int cpu_capacity_sysctl_remove(unsigned int cpu)
235+{
236+ struct device *cpu_dev = get_cpu_device(cpu);
237+
238+ if (!cpu_dev)
239+ return -ENOENT;
240+
241+ device_remove_file(cpu_dev, &dev_attr_cpu_capacity);
242+
243+ return 0;
244+}
245+
246+static int register_cpu_capacity_sysctl(void)
247+{
248+ cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "topology/cpu-capacity",
249+ cpu_capacity_sysctl_add, cpu_capacity_sysctl_remove);
236250
237251 return 0;
238252 }
drivers/base/auxiliary.c+1−1
@@ -244,7 +244,7 @@ static void auxiliary_bus_shutdown(struct device *dev) · 243 unmodified lines
244244 auxdrv->shutdown(auxdev);
245245 }
246246
247−static struct bus_type auxiliary_bus_type = {
247+static const struct bus_type auxiliary_bus_type = {
248248 .name = "auxiliary",
249249 .probe = auxiliary_bus_probe,
250250 .remove = auxiliary_bus_remove,
drivers/base/bus.c+4−4
@@ -1030,7 +1030,7 @@ static void device_insertion_sort_klist(struct device *a, struct list_head *list · 1029 unmodified lines
10301030 list_move_tail(&a->p->knode_bus.n_node, list);
10311031 }
10321032
1033−void bus_sort_breadthfirst(struct bus_type *bus,
1033+void bus_sort_breadthfirst(const struct bus_type *bus,
10341034 int (*compare)(const struct device *a,
10351035 const struct device *b))
10361036 {
@@ -1194,7 +1194,7 @@ static void system_root_device_release(struct device *dev) · 157 unmodified lines
11941194 kfree(dev);
11951195 }
11961196
1197−static int subsys_register(struct bus_type *subsys,
1197+static int subsys_register(const struct bus_type *subsys,
11981198 const struct attribute_group **groups,
11991199 struct kobject *parent_of_root)
12001200 {
@@ -1264,7 +1264,7 @@ err_sp: · 63 unmodified lines
12641264 * directory itself and not some create fake root-device placed in
12651265 * /sys/devices/system/<name>.
12661266 */
1267−int subsys_system_register(struct bus_type *subsys,
1267+int subsys_system_register(const struct bus_type *subsys,
12681268 const struct attribute_group **groups)
12691269 {
12701270 return subsys_register(subsys, groups, &system_kset->kobj);
@@ -1282,7 +1282,7 @@ EXPORT_SYMBOL_GPL(subsys_system_register); · 11 unmodified lines
12821282 * There's no restriction on device naming. This is for kernel software
12831283 * constructs which need sysfs interface.
12841284 */
1285−int subsys_virtual_register(struct bus_type *subsys,
1285+int subsys_virtual_register(const struct bus_type *subsys,
12861286 const struct attribute_group **groups)
12871287 {
12881288 struct kobject *virtual_dir;
drivers/base/class.c+1−0
@@ -213,6 +213,7 @@ int class_register(const struct class *cls) · 212 unmodified lines
213213 return 0;
214214
215215 err_out:
216+ lockdep_unregister_key(key);
216217 kfree(cp);
217218 return error;
218219 }
drivers/base/container.c+1−1
@@ -24,7 +24,7 @@ static int container_offline(struct device *dev) · 23 unmodified lines
2424 return cdev->offline ? cdev->offline(cdev) : 0;
2525 }
2626
27−struct bus_type container_subsys = {
27+const struct bus_type container_subsys = {
2828 .name = CONTAINER_BUS_NAME,
2929 .dev_name = CONTAINER_BUS_NAME,
3030 .online = trivial_online,
drivers/base/core.c+7−6
@@ -298,7 +298,7 @@ static inline bool device_link_flag_is_sync_state_only(u32 flags) · 297 unmodified lines
298298 * Check if @target depends on @dev or any device dependent on it (its child or
299299 * its consumer etc). Return 1 if that is the case or 0 otherwise.
300300 */
301−int device_is_dependent(struct device *dev, void *target)
301+static int device_is_dependent(struct device *dev, void *target)
302302 {
303303 struct device_link *link;
304304 int ret;
@@ -1641,7 +1641,7 @@ static void device_links_purge(struct device *dev) · 1336 unmodified lines
16411641 #define FW_DEVLINK_FLAGS_RPM (FW_DEVLINK_FLAGS_ON | \
16421642 DL_FLAG_PM_RUNTIME)
16431643
1644−static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_ON;
1644+static u32 fw_devlink_flags = FW_DEVLINK_FLAGS_RPM;
16451645 static int __init fw_devlink_setup(char *arg)
16461646 {
16471647 if (!arg)
@@ -4944,13 +4944,14 @@ define_dev_printk_level(_dev_info, KERN_INFO); · 3296 unmodified lines
49444944 *
49454945 * return dev_err_probe(dev, err, ...);
49464946 *
4947− * Note that it is deemed acceptable to use this function for error
4948− * prints during probe even if the @err is known to never be -EPROBE_DEFER.
4947+ * Using this helper in your probe function is totally fine even if @err is
4948+ * known to never be -EPROBE_DEFER.
49494949 * The benefit compared to a normal dev_err() is the standardized format
4950− * of the error code and the fact that the error code is returned.
4950+ * of the error code, it being emitted symbolically (i.e. you get "EAGAIN"
4951+ * instead of "-35") and the fact that the error code is returned which allows
4952+ * more compact error paths.
49514953 *
49524954 * Returns @err.
4953− *
49544955 */
49554956 int dev_err_probe(const struct device *dev, int err, const char *fmt, ...)
49564957 {
drivers/base/cpu.c+31−8
@@ -525,19 +525,42 @@ bool cpu_is_hotpluggable(unsigned int cpu) · 524 unmodified lines
525525 EXPORT_SYMBOL_GPL(cpu_is_hotpluggable);
526526
527527 #ifdef CONFIG_GENERIC_CPU_DEVICES
528−static DEFINE_PER_CPU(struct cpu, cpu_devices);
529−#endif
528+DEFINE_PER_CPU(struct cpu, cpu_devices);
529+
530+bool __weak arch_cpu_is_hotpluggable(int cpu)
531+{
532+ return false;
533+}
534+
535+int __weak arch_register_cpu(int cpu)
536+{
537+ struct cpu *c = &per_cpu(cpu_devices, cpu);
538+
539+ c->hotpluggable = arch_cpu_is_hotpluggable(cpu);
540+
541+ return register_cpu(c, cpu);
542+}
543+
544+#ifdef CONFIG_HOTPLUG_CPU
545+void __weak arch_unregister_cpu(int num)
546+{
547+ unregister_cpu(&per_cpu(cpu_devices, num));
548+}
549+#endif /* CONFIG_HOTPLUG_CPU */
550+#endif /* CONFIG_GENERIC_CPU_DEVICES */
530551
531552 static void __init cpu_dev_register_generic(void)
532553 {
533−#ifdef CONFIG_GENERIC_CPU_DEVICES
534− int i;
554+ int i, ret;
535555
536− for_each_possible_cpu(i) {
537− if (register_cpu(&per_cpu(cpu_devices, i), i))
538− panic("Failed to register CPU device");
556+ if (!IS_ENABLED(CONFIG_GENERIC_CPU_DEVICES))
557+ return;
558+
559+ for_each_present_cpu(i) {
560+ ret = arch_register_cpu(i);
561+ if (ret)
562+ pr_warn("register_cpu %d failed (%d)\n", i, ret);
539563 }
540−#endif
541564 }
542565
543566 #ifdef CONFIG_GENERIC_CPU_VULNERABILITIES
drivers/base/dd.c+1−1
@@ -313,7 +313,7 @@ static void deferred_probe_timeout_work_func(struct work_struct *work) · 312 unmodified lines
313313
314314 mutex_lock(&deferred_probe_mutex);
315315 list_for_each_entry(p, &deferred_probe_pending_list, deferred_probe)
316− dev_info(p->device, "deferred probe pending\n");
316+ dev_info(p->device, "deferred probe pending: %s", p->deferred_probe_reason ?: "(reason unknown)\n");
317317 mutex_unlock(&deferred_probe_mutex);
318318
319319 fw_devlink_probing_done();
drivers/base/init.c+1−1
@@ -35,8 +35,8 @@ void __init driver_init(void) · 34 unmodified lines
3535 of_core_init();
3636 platform_bus_init();
3737 auxiliary_bus_init();
38− cpu_dev_init();
3938 memory_dev_init();
4039 node_dev_init();
40+ cpu_dev_init();
4141 container_dev_init();
4242 }
drivers/base/isa.c+1−1
@@ -82,7 +82,7 @@ static int isa_bus_resume(struct device *dev) · 81 unmodified lines
8282 return 0;
8383 }
8484
85−static struct bus_type isa_bus_type = {
85+static const struct bus_type isa_bus_type = {
8686 .name = "isa",
8787 .match = isa_bus_match,
8888 .probe = isa_bus_probe,
drivers/base/memory.c+1−1
@@ -68,7 +68,7 @@ static inline unsigned long phys_to_block_id(unsigned long phys) · 67 unmodified lines
6868 static int memory_subsys_online(struct device *dev);
6969 static int memory_subsys_offline(struct device *dev);
7070
71−static struct bus_type memory_subsys = {
71+static const struct bus_type memory_subsys = {
7272 .name = MEMORY_CLASS_NAME,
7373 .dev_name = MEMORY_CLASS_NAME,
7474 .online = memory_subsys_online,
drivers/base/node.c+7−4
@@ -21,7 +21,7 @@ · 20 unmodified lines
2121 #include <linux/swap.h>
2222 #include <linux/slab.h>
2323
24−static struct bus_type node_subsys = {
24+static const struct bus_type node_subsys = {
2525 .name = "node",
2626 .dev_name = "node",
2727 };
@@ -868,11 +868,15 @@ int __register_one_node(int nid) · 840 unmodified lines
868868 {
869869 int error;
870870 int cpu;
871+ struct node *node;
871872
872− node_devices[nid] = kzalloc(sizeof(struct node), GFP_KERNEL);
873− if (!node_devices[nid])
873+ node = kzalloc(sizeof(struct node), GFP_KERNEL);
874+ if (!node)
874875 return -ENOMEM;
875876
877+ INIT_LIST_HEAD(&node->access_list);
878+ node_devices[nid] = node;
879+
876880 error = register_node(node_devices[nid], nid);
877881
878882 /* link cpu under this node */
@@ -881,7 +885,6 @@ int __register_one_node(int nid) · 2 unmodified lines
881885 register_cpu_under_node(cpu, nid);
882886 }
883887
884− INIT_LIST_HEAD(&node_devices[nid]->access_list);
885888 node_init_caches(nid);
886889
887890 return error;
drivers/base/power/clock_ops.c+1−1
@@ -793,7 +793,7 @@ static int pm_clk_notify(struct notifier_block *nb, · 792 unmodified lines
793793 * the remaining members of @clknb should be populated prior to calling this
794794 * routine.
795795 */
796−void pm_clk_add_notifier(struct bus_type *bus,
796+void pm_clk_add_notifier(const struct bus_type *bus,
797797 struct pm_clk_notifier_block *clknb)
798798 {
799799 if (!bus || !clknb)
drivers/base/property.c+1−0
@@ -543,6 +543,7 @@ EXPORT_SYMBOL_GPL(fwnode_property_match_property_string); · 542 unmodified lines
543543 * @nargs: Number of arguments. Ignored if @nargs_prop is non-NULL.
544544 * @index: Index of the reference, from zero onwards.
545545 * @args: Result structure with reference and integer arguments.
546+ * May be NULL.
546547 *
547548 * Obtain a reference based on a named property in an fwnode, with
548549 * integer arguments.
drivers/base/soc.c+3−3
@@ -28,7 +28,7 @@ struct soc_device { · 27 unmodified lines
2828 int soc_dev_num;
2929 };
3030
31−static struct bus_type soc_bus_type = {
31+static const struct bus_type soc_bus_type = {
3232 .name = "soc",
3333 };
3434 static bool soc_bus_registered;
@@ -106,7 +106,7 @@ static void soc_release(struct device *dev) · 71 unmodified lines
106106 {
107107 struct soc_device *soc_dev = container_of(dev, struct soc_device, dev);
108108
109− ida_simple_remove(&soc_ida, soc_dev->soc_dev_num);
109+ ida_free(&soc_ida, soc_dev->soc_dev_num);
110110 kfree(soc_dev->dev.groups);
111111 kfree(soc_dev);
112112 }
@@ -155,7 +155,7 @@ struct soc_device *soc_device_register(struct soc_device_attribute *soc_dev_attr · 42 unmodified lines
155155 soc_attr_groups[1] = soc_dev_attr->custom_attr_group;
156156
157157 /* Fetch a unique (reclaimable) SOC ID. */
158− ret = ida_simple_get(&soc_ida, 0, 0, GFP_KERNEL);
158+ ret = ida_alloc(&soc_ida, GFP_KERNEL);
159159 if (ret < 0)
160160 goto out3;
161161 soc_dev->soc_dev_num = ret;
drivers/base/swnode.c+7−4
@@ -541,6 +541,9 @@ software_node_get_reference_args(const struct fwnode_handle *fwnode, · 540 unmodified lines
541541 if (nargs > NR_FWNODE_REFERENCE_ARGS)
542542 return -EINVAL;
543543
544+ if (!args)
545+ return 0;
546+
544547 args->fwnode = software_node_get(refnode);
545548 args->nargs = nargs;
546549
@@ -747,10 +750,10 @@ static void software_node_release(struct kobject *kobj) · 200 unmodified lines
747750 struct swnode *swnode = kobj_to_swnode(kobj);
748751
749752 if (swnode->parent) {
750− ida_simple_remove(&swnode->parent->child_ids, swnode->id);
753+ ida_free(&swnode->parent->child_ids, swnode->id);
751754 list_del(&swnode->entry);
752755 } else {
753− ida_simple_remove(&swnode_root_ids, swnode->id);
756+ ida_free(&swnode_root_ids, swnode->id);
754757 }
755758
756759 if (swnode->allocated)
@@ -776,8 +779,8 @@ swnode_register(const struct software_node *node, struct swnode *parent, · 19 unmodified lines
776779 if (!swnode)
777780 return ERR_PTR(-ENOMEM);
778781
779− ret = ida_simple_get(parent ? &parent->child_ids : &swnode_root_ids,
780− 0, 0, GFP_KERNEL);
782+ ret = ida_alloc(parent ? &parent->child_ids : &swnode_root_ids,
783+ GFP_KERNEL);
781784 if (ret < 0) {
782785 kfree(swnode);
783786 return ERR_PTR(ret);
drivers/edac/edac_device.h+1−1
@@ -176,7 +176,7 @@ struct edac_device_ctl_info { · 175 unmodified lines
176176 struct edac_dev_sysfs_attribute *sysfs_attributes;
177177
178178 /* pointer to main 'edac' subsys in sysfs */
179− struct bus_type *edac_subsys;
179+ const struct bus_type *edac_subsys;
180180
181181 /* the internal state of this controller instance */
182182 int op_state;
drivers/edac/edac_device_sysfs.c+1−1
@@ -229,7 +229,7 @@ static struct kobj_type ktype_device_ctrl = { · 228 unmodified lines
229229 int edac_device_register_sysfs_main_kobj(struct edac_device_ctl_info *edac_dev)
230230 {
231231 struct device *dev_root;
232− struct bus_type *edac_subsys;
232+ const struct bus_type *edac_subsys;
233233 int err = -ENODEV;
234234
235235 edac_dbg(1, "\n");
drivers/edac/edac_module.c+2−2
@@ -67,7 +67,7 @@ char *edac_op_state_to_string(int opstate) · 66 unmodified lines
6767 * sysfs object: /sys/devices/system/edac
6868 * need to export to other files
6969 */
70−static struct bus_type edac_subsys = {
70+static const struct bus_type edac_subsys = {
7171 .name = "edac",
7272 .dev_name = "edac",
7373 };
@@ -90,7 +90,7 @@ static void edac_subsys_exit(void) · 16 unmodified lines
9090 }
9191
9292 /* return pointer to the 'edac' node in sysfs */
93−struct bus_type *edac_get_sysfs_subsys(void)
93+const struct bus_type *edac_get_sysfs_subsys(void)
9494 {
9595 return &edac_subsys;
9696 }
drivers/edac/edac_pci_sysfs.c+1−1
@@ -338,7 +338,7 @@ static struct kobj_type ktype_edac_pci_main_kobj = { · 337 unmodified lines
338338 static int edac_pci_main_kobj_setup(void)
339339 {
340340 int err = -ENODEV;
341− struct bus_type *edac_subsys;
341+ const struct bus_type *edac_subsys;
342342 struct device *dev_root;
343343
344344 edac_dbg(0, "\n");
drivers/pmdomain/core.c+1−1
@@ -2668,7 +2668,7 @@ static void genpd_release_dev(struct device *dev) · 2667 unmodified lines
26682668 kfree(dev);
26692669 }
26702670
2671−static struct bus_type genpd_bus_type = {
2671+static const struct bus_type genpd_bus_type = {
26722672 .name = "genpd",
26732673 };
26742674
fs/kernfs/dir.c+37−25
@@ -54,9 +54,9 @@ static bool kernfs_lockdep(struct kernfs_node *kn) · 53 unmodified lines
5454 static int kernfs_name_locked(struct kernfs_node *kn, char *buf, size_t buflen)
5555 {
5656 if (!kn)
57− return strlcpy(buf, "(null)", buflen);
57+ return strscpy(buf, "(null)", buflen);
5858
59− return strlcpy(buf, kn->parent ? kn->name : "/", buflen);
59+ return strscpy(buf, kn->parent ? kn->name : "/", buflen);
6060 }
6161
6262 /* kernfs_node_depth - compute depth from @from to @to */
@@ -127,7 +127,7 @@ static struct kernfs_node *kernfs_common_ancestor(struct kernfs_node *a, · 64 unmodified lines
127127 *
128128 * [3] when @kn_to is %NULL result will be "(null)"
129129 *
130− * Return: the length of the full path. If the full length is equal to or
130+ * Return: the length of the constructed path. If the path would have been
131131 * greater than @buflen, @buf contains the truncated path with the trailing
132132 * '\0'. On error, -errno is returned.
133133 */
@@ -138,16 +138,17 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 4 unmodified lines
138138 struct kernfs_node *kn, *common;
139139 const char parent_str[] = "/..";
140140 size_t depth_from, depth_to, len = 0;
141+ ssize_t copied;
141142 int i, j;
142143
143144 if (!kn_to)
144− return strlcpy(buf, "(null)", buflen);
145+ return strscpy(buf, "(null)", buflen);
145146
146147 if (!kn_from)
147148 kn_from = kernfs_root(kn_to)->kn;
148149
149150 if (kn_from == kn_to)
150− return strlcpy(buf, "/", buflen);
151+ return strscpy(buf, "/", buflen);
151152
152153 common = kernfs_common_ancestor(kn_from, kn_to);
153154 if (WARN_ON(!common))
@@ -158,18 +159,19 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 4 unmodified lines
158159
159160 buf[0] = '\0';
160161
161− for (i = 0; i < depth_from; i++)
162− len += strlcpy(buf + len, parent_str,
163− len < buflen ? buflen - len : 0);
162+ for (i = 0; i < depth_from; i++) {
163+ copied = strscpy(buf + len, parent_str, buflen - len);
164+ if (copied < 0)
165+ return copied;
166+ len += copied;
167+ }
164168
165169 /* Calculate how many bytes we need for the rest */
166170 for (i = depth_to - 1; i >= 0; i--) {
167171 for (kn = kn_to, j = 0; j < i; j++)
168172 kn = kn->parent;
169− len += strlcpy(buf + len, "/",
170− len < buflen ? buflen - len : 0);
171− len += strlcpy(buf + len, kn->name,
172− len < buflen ? buflen - len : 0);
173+
174+ len += scnprintf(buf + len, buflen - len, "/%s", kn->name);
173175 }
174176
175177 return len;
@@ -182,12 +184,12 @@ static int kernfs_path_from_node_locked(struct kernfs_node *kn_to, · 6 unmodified lines
182184 * @buflen: size of @buf
183185 *
184186 * Copies the name of @kn into @buf of @buflen bytes. The behavior is
185− * similar to strlcpy().
187+ * similar to strscpy().
186188 *
187189 * Fills buffer with "(null)" if @kn is %NULL.
188190 *
189− * Return: the length of @kn's name and if @buf isn't long enough,
190− * it's filled up to @buflen-1 and nul terminated.
191+ * Return: the resulting length of @buf. If @buf isn't long enough,
192+ * it's filled up to @buflen-1 and nul terminated, and returns -E2BIG.
191193 *
192194 * This function can be called from any context.
193195 */
@@ -214,7 +216,7 @@ int kernfs_name(struct kernfs_node *kn, char *buf, size_t buflen) · 20 unmodified lines
214216 * path (which includes '..'s) as needed to reach from @from to @to is
215217 * returned.
216218 *
217− * Return: the length of the full path. If the full length is equal to or
219+ * Return: the length of the constructed path. If the path would have been
218220 * greater than @buflen, @buf contains the truncated path with the trailing
219221 * '\0'. On error, -errno is returned.
220222 */
@@ -265,12 +267,10 @@ void pr_cont_kernfs_path(struct kernfs_node *kn) · 44 unmodified lines
265267 sz = kernfs_path_from_node(kn, NULL, kernfs_pr_cont_buf,
266268 sizeof(kernfs_pr_cont_buf));
267269 if (sz < 0) {
268− pr_cont("(error)");
269− goto out;
270− }
271−
272− if (sz >= sizeof(kernfs_pr_cont_buf)) {
273− pr_cont("(name too long)");
270+ if (sz == -E2BIG)
271+ pr_cont("(name too long)");
272+ else
273+ pr_cont("(error)");
274274 goto out;
275275 }
276276
@@ -676,6 +676,18 @@ struct kernfs_node *kernfs_new_node(struct kernfs_node *parent, · 399 unmodified lines
676676 {
677677 struct kernfs_node *kn;
678678
679+ if (parent->mode & S_ISGID) {
680+ /* this code block imitates inode_init_owner() for
681+ * kernfs
682+ */
683+
684+ if (parent->iattr)
685+ gid = parent->iattr->ia_gid;
686+
687+ if (flags & KERNFS_DIR)
688+ mode |= S_ISGID;
689+ }
690+
679691 kn = __kernfs_new_node(kernfs_root(parent), parent,
680692 name, mode, uid, gid, flags);
681693 if (kn) {
@@ -850,16 +862,16 @@ static struct kernfs_node *kernfs_walk_ns(struct kernfs_node *parent, · 168 unmodified lines
850862 const unsigned char *path,
851863 const void *ns)
852864 {
853− size_t len;
865+ ssize_t len;
854866 char *p, *name;
855867
856868 lockdep_assert_held_read(&kernfs_root(parent)->kernfs_rwsem);
857869
858870 spin_lock_irq(&kernfs_pr_cont_lock);
859871
860− len = strlcpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
872+ len = strscpy(kernfs_pr_cont_buf, path, sizeof(kernfs_pr_cont_buf));
861873
862− if (len >= sizeof(kernfs_pr_cont_buf)) {
874+ if (len < 0) {
863875 spin_unlock_irq(&kernfs_pr_cont_lock);
864876 return NULL;
865877 }
fs/kernfs/file.c+1−1
@@ -447,7 +447,7 @@ static int kernfs_fop_mmap(struct file *file, struct vm_area_struct *vma) · 446 unmodified lines
447447 * warnings and we don't want to add spurious locking dependency
448448 * between the two. Check whether mmap is actually implemented
449449 * without grabbing @of->mutex by testing HAS_MMAP flag. See the
450− * comment in kernfs_file_open() for more details.
450+ * comment in kernfs_fop_open() for more details.
451451 */
452452 if (!(of->kn->flags & KERNFS_HAS_MMAP))
453453 return -ENODEV;
fs/kernfs/mount.c+0−3
@@ -125,9 +125,6 @@ static struct dentry *__kernfs_fh_to_dentry(struct super_block *sb, · 124 unmodified lines
125125
126126 inode = kernfs_get_inode(sb, kn);
127127 kernfs_put(kn);
128− if (!inode)
129− return ERR_PTR(-ESTALE);
130−
131128 return d_obtain_alias(inode);
132129 }
133130
fs/sysfs/dir.c+1−1
@@ -81,7 +81,7 @@ void sysfs_remove_dir(struct kobject *kobj) · 80 unmodified lines
8181 struct kernfs_node *kn = kobj->sd;
8282
8383 /*
84− * In general, kboject owner is responsible for ensuring removal
84+ * In general, kobject owner is responsible for ensuring removal
8585 * doesn't race with other operations and sysfs doesn't provide any
8686 * protection; however, when @kobj is used as a symlink target, the
8787 * symlinking entity usually doesn't own @kobj and thus has no
include/linux/container.h+1−1
@@ -12,7 +12,7 @@ · 11 unmodified lines
1212 #include <linux/device.h>
1313
1414 /* drivers/base/power/container.c */
15−extern struct bus_type container_subsys;
15+extern const struct bus_type container_subsys;
1616
1717 struct container_dev {
1818 struct device dev;
include/linux/cpu.h+5−0
@@ -80,6 +80,7 @@ extern __printf(4, 5) · 79 unmodified lines
8080 struct device *cpu_device_create(struct device *parent, void *drvdata,
8181 const struct attribute_group **groups,
8282 const char *fmt, ...);
83+extern bool arch_cpu_is_hotpluggable(int cpu);
8384 extern int arch_register_cpu(int cpu);
8485 extern void arch_unregister_cpu(int cpu);
8586 #ifdef CONFIG_HOTPLUG_CPU
@@ -88,6 +89,10 @@ extern ssize_t arch_cpu_probe(const char *, size_t); · 2 unmodified lines
8889 extern ssize_t arch_cpu_release(const char *, size_t);
8990 #endif
9091
92+#ifdef CONFIG_GENERIC_CPU_DEVICES
93+DECLARE_PER_CPU(struct cpu, cpu_devices);
94+#endif
95+
9196 /*
9297 * These states are not related to the core CPU hotplug mechanism. They are
9398 * used by various (sub)architectures to track internal state
include/linux/device.h+3−5
@@ -63,7 +63,7 @@ struct msi_device_data; · 62 unmodified lines
6363 */
6464 struct subsys_interface {
6565 const char *name;
66− struct bus_type *subsys;
66+ const struct bus_type *subsys;
6767 struct list_head node;
6868 int (*add_dev)(struct device *dev, struct subsys_interface *sif);
6969 void (*remove_dev)(struct device *dev, struct subsys_interface *sif);
@@ -72,9 +72,9 @@ struct subsys_interface { · 2 unmodified lines
7272 int subsys_interface_register(struct subsys_interface *sif);
7373 void subsys_interface_unregister(struct subsys_interface *sif);
7474
75−int subsys_system_register(struct bus_type *subsys,
75+int subsys_system_register(const struct bus_type *subsys,
7676 const struct attribute_group **groups);
77−int subsys_virtual_register(struct bus_type *subsys,
77+int subsys_virtual_register(const struct bus_type *subsys,
7878 const struct attribute_group **groups);
7979
8080 /*
@@ -662,7 +662,6 @@ struct device_physical_location { · 581 unmodified lines
662662 * @id: device instance
663663 * @devres_lock: Spinlock to protect the resource of the device.
664664 * @devres_head: The resources list of the device.
665− * @knode_class: The node used to add the device to the class list.
666665 * @class: The class of the device.
667666 * @groups: Optional attribute groups.
668667 * @release: Callback to free the device after all references have
@@ -1073,7 +1072,6 @@ int device_rename(struct device *dev, const char *new_name); · 404 unmodified lines
10731072 int device_move(struct device *dev, struct device *new_parent,
10741073 enum dpm_order dpm_order);
10751074 int device_change_owner(struct device *dev, kuid_t kuid, kgid_t kgid);
1076−int device_is_dependent(struct device *dev, void *target);
10771075
10781076 static inline bool device_supports_offline(struct device *dev)
10791077 {
include/linux/device/bus.h+1−1
@@ -232,7 +232,7 @@ bus_find_device_by_acpi_dev(const struct bus_type *bus, const void *adev) · 231 unmodified lines
232232
233233 int bus_for_each_drv(const struct bus_type *bus, struct device_driver *start,
234234 void *data, int (*fn)(struct device_driver *, void *));
235−void bus_sort_breadthfirst(struct bus_type *bus,
235+void bus_sort_breadthfirst(const struct bus_type *bus,
236236 int (*compare)(const struct device *a,
237237 const struct device *b));
238238 /*
include/linux/device/class.h+0−2
@@ -40,8 +40,6 @@ struct fwnode_handle; · 39 unmodified lines
4040 * for the devices belonging to the class. Usually tied to
4141 * device's namespace.
4242 * @pm: The default device power management operations of this class.
43− * @p: The private data of the driver core, no one other than the
44− * driver core can touch this.
4543 *
4644 * A class is a higher-level view of a device that abstracts out low-level
4745 * implementation details. Drivers may see a SCSI disk or an ATA disk, but,
include/linux/edac.h+2−2
@@ -30,7 +30,7 @@ struct device; · 29 unmodified lines
3030
3131 extern int edac_op_state;
3232
33−struct bus_type *edac_get_sysfs_subsys(void);
33+const struct bus_type *edac_get_sysfs_subsys(void);
3434
3535 static inline void opstate_init(void)
3636 {
@@ -495,7 +495,7 @@ struct edac_raw_error_desc { · 458 unmodified lines
495495 */
496496 struct mem_ctl_info {
497497 struct device dev;
498− struct bus_type *bus;
498+ const struct bus_type *bus;
499499
500500 struct list_head link; /* for global list of mem_ctl_info structs */
501501
include/linux/pm_clock.h+2−2
@@ -91,10 +91,10 @@ static inline int devm_pm_clk_create(struct device *dev) · 90 unmodified lines
9191 #endif
9292
9393 #ifdef CONFIG_HAVE_CLK
94−extern void pm_clk_add_notifier(struct bus_type *bus,
94+extern void pm_clk_add_notifier(const struct bus_type *bus,
9595 struct pm_clk_notifier_block *clknb);
9696 #else
97−static inline void pm_clk_add_notifier(struct bus_type *bus,
97+static inline void pm_clk_add_notifier(const struct bus_type *bus,
9898 struct pm_clk_notifier_block *clknb)
9999 {
100100 }
init/initramfs.c+17−1
@@ -574,6 +574,16 @@ extern unsigned long __initramfs_size; · 573 unmodified lines
574574 #include <linux/initrd.h>
575575 #include <linux/kexec.h>
576576
577+static ssize_t raw_read(struct file *file, struct kobject *kobj,
578+ struct bin_attribute *attr, char *buf,
579+ loff_t pos, size_t count)
580+{
581+ memcpy(buf, attr->private + pos, count);
582+ return count;
583+}
584+
585+static BIN_ATTR(initrd, 0440, raw_read, NULL, 0);
586+
577587 void __init reserve_initrd_mem(void)
578588 {
579589 phys_addr_t start;
@@ -715,8 +725,14 @@ done: · 135 unmodified lines
715725 * If the initrd region is overlapped with crashkernel reserved region,
716726 * free only memory that is not part of crashkernel region.
717727 */
718− if (!do_retain_initrd && initrd_start && !kexec_free_initrd())
728+ if (!do_retain_initrd && initrd_start && !kexec_free_initrd()) {
719729 free_initrd_mem(initrd_start, initrd_end);
730+ } else if (do_retain_initrd && initrd_start) {
731+ bin_attr_initrd.size = initrd_end - initrd_start;
732+ bin_attr_initrd.private = (void *)initrd_start;
733+ if (sysfs_create_bin_file(firmware_kobj, &bin_attr_initrd))
734+ pr_err("Failed to create initrd sysfs file");
735+ }
720736 initrd_start = 0;
721737 initrd_end = 0;
722738
kernel/cgroup/cgroup-v1.c+1−1
@@ -802,7 +802,7 @@ void cgroup1_release_agent(struct work_struct *work) · 801 unmodified lines
802802 goto out_free;
803803
804804 ret = cgroup_path_ns(cgrp, pathbuf, PATH_MAX, &init_cgroup_ns);
805− if (ret < 0 || ret >= PATH_MAX)
805+ if (ret < 0)
806806 goto out_free;
807807
808808 argv[0] = agentbuf;
kernel/cgroup/cgroup.c+6−29
@@ -1906,7 +1906,7 @@ int cgroup_show_path(struct seq_file *sf, struct kernfs_node *kf_node, · 1905 unmodified lines
19061906 len = kernfs_path_from_node(kf_node, ns_cgroup->kn, buf, PATH_MAX);
19071907 spin_unlock_irq(&css_set_lock);
19081908
1909− if (len >= PATH_MAX)
1909+ if (len == -E2BIG)
19101910 len = -ERANGE;
19111911 else if (len > 0) {
19121912 seq_escape(sf, buf, " \t\n\\");
@@ -4182,20 +4182,6 @@ static struct kernfs_ops cgroup_kf_ops = { · 2269 unmodified lines
41824182 .seq_show = cgroup_seqfile_show,
41834183 };
41844184
4185−/* set uid and gid of cgroup dirs and files to that of the creator */
4186−static int cgroup_kn_set_ugid(struct kernfs_node *kn)
4187−{
4188− struct iattr iattr = { .ia_valid = ATTR_UID | ATTR_GID,
4189− .ia_uid = current_fsuid(),
4190− .ia_gid = current_fsgid(), };
4191−
4192− if (uid_eq(iattr.ia_uid, GLOBAL_ROOT_UID) &&
4193− gid_eq(iattr.ia_gid, GLOBAL_ROOT_GID))
4194− return 0;
4195−
4196− return kernfs_setattr(kn, &iattr);
4197−}
4198−
41994185 static void cgroup_file_notify_timer(struct timer_list *timer)
42004186 {
42014187 cgroup_file_notify(container_of(timer, struct cgroup_file,
@@ -4208,25 +4194,18 @@ static int cgroup_add_file(struct cgroup_subsys_state *css, struct cgroup *cgrp, · 6 unmodified lines
42084194 char name[CGROUP_FILE_NAME_MAX];
42094195 struct kernfs_node *kn;
42104196 struct lock_class_key *key = NULL;
4211− int ret;
42124197
42134198 #ifdef CONFIG_DEBUG_LOCK_ALLOC
42144199 key = &cft->lockdep_key;
42154200 #endif
42164201 kn = __kernfs_create_file(cgrp->kn, cgroup_file_name(cgrp, cft, name),
42174202 cgroup_file_mode(cft),
4218− GLOBAL_ROOT_UID, GLOBAL_ROOT_GID,
4203+ current_fsuid(), current_fsgid(),
42194204 0, cft->kf_ops, cft,
42204205 NULL, key);
42214206 if (IS_ERR(kn))
42224207 return PTR_ERR(kn);
42234208
4224− ret = cgroup_kn_set_ugid(kn);
4225− if (ret) {
4226− kernfs_remove(kn);
4227− return ret;
4228− }
4229−
42304209 if (cft->file_offset) {
42314210 struct cgroup_file *cfile = (void *)css + cft->file_offset;
42324211
@@ -5629,7 +5608,9 @@ static struct cgroup *cgroup_create(struct cgroup *parent, const char *name, · 1396 unmodified lines
56295608 goto out_cancel_ref;
56305609
56315610 /* create the directory */
5632− kn = kernfs_create_dir(parent->kn, name, mode, cgrp);
5611+ kn = kernfs_create_dir_ns(parent->kn, name, mode,
5612+ current_fsuid(), current_fsgid(),
5613+ cgrp, NULL);
56335614 if (IS_ERR(kn)) {
56345615 ret = PTR_ERR(kn);
56355616 goto out_stat_exit;
@@ -5774,10 +5755,6 @@ int cgroup_mkdir(struct kernfs_node *parent_kn, const char *name, umode_t mode) · 138 unmodified lines
57745755 */
57755756 kernfs_get(cgrp->kn);
57765757
5777− ret = cgroup_kn_set_ugid(cgrp->kn);
5778− if (ret)
5779− goto out_destroy;
5780−
57815758 ret = css_populate_dir(&cgrp->self);
57825759 if (ret)
57835760 goto out_destroy;
@@ -6316,7 +6293,7 @@ int proc_cgroup_show(struct seq_file *m, struct pid_namespace *ns, · 532 unmodified lines
63166293 if (cgroup_on_dfl(cgrp) || !(tsk->flags & PF_EXITING)) {
63176294 retval = cgroup_path_ns_locked(cgrp, buf, PATH_MAX,
63186295 current->nsproxy->cgroup_ns);
6319− if (retval >= PATH_MAX)
6296+ if (retval == -E2BIG)
63206297 retval = -ENAMETOOLONG;
63216298 if (retval < 0)
63226299 goto out_unlock;
kernel/cgroup/cpuset.c+1−1
@@ -5092,7 +5092,7 @@ int proc_cpuset_show(struct seq_file *m, struct pid_namespace *ns, · 5091 unmodified lines
50925092 retval = cgroup_path_ns(css->cgroup, buf, PATH_MAX,
50935093 current->nsproxy->cgroup_ns);
50945094 css_put(css);
5095− if (retval >= PATH_MAX)
5095+ if (retval == -E2BIG)
50965096 retval = -ENAMETOOLONG;
50975097 if (retval < 0)
50985098 goto out_free;