lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20200424041201.ekbx6wvl3dn45zfl@treble>
Date:   Thu, 23 Apr 2020 23:12:01 -0500
From:   Josh Poimboeuf <jpoimboe@...hat.com>
To:     Joe Lawrence <joe.lawrence@...hat.com>
Cc:     Miroslav Benes <mbenes@...e.cz>,
        Gerald Schaefer <gerald.schaefer@...ibm.com>,
        live-patching@...r.kernel.org, linux-kernel@...r.kernel.org,
        Peter Zijlstra <peterz@...radead.org>,
        Jessica Yu <jeyu@...nel.org>, linux-s390@...r.kernel.org,
        heiko.carstens@...ibm.com, Vasily Gorbik <gor@...ux.ibm.com>
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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