Skip to content

Commit 0968621

Browse files
committed
Merge tag 'printk-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk
Pull printk updates from Petr Mladek: - Allow state reset of printk_once() calls. - Prevent crashes when dereferencing invalid pointers in vsprintf(). Only the first byte is checked for simplicity. - Make vsprintf warnings consistent and inlined. - Treewide conversion of obsolete %pf, %pF to %ps, %pF printf modifiers. - Some clean up of vsprintf and test_printf code. * tag 'printk-for-5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/pmladek/printk: lib/vsprintf: Make function pointer_string static vsprintf: Limit the length of inlined error messages vsprintf: Avoid confusion between invalid address and value vsprintf: Prevent crash when dereferencing invalid pointers vsprintf: Consolidate handling of unknown pointer specifiers vsprintf: Factor out %pO handler as kobject_string() vsprintf: Factor out %pV handler as va_format() vsprintf: Factor out %p[iI] handler as ip_addr_string() vsprintf: Do not check address of well-known strings vsprintf: Consistent %pK handling for kptr_restrict == 0 vsprintf: Shuffle restricted_pointer() printk: Tie printk_once / printk_deferred_once into .data.once for reset treewide: Switch printk users from %pf and %pF to %ps and %pS, respectively lib/test_printf: Switch to bitmap_zalloc()
2 parents 573de2a + 0f46c78 commit 0968621

60 files changed

Lines changed: 410 additions & 272 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎Documentation/clearing-warn-once.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
WARN_ONCE / WARN_ON_ONCE only print a warning once.
2+
WARN_ONCE / WARN_ON_ONCE / printk_once only emit a message once.
33

44
echo 1 > /sys/kernel/debug/clear_warn_once
55

‎Documentation/core-api/printk-formats.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,14 @@ A raw pointer value may be printed with %p which will hash the address
5858
before printing. The kernel also supports extended specifiers for printing
5959
pointers of different types.
6060

61+
Some of the extended specifiers print the data on the given address instead
62+
of printing the address itself. In this case, the following error messages
63+
might be printed instead of the unreachable information::
64+
65+
(null) data on plain NULL address
66+
(efault) data on invalid address
67+
(einval) invalid data on a valid address
68+
6169
Plain Pointers
6270
--------------
6371

‎arch/alpha/kernel/pci_iommu.c‎

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ static int pci_dac_dma_supported(struct pci_dev *dev, u64 mask)
249249
ok = 0;
250250

