From sacadmin Mon Mar  5 16:24:02 2007
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l260O2HE022899
	for <psarc@sac.sfbay.sun.com>; Mon, 5 Mar 2007 16:24:02 -0800 (PST)
Received: from brmea-mail-4.sun.com (brmea-mail-4.Sun.COM [192.18.98.36])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l260O2sj018659
	for <psarc@sac.sfbay.sun.com>; Mon, 5 Mar 2007 16:24:02 -0800 (PST)
Received: from fe-amer-04.sun.com ([192.18.108.178])
	by brmea-mail-4.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l260O2Zx029553
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 00:24:02 GMT
Received: from conversion-daemon.mail-amer.sun.com by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 id <0JEG00A01GQ6G800@mail-amer.sun.com>
 (original mail from Ali.Bahrami@Sun.COM) for psarc@sac.sfbay.sun.com; Mon,
 05 Mar 2007 17:24:02 -0700 (MST)
Received: from [172.20.25.67] by mail-amer.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 with ESMTPSA id <0JEG00KCZH42SDY2@mail-amer.sun.com> for
 psarc@sac.sfbay.sun.com; Mon, 05 Mar 2007 17:24:02 -0700 (MST)
Date: Mon, 05 Mar 2007 17:26:40 -0700
From: Ali Bahrami <Ali.Bahrami@Sun.COM>
Subject: 2007/127 Reserved space for editing ELF dynamic sections
Sender: Ali.Bahrami@Sun.COM
To: psarc@sac.sfbay.sun.com
Message-id: <45ECB540.9000905@Sun.COM>
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
X-Accept-Language: en-us, en
User-Agent: Mozilla Thunderbird 1.0.7 (X11/20050930)
Status: RO
Content-Length: 4871

I am sponsoring the following self approved case for myself.
This case qualifies for Architectural self-review, but I wish
to record the following information. Timeout 3-7-2007.

-----------------------------------------------------------------------

This is a proposal to add a small amount of unused space to the dynamic
string table and dynamic section of Solaris objects. This change
will significantly improve our ability to edit such files in a safe
and backward compatible manner.

This work is for:

     6516118 Reserved space needed in ELF dynamic section and string table

We have long desired a tool that would allow us to modify existing
ELF files in minor ways, such as adding or altering the runpath of
a dynamic object, without the need to rebuild the file. The problem
one encounters in trying to do this is that the various parts of an ELF
file refer to each other by their relative offset from each other, and
once built, the information required to fix up these interrelationships
no longer exists. Therefore, any change that alters the size or relative
spacing between the various parts of an ELF file will break it.

In contrast, edits that preserve the relative positions of items in an
ELF file are possible and can be very useful. For example, to alter
the runpath of a sharable object, one might overwrite the existing
string with a new one. As long as the new string is smaller or
equal in length to the new one, this has an excellent chance of
working. However, there are problems with this approach. There may
be no existing runpath to overwrite. Or, the runpath may exist,
but the compiler and/or linker may have decided to use the same readonly
string to satisfy a different unrelated purpose --- changing it to fix
the runpath may therefore break something else.

Our ability to safely perform such edits can be greatly improved
if the linker provides a small amount of extra unused space when
producing an object:

	- A small amount of unused space at the end of the dynamic
	  string table to provide room to add new strings.

	- A few extra DT_NULL entries at the end of the .dynamic section
	  to allow the addition of a runpath (or other similar items)
	  to a file that does not already have one.

There are limits to how much editing can be supported by a small amount
of spare space. If enough changes are needed, it will always be necessary
to rebuild. However, the 90/10 rule applies in this case --- a very small
amount of extra space will allow us to easily handle the vast majority
of editing requests, runpath modification being far and away the most
common such request.

