Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1642640 > unrolled thread

Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy

Started byTony Lindgren <tony@atomide.com>
First post2017-05-16 18:10 +0200
Last post2017-05-17 16:30 +0200
Articles 5 — 4 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.


Contents

  Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy Tony Lindgren <tony@atomide.com> - 2017-05-16 18:10 +0200
    Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy Greg Kroah-Hartman <gregkh@linuxfoundation.org> - 2017-05-17 11:20 +0200
      Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy Russell King - ARM Linux <linux@armlinux.org.uk> - 2017-05-17 13:50 +0200
        Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy Tony Lindgren <tony@atomide.com> - 2017-05-17 15:50 +0200
          Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy Dave Gerlach <d-gerlach@ti.com> - 2017-05-17 16:30 +0200

#1642640 — Re: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy

FromTony Lindgren <tony@atomide.com>
Date2017-05-16 18:10 +0200
SubjectRe: [PATCH v2] misc: sram-exec: Use aligned fncpy instead of memcpy
Message-ID<tHNcR-7My-13@gated-at.bofh.it>
* Russell King - ARM Linux <linux@armlinux.org.uk> [170503 11:58]:
> On Mon, Apr 10, 2017 at 09:52:47AM -0500, Dave Gerlach wrote:
> > Currently the sram-exec functionality, which allows allocation of
> > executable memory and provides an API to move code to it, is only
> > selected in configs for the ARM architecture. Based on commit
> > 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for
> > function body copying") simply copying a C function pointer address
> > using memcpy without consideration of alignment and Thumb is unsafe on
> > ARM platforms.
> > 
> > The aforementioned patch introduces the fncpy macro which is a safe way
> > to copy executable code on ARM platforms, so let's make use of that here
> > rather than the unsafe plain memcpy that was previously used by
> > sram_exec_copy. Now sram_exec_copy will move the code to "dst" and
> > return an address that is guaranteed to be safely callable.
> > 
> > In the future, architectures hoping to make use of the sram-exec
> > functionality must define an fncpy macro just as ARM has done to
> > guarantee or check for safe copying to executable memory before allowing
> > the arch to select CONFIG_SRAM_EXEC.
> > 
> > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> 
> Looks a lot saner, thanks.  It's just a bit sad that we lose the type
> checking.
> 
> Acked-by: Russell King <rmk+kernel@armlinux.org.uk>

Looks like this is still pending so I'll add it into
omap-for-v4.12/fixes so we can get this out of the way.

Regards,

Tony

[toc] | [next] | [standalone]


#1643165

FromGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Date2017-05-17 11:20 +0200
Message-ID<tI3hE-1cV-15@gated-at.bofh.it>
In reply to#1642640
On Tue, May 16, 2017 at 09:01:27AM -0700, Tony Lindgren wrote:
> * Russell King - ARM Linux <linux@armlinux.org.uk> [170503 11:58]:
> > On Mon, Apr 10, 2017 at 09:52:47AM -0500, Dave Gerlach wrote:
> > > Currently the sram-exec functionality, which allows allocation of
> > > executable memory and provides an API to move code to it, is only
> > > selected in configs for the ARM architecture. Based on commit
> > > 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for
> > > function body copying") simply copying a C function pointer address
> > > using memcpy without consideration of alignment and Thumb is unsafe on
> > > ARM platforms.
> > > 
> > > The aforementioned patch introduces the fncpy macro which is a safe way
> > > to copy executable code on ARM platforms, so let's make use of that here
> > > rather than the unsafe plain memcpy that was previously used by
> > > sram_exec_copy. Now sram_exec_copy will move the code to "dst" and
> > > return an address that is guaranteed to be safely callable.
> > > 
> > > In the future, architectures hoping to make use of the sram-exec
> > > functionality must define an fncpy macro just as ARM has done to
> > > guarantee or check for safe copying to executable memory before allowing
> > > the arch to select CONFIG_SRAM_EXEC.
> > > 
> > > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> > 
> > Looks a lot saner, thanks.  It's just a bit sad that we lose the type
> > checking.
> > 
> > Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
> 
> Looks like this is still pending so I'll add it into
> omap-for-v4.12/fixes so we can get this out of the way.

It's a "fix"?  Looked to be a 4.13 issue, sorry for the delay, otherwise
I would have queued it up earlier.

