Patchwork [v4,13/14] rxrpc: Prepare to remove VLA usage for SKCIPHER_REQUEST_ON_STACK

login
register
mail settings
Submitter Kees Cook
Date July 11, 2018, 8:36 p.m.
Message ID <20180711203619.1020-14-keescook@chromium.org>
Download mbox | patch
Permalink /patch/10520425/
State Changes Requested
Delegated to: Herbert Xu
Headers show

Comments

Kees Cook - July 11, 2018, 8:36 p.m.
Two uses of SKCIPHER_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
(when less than 2048) once the VLA is no longer hidden from the check:

net/rxrpc/rxkad.c:398:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
net/rxrpc/rxkad.c:242:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]

This bumps the affected objects by 20% to silence the warnings while
still providing coverage is anything grows even more.

Signed-off-by: Kees Cook <keescook@chromium.org>
---
 net/rxrpc/Makefile | 1 +
 1 file changed, 1 insertion(+)
Arnd Bergmann - July 12, 2018, 3:11 p.m.
On Wed, Jul 11, 2018 at 10:36 PM, Kees Cook <keescook@chromium.org> wrote:
> Two uses of SKCIPHER_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
> (when less than 2048) once the VLA is no longer hidden from the check:
>
> net/rxrpc/rxkad.c:398:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
> net/rxrpc/rxkad.c:242:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> This bumps the affected objects by 20% to silence the warnings while
> still providing coverage is anything grows even more.
>
> Signed-off-by: Kees Cook <keescook@chromium.org>

(adding David Howells to cc)

I don't think these are in a fast path, it should be possible to just use
skcipher_alloc_req() instead of SKCIPHER_REQUEST_ON_STACK() here.
From what I can tell, neither of the two are called in atomic context, so
you should be able to use a GFP_KERNEL allocation.

      Arnd
Kees Cook - July 12, 2018, 8:23 p.m.
On Thu, Jul 12, 2018 at 8:11 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> On Wed, Jul 11, 2018 at 10:36 PM, Kees Cook <keescook@chromium.org> wrote:
>> Two uses of SKCIPHER_REQUEST_ON_STACK() will trigger FRAME_WARN warnings
>> (when less than 2048) once the VLA is no longer hidden from the check:
>>
>> net/rxrpc/rxkad.c:398:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>> net/rxrpc/rxkad.c:242:1: warning: the frame size of 1152 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>>
>> This bumps the affected objects by 20% to silence the warnings while
>> still providing coverage is anything grows even more.
>>
>> Signed-off-by: Kees Cook <keescook@chromium.org>
>
> (adding David Howells to cc)
>
> I don't think these are in a fast path, it should be possible to just use
> skcipher_alloc_req() instead of SKCIPHER_REQUEST_ON_STACK() here.
> From what I can tell, neither of the two are called in atomic context, so
> you should be able to use a GFP_KERNEL allocation.

Sure, I can do that instead.

-Kees
David Howells - July 12, 2018, 9:28 p.m.
Can I get a cc on the original patch?

David
Kees Cook - July 12, 2018, 9:34 p.m.
Hi David,

On Thu, Jul 12, 2018 at 2:28 PM, David Howells <dhowells@redhat.com> wrote:
> Can I get a cc on the original patch?

I'll add you to CC for future revisions. Here was the start of this thread:
https://lkml.kernel.org/r/20180711203619.1020-14-keescook@chromium.org

-Kees
David Howells - July 12, 2018, 10:05 p.m.
Arnd Bergmann <arnd@arndb.de> wrote:

> From what I can tell, neither of the two are called in atomic context, so
> you should be able to use a GFP_KERNEL allocation.

You need to be careful doing that since the allocation might happen in the AFS
writeback path.  I use GFP_NOIO or GFP_NOFS in rxkad.c and skb_cow_data() uses
GFP_ATOMIC - though we should have single ownership of the packet at this
point.

David

Patch

diff --git a/net/rxrpc/Makefile b/net/rxrpc/Makefile
index 6ffb7e9887ce..53e1177129e6 100644
--- a/net/rxrpc/Makefile
+++ b/net/rxrpc/Makefile
@@ -32,4 +32,5 @@  rxrpc-y := \
 
 rxrpc-$(CONFIG_PROC_FS) += proc.o
 rxrpc-$(CONFIG_RXKAD) += rxkad.o
+CFLAGS_rxkad.o += $(FRAME_WARN_BUMP_FLAG)
 rxrpc-$(CONFIG_SYSCTL) += sysctl.o