I plan to make the following changes to the linker:

	- 512 bytes of unused space will be added to the end of
	  the .dynamic string table (.dynstr). This is large enough
	  to handle most cases, and small enough avoid swelling objects
	  unnecessarily.

	- 10 additional DT_NULL entries will be added to the end
	  of the .dynamic section. These extra slots can be used to
	  add dynamic entries that were not in the original ELF file.
	  The runtime linker stops examining the dynamic section when
	  it encounters the first DT_NULL, so the extra entries will
	  not change its behavior. This is true of older versions of
	  the runtime linker as well, so such a file can be safely moved
	  back to older Solaris versions.

	- A new dynamic section element, DT_SUNW_STRPAD will record
	  the amount of available space at the end of the dynamic
	  string table. This serves two purposes: (1) The lack of a
	  DT_SUNW_STRPAD entry indicates that have an old ELF file without
	  any extra space, and (2) As extra space is used by editors,
	  the value of DT_SUNW_STRPAD will be reduced by the editor
	  in order to keep track of the use.
	
	- A new flag for the DT_FLAGS_1 entry of the dynamic section
	  named DF_1_ELFEDIT, to be set by any editor that alters the
	  elf file. The presence of this flag will therefore advise
	  that the file is not in the original state generated by
	  the linker. A developer who is investigating a problem
	  with such a file will have a way to detect that the file
	  has been manually modified, and may be able to avoid
	  unprofitable debugging as a result.

These ELF additions are backward compatible. A file containing them
can be safely moved to an older Solaris system. These features represent
the result of considered discussion with Rod Evans as to the various
approaches we might take to editing ELF files, as well as experimental
experience. This case does not include an ELF editor. However, we
have an ongoing project underway to eventually supply one. The
features described in this case have been successfully used in that
project to edit ELF files.

-----------------------------------------------------------------------

Release Binding:			Patch/Micro
DT_SUNW_STRPAD and DF_1_ELFEDIT		Committed

From sacadmin Tue Mar  6 05:50:52 2007
Received: from sfbaymail1sca.SFBay.Sun.COM (sfbaymail1sca.SFBay.Sun.COM [129.145.154.35])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l26Dopbu015929
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 05:50:52 -0800 (PST)
Received: from gmp-ea-fw-1.sun.com (gmpes-gis-mail-1.UK.Sun.COM [129.156.42.5])
	by sfbaymail1sca.SFBay.Sun.COM (8.13.6+Sun/8.13.6/ENSMAIL,v2.2) with ESMTP id l26DopdC010984
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 05:50:51 -0800 (PST)
Received: from d1-emea-10.sun.com (d1-emea-10.sun.com [192.18.2.120])
	by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l26DojQ6008412
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 13:50:45 GMT
Received: from conversion-daemon.d1-emea-10.sun.com by d1-emea-10.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 id <0JEH00B01IAZFG00@d1-emea-10.sun.com>
 (original mail from Darren.Moffat@Sun.COM) for psarc@sac.sfbay.sun.com; Tue,
 06 Mar 2007 13:50:45 +0000 (GMT)
Received: from [192.168.73.101] (nessieroo.force9.co.uk [81.174.224.49])
 by d1-emea-10.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 with ESMTPSA id <0JEH003W1IGKSG00@d1-emea-10.sun.com> for
 psarc@sac.sfbay.sun.com; Tue, 06 Mar 2007 13:50:45 +0000 (GMT)
Date: Tue, 06 Mar 2007 13:50:44 +0000
From: Darren J Moffat <Darren.Moffat@Sun.COM>
Subject: Re: 2007/127 Reserved space for editing ELF dynamic sections
In-reply-to: <45ECB540.9000905@Sun.COM>
Sender: Darren.Moffat@Sun.COM
To: Ali Bahrami <Ali.Bahrami@Sun.COM>
Cc: psarc@sac.sfbay.sun.com
Message-id: <45ED71B4.9020303@Sun.COM>
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
References: <45ECB540.9000905@Sun.COM>
User-Agent: Thunderbird 1.5.0.8 (X11/20061127)
Status: RO
Content-Length: 354