No objection for you to take this through your tree.

greg k-h

[toc] | [prev] | [next] | [standalone]


#1643290

FromRussell King - ARM Linux <linux@armlinux.org.uk>
Date2017-05-17 13:50 +0200
Message-ID<tI5CO-2wd-21@gated-at.bofh.it>
In reply to#1643165
On Wed, May 17, 2017 at 11:13:17AM +0200, Greg Kroah-Hartman wrote:
> On Tue, May 16, 2017 at 09:01:27AM -0700, Tony Lindgren wrote:
> > * Russell King - ARM Linux <linux@armlinux.org.uk> [170503 11:58]:
> > > On Mon, Apr 10, 2017 at 09:52:47AM -0500, Dave Gerlach wrote:
> > > > Currently the sram-exec functionality, which allows allocation of
> > > > executable memory and provides an API to move code to it, is only
> > > > selected in configs for the ARM architecture. Based on commit
> > > > 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for
> > > > function body copying") simply copying a C function pointer address
> > > > using memcpy without consideration of alignment and Thumb is unsafe on
> > > > ARM platforms.
> > > > 
> > > > The aforementioned patch introduces the fncpy macro which is a safe way
> > > > to copy executable code on ARM platforms, so let's make use of that here
> > > > rather than the unsafe plain memcpy that was previously used by
> > > > sram_exec_copy. Now sram_exec_copy will move the code to "dst" and
> > > > return an address that is guaranteed to be safely callable.
> > > > 
> > > > In the future, architectures hoping to make use of the sram-exec
> > > > functionality must define an fncpy macro just as ARM has done to
> > > > guarantee or check for safe copying to executable memory before allowing
> > > > the arch to select CONFIG_SRAM_EXEC.
> > > > 
> > > > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> > > 
> > > Looks a lot saner, thanks.  It's just a bit sad that we lose the type
> > > checking.
> > > 
> > > Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
> > 
> > Looks like this is still pending so I'll add it into
> > omap-for-v4.12/fixes so we can get this out of the way.
> 
> It's a "fix"?  Looked to be a 4.13 issue, sorry for the delay, otherwise
> I would have queued it up earlier.

Technically, it is a fix, but my greps for "sram_exec_copy" indicate
that the code does not yet have any in-tree users.  So I don't think
there's any urgency to picking this up, and I think no need to back
port to stable trees.

-- 
RMK's Patch system: http://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up
according to speedtest.net.

[toc] | [prev] | [next] | [standalone]


#1643366

FromTony Lindgren <tony@atomide.com>
Date2017-05-17 15:50 +0200
Message-ID<tI7uV-3HE-3@gated-at.bofh.it>
In reply to#1643290
* Russell King - ARM Linux <linux@armlinux.org.uk> [170517 04:46]:
> On Wed, May 17, 2017 at 11:13:17AM +0200, Greg Kroah-Hartman wrote:
> > On Tue, May 16, 2017 at 09:01:27AM -0700, Tony Lindgren wrote:
> > > * Russell King - ARM Linux <linux@armlinux.org.uk> [170503 11:58]:
> > > > On Mon, Apr 10, 2017 at 09:52:47AM -0500, Dave Gerlach wrote:
> > > > > Currently the sram-exec functionality, which allows allocation of
> > > > > executable memory and provides an API to move code to it, is only
> > > > > selected in configs for the ARM architecture. Based on commit
> > > > > 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for
> > > > > function body copying") simply copying a C function pointer address
> > > > > using memcpy without consideration of alignment and Thumb is unsafe on
> > > > > ARM platforms.
> > > > > 
> > > > > The aforementioned patch introduces the fncpy macro which is a safe way
> > > > > to copy executable code on ARM platforms, so let's make use of that here
> > > > > rather than the unsafe plain memcpy that was previously used by
> > > > > sram_exec_copy. Now sram_exec_copy will move the code to "dst" and
> > > > > return an address that is guaranteed to be safely callable.
> > > > > 
> > > > > In the future, architectures hoping to make use of the sram-exec
> > > > > functionality must define an fncpy macro just as ARM has done to
> > > > > guarantee or check for safe copying to executable memory before allowing
> > > > > the arch to select CONFIG_SRAM_EXEC.
> > > > > 
> > > > > Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
> > > > 
> > > > Looks a lot saner, thanks.  It's just a bit sad that we lose the type
> > > > checking.
> > > > 
> > > > Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
> > > 
> > > Looks like this is still pending so I'll add it into
> > > omap-for-v4.12/fixes so we can get this out of the way.
> > 
> > It's a "fix"?  Looked to be a 4.13 issue, sorry for the delay, otherwise
> > I would have queued it up earlier.
> 
> Technically, it is a fix, but my greps for "sram_exec_copy" indicate
> that the code does not yet have any in-tree users.  So I don't think
> there's any urgency to picking this up, and I think no need to back
> port to stable trees.

