|
Message-ID: <0bf9be39-82bb-ad3a-a3c3-e41bebedba7e@suse.cz> Date: Wed, 4 Jul 2018 19:47:38 +0200 From: Vlastimil Babka <vbabka@...e.cz> To: Kees Cook <keescook@...omium.org> Cc: Chris von Recklinghausen <crecklin@...hat.com>, Laura Abbott <labbott@...hat.com>, Paolo Abeni <pabeni@...hat.com>, LKML <linux-kernel@...r.kernel.org>, Linux-MM <linux-mm@...ck.org>, Kernel Hardening <kernel-hardening@...ts.openwall.com> Subject: Re: [PATCH v7] add param that allows bootline control of hardened usercopy On 07/04/2018 06:52 PM, Kees Cook wrote: > On Wed, Jul 4, 2018 at 6:43 AM, Vlastimil Babka <vbabka@...e.cz> wrote: >> On 07/03/2018 09:43 PM, Chris von Recklinghausen wrote: >> >> Subject: [PATCH v7] add param that allows bootline control of hardened >> usercopy >> >> s/bootline/boot time/ ? >> >>> v1->v2: >>> remove CONFIG_HUC_DEFAULT_OFF >>> default is now enabled, boot param disables >>> move check to __check_object_size so as to not break optimization of >>> __builtin_constant_p() >> >> Sorry for late and drive-by suggestion, but I think the change above is >> kind of a waste because there's a function call overhead only to return >> immediately. >> >> Something like this should work and keep benefits of both the built-in >> check and avoiding function call? >> >> static __always_inline void check_object_size(const void *ptr, unsigned >> long n, bool to_user) >> { >> if (!__builtin_constant_p(n) && >> static_branch_likely(&bypass_usercopy_checks)) >> __check_object_size(ptr, n, to_user); >> } > > This produces less efficient code in the general case, and I'd like to > keep the general case (hardening enabled) as fast as possible. How specifically is the code less efficient? It should be always a static key check (no-op thanks to the code patching involved) and a function call in the "hardening enabled" case, just in different order. And in either case compiled out if it's a constant. > -Kees >
Powered by blists - more mailing lists
Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.