I assume this case has no impact on elfsign other than if one makes use 
of the infrastructure this case provides the signature would be invalid 
until the binary is resigned.

Please run the STC2 suites/security/ef test suite before integration as 
this will test the elfsign functionality to ensure this case has no 
impact on it.

-- 
Darren J Moffat

From sacadmin Tue Mar  6 07:42:14 2007
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l26FgEVi018970
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 07:42:14 -0800 (PST)
Received: from gmp-ea-fw-1.sun.com (gmpes-gis-mail-2.UK.Sun.COM [129.156.42.6])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l26FgD62009812
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 07:42:13 -0800 (PST)
Received: from d1-emea-09.sun.com ([192.18.2.119])
	by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l26Fg7UG000354
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 15:42:07 GMT
Received: from conversion-daemon.d1-emea-09.sun.com by d1-emea-09.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 id <0JEH00101MYWE200@d1-emea-09.sun.com>
 (original mail from Calum.Mackay@Sun.COM) for psarc@sac.sfbay.sun.com; Tue,
 06 Mar 2007 15:42:07 +0000 (GMT)
Received: from [192.168.254.1] ([62.24.230.83])
 by d1-emea-09.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr  3
 2006)) with ESMTPSA id <0JEH00HFENM517CC@d1-emea-09.sun.com> for
 psarc@sac.sfbay.sun.com; Tue, 06 Mar 2007 15:42:06 +0000 (GMT)
Date: Tue, 06 Mar 2007 15:42:05 +0000
From: Calum Mackay <Calum.Mackay@Sun.COM>
Subject: Re: 2007/127 Reserved space for editing ELF dynamic sections
In-reply-to: <45ECB540.9000905@Sun.COM>
Sender: Calum.Mackay@Sun.COM
To: Ali Bahrami <Ali.Bahrami@Sun.COM>
Cc: psarc@sac.sfbay.sun.com
Message-id: <45ED8BCD.8050702@sun.com>
Organization: Sun Microsystems
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
References: <45ECB540.9000905@Sun.COM>
User-Agent: Thunderbird 3.0a1 (X11/20070303)
Status: RO
Content-Length: 754

hi Ali,

> In contrast, edits that preserve the relative positions of items in an
> ELF file are possible and can be very useful. For example, to alter
> the runpath of a sharable object, one might overwrite the existing
> string with a new one. As long as the new string is smaller or
> equal in length to the new one, this has an excellent chance of
> working. However, there are problems with this approach. There may
> be no existing runpath to overwrite. Or, the runpath may exist,
> but the compiler and/or linker may have decided to use the same readonly
> string to satisfy a different unrelated purpose --- changing it to fix
> the runpath may therefore break something else.

How would this new scheme affect that latter issue?

cheers,
calum.

From sacadmin Tue Mar  6 07:51:57 2007
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l26FpvKi019049
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 07:51:57 -0800 (PST)
Received: from brmea-mail-1.sun.com (brmea-mail-1.Sun.COM [192.18.98.31])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l26FpvLI014035
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 07:51:57 -0800 (PST)
Received: from relay43i.sun.com ([192.5.209.74])
	by brmea-mail-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l26FmqXD004183
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 15:51:56 GMT
Received: from mms48es.sun.com ([160.41.221.231] [160.41.221.231]) by relay43i.sun.com with ESMTP; Tue, 6 Mar 2007 15:51:56 Z
Received: from relay41i.sun.com ([192.5.209.70] [192.5.209.70]) by mms48es.sun.com with ESMTP; Tue, 6 Mar 2007 15:51:56 Z
Received: from emvision.com ([199.45.162.234] [199.45.162.234]) by relay4i.sun.com with ESMTP; Tue, 6 Mar 2007 15:51:55 Z
Received: from [198.182.198.2] (pod.emvision.com [198.182.198.2])
	by emvision.com (8.13.6/8.13.6) with ESMTP id l26FpmvY009779;
	Tue, 6 Mar 2007 08:51:48 -0700 (MST)
Message-Id: <45ED8E29.7090906@Sun.COM>
Date: Tue, 06 Mar 2007 08:52:09 -0700
From: Ali Bahrami <Ali.Bahrami@sun.com>
User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221)
MIME-Version: 1.0
To: Darren J Moffat <Darren.Moffat@sun.com>
CC: psarc@sac.sfbay.sun.com
Subject: Re: 2007/127 Reserved space for editing ELF dynamic sections
References: <45ECB540.9000905@Sun.COM> <45ED71B4.9020303@Sun.COM>
In-Reply-To: <45ED71B4.9020303@Sun.COM>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (emvision.com [198.182.198.5]); Tue, 06 Mar 2007 08:51:49 -0700 (MST)
Status: RO
Content-Length: 610

Darren J Moffat wrote:
> I assume this case has no impact on elfsign other than if one makes use 
> of the infrastructure this case provides the signature would be invalid 
> until the binary is resigned.
> 
> Please run the STC2 suites/security/ef test suite before integration as 
> this will test the elfsign functionality to ensure this case has no 
> impact on it.
> 


You are correct about elfsign. This extra space is part of the
standard sections, and a change to them would invalidate the
signature, which could then be resigned if appropriate.

I will be sure to run STC2 before integration.

- Ali

From sacadmin Tue Mar  6 08:06:46 2007
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l26G6kj8020054
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 08:06:46 -0800 (PST)
Received: from sca-ea-mail-3.sun.com (sca-ea-mail-3.Sun.COM [192.18.43.21])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l26G6jwJ021387
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 08:06:45 -0800 (PST)
Received: from relay2.sun.com (relay2.sun.com [150.143.103.24] (may be forged))
	by sca-ea-mail-3.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l26FkkiU014743
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 16:06:45 GMT
Received: from mms02es.sun.com ([150.143.104.34] [150.143.104.34]) by relay2.sun.com with ESMTP; Tue, 6 Mar 2007 16:06:17 Z
Received: from relay3.sun.com (relay3.sun.com [150.143.103.54]) by mms02es.sun.com with ESMTP id BT-MMP-2704654; Tue, 6 Mar 2007 16:06:17 Z
Received: from emvision.com ([199.45.162.234] [199.45.162.234]) by relay3.sun.com with ESMTP; Tue, 6 Mar 2007 16:06:16 Z
Received: from [198.182.198.2] (pod.emvision.com [198.182.198.2])
	by emvision.com (8.13.6/8.13.6) with ESMTP id l26G6DUO009855;
	Tue, 6 Mar 2007 09:06:13 -0700 (MST)
Message-Id: <45ED9189.8080003@Sun.COM>
Date: Tue, 06 Mar 2007 09:06:33 -0700
From: Ali Bahrami <Ali.Bahrami@Sun.com>
User-Agent: Thunderbird 1.5.0.10 (Macintosh/20070221)
MIME-Version: 1.0
To: Calum Mackay <Calum.Mackay@Sun.com>
CC: psarc@sac.sfbay.sun.com
Subject: Re: 2007/127 Reserved space for editing ELF dynamic sections
References: <45ECB540.9000905@Sun.COM> <45ED8BCD.8050702@sun.com>
In-Reply-To: <45ED8BCD.8050702@sun.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.0.2 (emvision.com [198.182.198.5]); Tue, 06 Mar 2007 09:06:15 -0700 (MST)
Status: RO
Content-Length: 1440

Calum Mackay wrote:
> hi Ali,
> 
>> In contrast, edits that preserve the relative positions of items in an
>> ELF file are possible and can be very useful. For example, to alter
>> the runpath of a sharable object, one might overwrite the existing
>> string with a new one. As long as the new string is smaller or
>> equal in length to the new one, this has an excellent chance of
>> working. However, there are problems with this approach. There may
>> be no existing runpath to overwrite. Or, the runpath may exist,
>> but the compiler and/or linker may have decided to use the same readonly
>> string to satisfy a different unrelated purpose --- changing it to fix
>> the runpath may therefore break something else.
> 
> How would this new scheme affect that latter issue?
> 
> cheers,
> calum.


The new scheme allows you to introduce a new string into the string table.
Since it is new, you know by definition that there are no pre-existing uses
of it within the ELF file. You then modify the item you wish to change
(for instance, the runpath entry in the dynamic section) to reference it.

This is safe, because the original string is left where it lies, and is
unchanged. Any other reference to it will be OK. It does not break the
ELF file, because the relative positions of existing things stay the
same. This is because the extra space was built into the ELF file when
it was generated, rather than being bolted on later.

- Ali

From sacadmin Tue Mar  6 09:20:19 2007
Received: from sfbaymail2sca.sfbay.sun.com (sfbaymail2sca.SFBay.Sun.COM [129.145.155.42])
	by sac.sfbay.sun.com (8.13.6+Sun/8.13.6) with ESMTP id l26HKJA5022312
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 09:20:19 -0800 (PST)
Received: from gmp-ea-fw-1.sun.com (gmpes-gis-mail-1.UK.Sun.COM [129.156.42.5])
	by sfbaymail2sca.sfbay.sun.com (8.13.6+Sun/8.12.10/ENSMAIL,v2.2) with ESMTP id l26HKIj8000152
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 09:20:18 -0800 (PST)
Received: from d1-emea-10.sun.com (d1-emea-10.sun.com [192.18.2.120])
	by gmp-ea-fw-1.sun.com (8.13.6+Sun/8.12.9) with ESMTP id l26HKC1B013493
	for <psarc@sac.sfbay.sun.com>; Tue, 6 Mar 2007 17:20:12 GMT
Received: from conversion-daemon.d1-emea-10.sun.com by d1-emea-10.sun.com
 (Sun Java System Messaging Server 6.2-6.01 (built Apr  3 2006))
 id <0JEH00401S4HVU00@d1-emea-10.sun.com>
 (original mail from Calum.Mackay@Sun.COM) for psarc@sac.sfbay.sun.com; Tue,
 06 Mar 2007 17:20:12 +0000 (GMT)
Received: from [192.168.254.1] ([62.24.230.83])
 by d1-emea-10.sun.com (Sun Java System Messaging Server 6.2-6.01 (built Apr  3
 2006)) with ESMTPSA id <0JEH00292S5M5RWJ@d1-emea-10.sun.com> for
 psarc@sac.sfbay.sun.com; Tue, 06 Mar 2007 17:20:12 +0000 (GMT)
Date: Tue, 06 Mar 2007 17:20:09 +0000
From: Calum Mackay <Calum.Mackay@Sun.COM>
Subject: Re: 2007/127 Reserved space for editing ELF dynamic sections
In-reply-to: <45ED9189.8080003@Sun.COM>
Sender: Calum.Mackay@Sun.COM
To: Ali Bahrami <Ali.Bahrami@Sun.COM>
Cc: psarc@sac.sfbay.sun.com
Message-id: <45EDA2C9.1090001@sun.com>
Organization: Sun Microsystems
MIME-version: 1.0
Content-type: text/plain; format=flowed; charset=ISO-8859-1
Content-transfer-encoding: 7BIT
References: <45ECB540.9000905@Sun.COM> <45ED8BCD.8050702@sun.com>
 <45ED9189.8080003@Sun.COM>
User-Agent: Thunderbird 3.0a1 (X11/20070303)
Status: RO
Content-Length: 365

Ali Bahrami wrote:
> The new scheme allows you to introduce a new string into the string table.
> Since it is new, you know by definition that there are no pre-existing uses
> of it within the ELF file. You then modify the item you wish to change
> (for instance, the runpath entry in the dynamic section) to reference it.

Understood, thanks much Ali.

cheers,
c.

