Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1732086 > unrolled thread
| Started by | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| First post | 2017-09-14 09:50 +0200 |
| Last post | 2017-09-18 09:10 +0200 |
| Articles | 7 — 3 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-14 09:50 +0200
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-14 10:10 +0200
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Helge Deller <deller@gmx.de> - 2017-09-14 10:40 +0200
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-14 11:30 +0200
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Helge Deller <deller@gmx.de> - 2017-09-14 11:50 +0200
RE: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages "Luck, Tony" <tony.luck@intel.com> - 2017-09-14 18:10 +0200
Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> - 2017-09-18 09:10 +0200
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-09-14 09:50 +0200 |
| Subject | Re: [PATCH 00/14] Fix wrong %pF and %pS printk format specifier usages |
| Message-ID | <upx4n-293-13@gated-at.bofh.it> |
On (09/08/17 20:28), Helge Deller wrote:
[..]
> I don't like this kind of trying to figure out at runtime at all.
> It's too much guessing in here IMHO.
well, may be we can avoid any guessing by checking that the
pointer belongs to .opd section.
for kernel we can add 2 new unsigned longs - __opd_start __opd_end -- and
tweak the corresponding arch/${FOO}/kernel/vmlinux.lds.S file to set those
two, the same way text, unwinding, etc. are set.
.... wait a second.
arch/ia64/kernel/vmlinux.lds.S already handles .opd section
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
*(.opd)
}
it just doesn't save start/end addresses. so all we need to to
is
.opd : AT(ADDR(.opd) - LOAD_OFFSET) {
+ __opd_start = .;
*(.opd)
+ __opd_end = .;
}
and tweak symbol dereference
static inline void *dereference_function_descriptor(void *ptr)
{
struct fdesc *desc = ptr;
void *p;
+ if (prt < (void *)__start_opd || (void *)__end_opd < ptr)
+ return ptr;
+
if (!probe_kernel_address(&desc->ip, p))
ptr = p;
return ptr;
now, the modules.
module_frob_arch_sections() has the following lines
else if (strcmp(".opd", secstrings + s->sh_name) == 0)
mod->arch.opd = s;
so, once, again, we keep the .opd section info in memory. and we
also have the size of that section
mod->arch.opd->sh_size = fdescs * sizeof(struct fdesc);
so it seems that we've got what we need. need to provide arch callback
(same way as we do with dereference_function_descriptor() to properly
dereference modules' symbols).
so I think we almost have what we need to make ps/pS smart enough
on ppc64/ia64/parisc.
powerpc and parisc handle kernel .opd section as well:
arch/powerpc/kernel/vmlinux.lds.S: .opd
arch/parisc/kernel/vmlinux.lds.S: .opd
need to check more.
> What about this idea:
> For %pF we always have pointers to functions, e.g.:
> printk("Going to call: %pF\n", gettimeofday);
> printk("Going to call: %pF\n", p->func);
>
> and for %pS most (if not all) usages use some kind of casting
> from "unsigned long" to "void *", e.g.:
> printk("%s: called from %pS\n", __func__, (void *)_RET_IP_);
> printk("%s: called from %pS\n", __func__, (void *)__builtin_return_address(0));
> printk("Faulted at %pS\n", (void *)regs->ip);
>
> So, what if we for the %pS case simply take the type as it is
> (unsigned long) and introduce a new printk-format, e.g. "%luS" ?
> The %pS examples above then become:
> printk("%s: called from %luS\n", __func__, _RET_IP_);
> printk("%s: called from %luS\n", __func__, __builtin_return_address(0));
> printk("Faulted at %luS\n", regs->ip);
>
> That way we don't need type-casting, gain compile-time type
> checks from the compiler, and we could add a checkpatch (or occinelle)
> check which checks for the combination of %pF/%pS and "void*" keyword
> and suggest to use %luS.
>
> Opinions?
hm. sounds interesting. but I'm afraid people won't be so happy
to learn a new printk format specifier.
-ss
[toc] | [next] | [standalone]
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-09-14 10:10 +0200 |
| Message-ID | <upxnI-2uK-21@gated-at.bofh.it> |
| In reply to | #1732086 |
On (09/14/17 16:40), Sergey Senozhatsky wrote:
[..]
> powerpc and parisc handle kernel .opd section as well:
>
> arch/powerpc/kernel/vmlinux.lds.S: .opd
> arch/parisc/kernel/vmlinux.lds.S: .opd
for modules, arch-s define mod_arch_specific struct.
parisc has .opd
(fdesc offset should be the start of .opd,
fdesc_offset + sizeof(fdesc) * fdesc_count should be the .opd address range)
struct mod_arch_specific
{
unsigned long got_offset, got_count, got_max;
unsigned long fdesc_offset, fdesc_count, fdesc_max;
struct {
unsigned long stub_offset;
unsigned int stub_entries;
} *section;
int unwind_section;
struct unwind_table *unwind;
};
ia64 has .opd
struct mod_arch_specific {
struct elf64_shdr *core_plt; /* core PLT section */
struct elf64_shdr *init_plt; /* init PLT section */
struct elf64_shdr *got; /* global offset table */
struct elf64_shdr *opd; /* official procedure descriptors */
struct elf64_shdr *unwind; /* unwind-table section */
unsigned long gp; /* global-pointer for module */
void *core_unw_table; /* core unwind-table cookie returned by unwinder */
void *init_unw_table; /* init unwind-table cookie returned by unwinder */
unsigned int next_got_entry; /* index of next available got entry */
};
powerpc does not keep track of .opd, need to add
struct mod_arch_specific {
#ifdef __powerpc64__
unsigned int stubs_section; /* Index of stubs section in module */
unsigned int toc_section; /* What section is the TOC? */
bool toc_fixed; /* Have we fixed up .TOC.? */
#ifdef CONFIG_DYNAMIC_FTRACE
unsigned long toc;
unsigned long tramp;
#endif
#else /* powerpc64 */
/* Indices of PLT sections within module. */
unsigned int core_plt_section;
unsigned int init_plt_section;
#ifdef CONFIG_DYNAMIC_FTRACE
unsigned long tramp;
#endif
#endif /* powerpc64 */
/* List of BUG addresses, source line numbers and filenames */
struct list_head bug_list;
struct bug_entry *bug_table;
unsigned int num_bugs;
};
seems like we are looking at a solution here.
thoughts?
-ss
[toc] | [prev] | [next] | [standalone]
| From | Helge Deller <deller@gmx.de> |
|---|---|
| Date | 2017-09-14 10:40 +0200 |
| Message-ID | <upxQJ-2Ek-3@gated-at.bofh.it> |
| In reply to | #1732102 |
On 14.09.2017 10:03, Sergey Senozhatsky wrote:
> On (09/14/17 16:40), Sergey Senozhatsky wrote:
> [..]
>> powerpc and parisc handle kernel .opd section as well:
>>
>> arch/powerpc/kernel/vmlinux.lds.S: .opd
>> arch/parisc/kernel/vmlinux.lds.S: .opd
>
> for modules, arch-s define mod_arch_specific struct.
>
> parisc has .opd
>
> (fdesc offset should be the start of .opd,
> fdesc_offset + sizeof(fdesc) * fdesc_count should be the .opd address range)
>
> struct mod_arch_specific
> {
> unsigned long got_offset, got_count, got_max;
> unsigned long fdesc_offset, fdesc_count, fdesc_max;
> struct {
> unsigned long stub_offset;
> unsigned int stub_entries;
> } *section;
> int unwind_section;
> struct unwind_table *unwind;
> };
>
>
> ia64 has .opd
>
> struct mod_arch_specific {
> struct elf64_shdr *core_plt; /* core PLT section */
> struct elf64_shdr *init_plt; /* init PLT section */
> struct elf64_shdr *got; /* global offset table */
> struct elf64_shdr *opd; /* official procedure descriptors */
> struct elf64_shdr *unwind; /* unwind-table section */
> unsigned long gp; /* global-pointer for module */
>
> void *core_unw_table; /* core unwind-table cookie returned by unwinder */
> void *init_unw_table; /* init unwind-table cookie returned by unwinder */
> unsigned int next_got_entry; /* index of next available got entry */
> };
>
>
> powerpc does not keep track of .opd, need to add
>
> struct mod_arch_specific {
> #ifdef __powerpc64__
> unsigned int stubs_section; /* Index of stubs section in module */
> unsigned int toc_section; /* What section is the TOC? */
> bool toc_fixed; /* Have we fixed up .TOC.? */
> #ifdef CONFIG_DYNAMIC_FTRACE
> unsigned long toc;
> unsigned long tramp;
> #endif
>
> #else /* powerpc64 */
> /* Indices of PLT sections within module. */
> unsigned int core_plt_section;
> unsigned int init_plt_section;
> #ifdef CONFIG_DYNAMIC_FTRACE
> unsigned long tramp;
> #endif
> #endif /* powerpc64 */
>
> /* List of BUG addresses, source line numbers and filenames */
> struct list_head bug_list;
> struct bug_entry *bug_table;
> unsigned int num_bugs;
> };
>
>
> seems like we are looking at a solution here.
>
> thoughts?
The basic concept of your proposal may work, and since it will avoid such
coding issues in the future I think it's probably the best solution.
Will you come up with a patch ? (I won't have time the next few days).
If yes,I'd be happy to test it on parisc.
Helge
[toc] | [prev] | [next] | [standalone]
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-09-14 11:30 +0200 |
| Message-ID | <upyD8-3bN-21@gated-at.bofh.it> |
| In reply to | #1732113 |
On (09/14/17 10:39), Helge Deller wrote: [..] > The basic concept of your proposal may work, and since it will avoid such > coding issues in the future I think it's probably the best solution. > > Will you come up with a patch ? (I won't have time the next few days). > If yes,I'd be happy to test it on parisc. cool. I think I can try to come up with something. I don't have any access to affected H/W, so if I won't be able to bring up qemu images I'll be happy to just hand it over to platform maintainers: arch-s like parisc64 are way to exotic ;) my aim is a removal of %pf/%pF here. let's hear from ia64 and ppc64 guys. -ss
[toc] | [prev] | [next] | [standalone]
| From | Helge Deller <deller@gmx.de> |
|---|---|
| Date | 2017-09-14 11:50 +0200 |
| Message-ID | <upyWt-3iw-7@gated-at.bofh.it> |
| In reply to | #1732139 |
On 14.09.2017 11:27, Sergey Senozhatsky wrote: > On (09/14/17 10:39), Helge Deller wrote: > [..] >> The basic concept of your proposal may work, and since it will avoid such >> coding issues in the future I think it's probably the best solution. >> >> Will you come up with a patch ? (I won't have time the next few days). >> If yes,I'd be happy to test it on parisc. > > cool. > > I think I can try to come up with something. I don't have any access > to affected H/W, so if I won't be able to bring up qemu images There is no qemu for parisc yet, but cross-compiling the kernel on Fedora or Debian from x86_64 is easy and ready-to-go. Otherwise it's not a problem, I can try in a few days. > I'll be happy to just hand it over to platform maintainers: arch-s like > parisc64 are way to exotic ;) my aim is a removal of %pf/%pF here. > > let's hear from ia64 and ppc64 guys. Ok too. Helge
[toc] | [prev] | [next] | [standalone]
| From | "Luck, Tony" <tony.luck@intel.com> |
|---|---|
| Date | 2017-09-14 18:10 +0200 |
| Message-ID | <upESe-7ea-27@gated-at.bofh.it> |
| In reply to | #1732145 |
> let's hear from ia64 and ppc64 guys. If you write a patch, I can try it on some ia64 h/w. Please include some test cases (perhaps as a second patch that adds a few good/bad %pF and %pS to some code (both in base kernel, and in a module). -Tony
[toc] | [prev] | [next] | [standalone]
| From | Sergey Senozhatsky <sergey.senozhatsky.work@gmail.com> |
|---|---|
| Date | 2017-09-18 09:10 +0200 |
| Message-ID | <uqYlP-2Ut-3@gated-at.bofh.it> |
| In reply to | #1732408 |
On (09/14/17 16:01), Luck, Tony wrote:
>
> > let's hear from ia64 and ppc64 guys.
>
> If you write a patch, I can try it on some ia64 h/w.
>
> Please include some test cases (perhaps as a second patch that adds a few good/bad %pF and %pS
> to some code (both in base kernel, and in a module).
Hello,
I sent out an RFC patch set.
would the following test case work for you?
kernel)
echo 1 > /proc/sys/vm/drop_caches
module)
modprobe zram
echo 100M > /sys/block/zram0/disksize
---
drivers/block/zram/zram_drv.c | 15 +++++++++++++++
fs/drop_caches.c | 11 +++++++++++
2 files changed, 26 insertions(+)
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c
index 2981c27d3aae..ac92aaeaced0 100644
--- a/drivers/block/zram/zram_drv.c
+++ b/drivers/block/zram/zram_drv.c
@@ -1508,6 +1508,12 @@ static int zram_add(void)
struct request_queue *queue;
int ret, device_id;
+ printk("printk#13 %pF\n", (void *)_RET_IP_);
+ printk("printk#14 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#15 %pF\n", __builtin_return_address(0));
+ printk("printk#16 %pS\n", __builtin_return_address(0));
+
zram = kzalloc(sizeof(struct zram), GFP_KERNEL);
if (!zram)
return -ENOMEM;
@@ -1730,6 +1736,15 @@ static int __init zram_init(void)
{
int ret;
+ printk("printk#7 %pF\n", zram_init);
+ printk("printk#8 %pS\n", zram_init);
+
+ printk("printk#9 %pF\n", (void *)_RET_IP_);
+ printk("printk#10 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#11 %pF\n", __builtin_return_address(0));
+ printk("printk#12 %pS\n", __builtin_return_address(0));
+
ret = cpuhp_setup_state_multi(CPUHP_ZCOMP_PREPARE, "block/zram:prepare",
zcomp_cpu_up_prepare, zcomp_cpu_dead);
if (ret < 0)
diff --git a/fs/drop_caches.c b/fs/drop_caches.c
index d72d52b90433..3db4adcac78d 100644
--- a/fs/drop_caches.c
+++ b/fs/drop_caches.c
@@ -39,11 +39,22 @@ static void drop_pagecache_sb(struct super_block *sb, void *unused)
iput(toput_inode);
}
+#include <linux/sched.h>
+
int drop_caches_sysctl_handler(struct ctl_table *table, int write,
void __user *buffer, size_t *length, loff_t *ppos)
{
int ret;
+ printk("printk#1 %pF\n", schedule_timeout);
+ printk("printk#2 %pS\n", schedule_timeout);
+
+ printk("printk#3 %pF\n", (void *)_RET_IP_);
+ printk("printk#4 %pS\n", (void *)_RET_IP_);
+
+ printk("printk#5 %pF\n", __builtin_return_address(0));
+ printk("printk#6 %pS\n", __builtin_return_address(0));
+
ret = proc_dointvec_minmax(table, write, buffer, length, ppos);
if (ret)
return ret;
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web