OK fine, I'll drop it today from my fixes (and for-next) no problem.
I did add a fixes tag to it which would then create confusion later
on too with stable trees.

Dave, probably best to resend the patch to Greg in few days with acks
added and rebased against v4.12-rc1 because it won't apply without a
merge because of the header changes.

Regards,

Tony

[toc] | [prev] | [next] | [standalone]


#1643402

FromDave Gerlach <d-gerlach@ti.com>
Date2017-05-17 16:30 +0200
Message-ID<tI87D-4cg-1@gated-at.bofh.it>
In reply to#1643366
On 05/17/2017 08:47 AM, Tony Lindgren wrote:
> * Russell King - ARM Linux <linux@armlinux.org.uk> [170517 04:46]:
>> On Wed, May 17, 2017 at 11:13:17AM +0200, Greg Kroah-Hartman wrote:
>>> On Tue, May 16, 2017 at 09:01:27AM -0700, Tony Lindgren wrote:
>>>> * Russell King - ARM Linux <linux@armlinux.org.uk> [170503 11:58]:
>>>>> On Mon, Apr 10, 2017 at 09:52:47AM -0500, Dave Gerlach wrote:
>>>>>> Currently the sram-exec functionality, which allows allocation of
>>>>>> executable memory and provides an API to move code to it, is only
>>>>>> selected in configs for the ARM architecture. Based on commit
>>>>>> 5756e9dd0de6 ("ARM: 6640/1: Thumb-2: Symbol manipulation macros for
>>>>>> function body copying") simply copying a C function pointer address
>>>>>> using memcpy without consideration of alignment and Thumb is unsafe on
>>>>>> ARM platforms.
>>>>>>
>>>>>> The aforementioned patch introduces the fncpy macro which is a safe way
>>>>>> to copy executable code on ARM platforms, so let's make use of that here
>>>>>> rather than the unsafe plain memcpy that was previously used by
>>>>>> sram_exec_copy. Now sram_exec_copy will move the code to "dst" and
>>>>>> return an address that is guaranteed to be safely callable.
>>>>>>
>>>>>> In the future, architectures hoping to make use of the sram-exec
>>>>>> functionality must define an fncpy macro just as ARM has done to
>>>>>> guarantee or check for safe copying to executable memory before allowing
>>>>>> the arch to select CONFIG_SRAM_EXEC.
>>>>>>
>>>>>> Signed-off-by: Dave Gerlach <d-gerlach@ti.com>
>>>>>
>>>>> Looks a lot saner, thanks.  It's just a bit sad that we lose the type
>>>>> checking.
>>>>>
>>>>> Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
>>>>
>>>> Looks like this is still pending so I'll add it into
>>>> omap-for-v4.12/fixes so we can get this out of the way.
>>>
>>> It's a "fix"?  Looked to be a 4.13 issue, sorry for the delay, otherwise
>>> I would have queued it up earlier.
>>
>> Technically, it is a fix, but my greps for "sram_exec_copy" indicate
>> that the code does not yet have any in-tree users.  So I don't think
>> there's any urgency to picking this up, and I think no need to back
>> port to stable trees.
>
> OK fine, I'll drop it today from my fixes (and for-next) no problem.
> I did add a fixes tag to it which would then create confusion later
> on too with stable trees.
>
> Dave, probably best to resend the patch to Greg in few days with acks
> added and rebased against v4.12-rc1 because it won't apply without a
> merge because of the header changes.

Yes, there are no users yet. Was planning on resending this anyway, so I'll do 
that before I send my patches that make use of this.

Regards,
Dave

>
> Regards,
>
> Tony
>
>
>
>
>
>

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web