linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Christophe Leroy' <christophe.leroy@csgroup.eu>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-mm@kvack.org" <linux-mm@kvack.org>
Subject: RE: [PATCH v2] mm: Uninline copy_overflow()
Date: Sun, 13 Feb 2022 02:46:16 +0000	[thread overview]
Message-ID: <1301657af59b46858662c605edf795cf@AcuMS.aculab.com> (raw)
In-Reply-To: <1b19e3168b6bed6b9488d35e50a592f5229a2d45.1644574519.git.christophe.leroy@csgroup.eu>

From: Christophe Leroy
> Sent: 11 February 2022 10:16
...
> copy_overflow() is a non conditional warning called by
> check_copy_size() on an error path.
> 
> check_copy_size() have to remain inlined in order to benefit
> from constant folding, but copy_overflow() is not worth inlining.
> 
> Uninline it.
> 
> This reduces the size of vmlinux by almost 4kbytes.
> 
> Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
> ---
> v2: Added missing EXPORT_SYMBOL() and enhanced commit message
> ---
>  include/linux/thread_info.h | 5 +----
>  mm/maccess.c                | 6 ++++++
>  2 files changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/include/linux/thread_info.h b/include/linux/thread_info.h
> index 73a6f34b3847..1087d1e2be5c 100644
> --- a/include/linux/thread_info.h
> +++ b/include/linux/thread_info.h
> @@ -209,10 +209,7 @@ __bad_copy_from(void);
>  extern void __compiletime_error("copy destination size is too small")
>  __bad_copy_to(void);
> 
> -static inline void copy_overflow(int size, unsigned long count)
> -{
> -	WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
> -}
> +void copy_overflow(int size, unsigned long count);
> 
>  static __always_inline __must_check bool
>  check_copy_size(const void *addr, size_t bytes, bool is_source)
> diff --git a/mm/maccess.c b/mm/maccess.c
> index d3f1a1f0b1c1..6b11a22f4b01 100644
> --- a/mm/maccess.c
> +++ b/mm/maccess.c
> @@ -335,3 +335,9 @@ long strnlen_user_nofault(const void __user *unsafe_addr, long count)
> 
>  	return ret;
>  }
> +
> +void copy_overflow(int size, unsigned long count)
> +{
> +	WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count);
> +}
> +EXPORT_SYMBOL_GPL(copy_overflow)

Can you remove the _GPL ????

I think that basically stops you compiling any non-gpl code if the
copy_protection is enabled in the kernel build.
I'm guessing that most of the inline wrappers calling this are non-FPL
functions.

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)



      reply	other threads:[~2022-02-13  2:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-11 10:15 Christophe Leroy
2022-02-13  2:46 ` David Laight [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1301657af59b46858662c605edf795cf@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=akpm@linux-foundation.org \
    --cc=christophe.leroy@csgroup.eu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mm@kvack.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox