Messages in this thread | | | Date | Thu, 23 Apr 2020 23:12:01 -0500 | From | Josh Poimboeuf <> | Subject | Re: [PATCH v2 6/9] s390/module: Use s390_kernel_write() for late relocations |
| |
On Thu, Apr 23, 2020 at 10:35:21PM -0400, Joe Lawrence wrote: > > diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c > > index 2798329ebb74..fe446f42818f 100644 > > --- a/arch/s390/kernel/module.c > > +++ b/arch/s390/kernel/module.c > > @@ -297,7 +297,7 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab, > > > > gotent = me->core_layout.base + me->arch.got_offset + > > info->got_offset; > > - *gotent = val; > > + write(gotent, &val, sizeof(*gotent)); > > info->got_initialized = 1; > > } > > val = info->got_offset + rela->r_addend; > > @@ -330,25 +330,29 @@ static int apply_rela(Elf_Rela *rela, Elf_Addr base, Elf_Sym *symtab, > > case R_390_PLTOFF32: /* 32 bit offset from GOT to PLT. */ > > case R_390_PLTOFF64: /* 16 bit offset from GOT to PLT. */ > > if (info->plt_initialized == 0) { > > - unsigned int *ip; > > + unsigned int *ip, insn[5]; > > + > > ip = me->core_layout.base + me->arch.plt_offset + > > info->plt_offset; > > Would it be too paranoid to declare: > > const unsigned int *ip = me->core_layout.base + > me->arch.plt_offset + > info->plt_offset; > > That would trip an assignment to read-only error if someone were tempted > to write directly through the pointer in the future. Ditto for Elf_Addr > *gotent pointer in the R_390_GOTPLTENT case.
The only problem is then the write() triggers a warning because then we *are* trying to write through the pointer :-)
arch/s390/kernel/module.c:300:10: warning: passing argument 1 of ‘write’ discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] 300 | write(gotent, &val, sizeof(*gotent));
-- Josh
| |