251251
/* If both conditions above are met, we are fine. */
252-
DBGA("pci_dac_dma_supported %s from %pf\n",
252+
DBGA("pci_dac_dma_supported %s from %ps\n",
253253
ok ? "yes" : "no", __builtin_return_address(0));
254254

255255
return ok;
@@ -281,7 +281,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
281281
&& paddr + size <= __direct_map_size) {
282282
ret = paddr + __direct_map_base;
283283

284-
DBGA2("pci_map_single: [%p,%zx] -> direct %llx from %pf\n",
284+
DBGA2("pci_map_single: [%p,%zx] -> direct %llx from %ps\n",
285285
cpu_addr, size, ret, __builtin_return_address(0));
286286

287287
return ret;
@@ -292,7 +292,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
292292
if (dac_allowed) {
293293
ret = paddr + alpha_mv.pci_dac_offset;
294294

295-
DBGA2("pci_map_single: [%p,%zx] -> DAC %llx from %pf\n",
295+
DBGA2("pci_map_single: [%p,%zx] -> DAC %llx from %ps\n",
296296
cpu_addr, size, ret, __builtin_return_address(0));
297297

298298
return ret;
@@ -329,7 +329,7 @@ pci_map_single_1(struct pci_dev *pdev, void *cpu_addr, size_t size,
329329
ret = arena->dma_base + dma_ofs * PAGE_SIZE;
330330
ret += (unsigned long)cpu_addr & ~PAGE_MASK;
331331

332-
DBGA2("pci_map_single: [%p,%zx] np %ld -> sg %llx from %pf\n",
332+
DBGA2("pci_map_single: [%p,%zx] np %ld -> sg %llx from %ps\n",
333333
cpu_addr, size, npages, ret, __builtin_return_address(0));
334334

335335
return ret;
@@ -396,14 +396,14 @@ static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr,
396396
&& dma_addr < __direct_map_base + __direct_map_size) {
397397
/* Nothing to do. */
398398

399-
DBGA2("pci_unmap_single: direct [%llx,%zx] from %pf\n",
399+
DBGA2("pci_unmap_single: direct [%llx,%zx] from %ps\n",
400400
dma_addr, size, __builtin_return_address(0));
401401

402402
return;
403403
}
404404

405405
if (dma_addr > 0xffffffff) {
406-
DBGA2("pci64_unmap_single: DAC [%llx,%zx] from %pf\n",
406+
DBGA2("pci64_unmap_single: DAC [%llx,%zx] from %ps\n",
407407
dma_addr, size, __builtin_return_address(0));
408408
return;
409409
}
@@ -435,7 +435,7 @@ static void alpha_pci_unmap_page(struct device *dev, dma_addr_t dma_addr,
435435

436436
spin_unlock_irqrestore(&arena->lock, flags);
437437

438-
DBGA2("pci_unmap_single: sg [%llx,%zx] np %ld from %pf\n",
438+
DBGA2("pci_unmap_single: sg [%llx,%zx] np %ld from %ps\n",
439439
dma_addr, size, npages, __builtin_return_address(0));
440440
}
441441

@@ -458,7 +458,7 @@ static void *alpha_pci_alloc_coherent(struct device *dev, size_t size,
458458
cpu_addr = (void *)__get_free_pages(gfp | __GFP_ZERO, order);
459459
if (! cpu_addr) {
460460
printk(KERN_INFO "pci_alloc_consistent: "
461-
"get_free_pages failed from %pf\n",
461+
"get_free_pages failed from %ps\n",
462462
__builtin_return_address(0));
463463
/* ??? Really atomic allocation? Otherwise we could play
464464
with vmalloc and sg if we can't find contiguous memory. */
@@ -477,7 +477,7 @@ static void *alpha_pci_alloc_coherent(struct device *dev, size_t size,
477477
goto try_again;
478478
}
479479

480-
DBGA2("pci_alloc_consistent: %zx -> [%p,%llx] from %pf\n",
480+
DBGA2("pci_alloc_consistent: %zx -> [%p,%llx] from %ps\n",
481481
size, cpu_addr, *dma_addrp, __builtin_return_address(0));
482482

483483
return cpu_addr;
@@ -497,7 +497,7 @@ static void alpha_pci_free_coherent(struct device *dev, size_t size,
497497
pci_unmap_single(pdev, dma_addr, size, PCI_DMA_BIDIRECTIONAL);
498498
free_pages((unsigned long)cpu_addr, get_order(size));
499499

500-
DBGA2("pci_free_consistent: [%llx,%zx] from %pf\n",
500+
DBGA2("pci_free_consistent: [%llx,%zx] from %ps\n",
501501
dma_addr, size, __builtin_return_address(0));
502502
}
503503

‎arch/arm/mach-imx/pm-imx6.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -631,7 +631,7 @@ static void imx6_pm_stby_poweroff(void)
631631
static int imx6_pm_stby_poweroff_probe(void)
632632
{
633633
if (pm_power_off) {
634-
pr_warn("%s: pm_power_off already claimed %p %pf!\n",
634+
pr_warn("%s: pm_power_off already claimed %p %ps!\n",
635635
__func__, pm_power_off, pm_power_off);
636636
return -EBUSY;
637637
}

‎arch/arm/mm/alignment.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ static const char *usermode_action[] = {
133133
static int alignment_proc_show(struct seq_file *m, void *v)
134134
{
135135
seq_printf(m, "User:\t\t%lu\n", ai_user);
136-
seq_printf(m, "System:\t\t%lu (%pF)\n", ai_sys, ai_sys_last_pc);
136+
seq_printf(m, "System:\t\t%lu (%pS)\n", ai_sys, ai_sys_last_pc);
137137
seq_printf(m, "Skipped:\t%lu\n", ai_skipped);
138138
seq_printf(m, "Half:\t\t%lu\n", ai_half);
139139
seq_printf(m, "Word:\t\t%lu\n", ai_word);

‎arch/arm/nwfpe/fpmodule.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void float_raise(signed char flags)
147147
#ifdef CONFIG_DEBUG_USER
148148
if (flags & debug)
149149
printk(KERN_DEBUG
150-
"NWFPE: %s[%d] takes exception %08x at %pf from %08lx\n",
150+
"NWFPE: %s[%d] takes exception %08x at %ps from %08lx\n",
151151
current->comm, current->pid, flags,
152152
__builtin_return_address(0), GET_USERREG()->ARM_pc);
153153
#endif

‎arch/microblaze/mm/pgtable.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ static void __iomem *__ioremap(phys_addr_t addr, unsigned long size,
7575
p >= memory_start && p < virt_to_phys(high_memory) &&
7676
!(p >= __virt_to_phys((phys_addr_t)__bss_stop) &&
7777
p < __virt_to_phys((phys_addr_t)__bss_stop))) {
78-
pr_warn("__ioremap(): phys addr "PTE_FMT" is RAM lr %pf\n",
78+
pr_warn("__ioremap(): phys addr "PTE_FMT" is RAM lr %ps\n",
7979
(unsigned long)p, __builtin_return_address(0));
8080
return NULL;
8181
}

‎arch/sparc/kernel/ds.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ void ldom_power_off(void)
876876

877877
static void ds_conn_reset(struct ds_info *dp)
878878
{
879-
printk(KERN_ERR "ds-%llu: ds_conn_reset() from %pf\n",
879+
printk(KERN_ERR "ds-%llu: ds_conn_reset() from %ps\n",
880880
dp->id, __builtin_return_address(0));
881881
}
882882

‎arch/um/kernel/sysrq.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
static void _print_addr(void *data, unsigned long address, int reliable)
2222
{
23-
pr_info(" [<%08lx>] %s%pF\n", address, reliable ? "" : "? ",
23+
pr_info(" [<%08lx>] %s%pS\n", address, reliable ? "" : "? ",
2424
(void *)address);
2525
}
2626

‎arch/x86/include/asm/trace/exceptions.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ DECLARE_EVENT_CLASS(x86_exceptions,
3030
__entry->error_code = error_code;
3131
),
3232

33-
TP_printk("address=%pf ip=%pf error_code=0x%lx",
33+
TP_printk("address=%ps ip=%ps error_code=0x%lx",
3434
(void *)__entry->address, (void *)__entry->ip,
3535
__entry->error_code) );
3636

0 commit comments

Comments
 (0)