From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B4C4C433F5 for ; Sun, 13 Feb 2022 02:46:24 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4F60B6B0072; Sat, 12 Feb 2022 21:46:23 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4A5556B0073; Sat, 12 Feb 2022 21:46:23 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 36D1C6B0078; Sat, 12 Feb 2022 21:46:23 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (relay.a.hostedemail.com [64.99.140.24]) by kanga.kvack.org (Postfix) with ESMTP id 289436B0072 for ; Sat, 12 Feb 2022 21:46:23 -0500 (EST) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id BD50D20756 for ; Sun, 13 Feb 2022 02:46:22 +0000 (UTC) X-FDA: 79136217804.03.2861351 Received: from eu-smtp-delivery-151.mimecast.com (eu-smtp-delivery-151.mimecast.com [185.58.85.151]) by imf02.hostedemail.com (Postfix) with ESMTP id D4E9380003 for ; Sun, 13 Feb 2022 02:46:21 +0000 (UTC) Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id uk-mta-24-HG4q7pd-NqGU0GUpRUO8BQ-1; Sun, 13 Feb 2022 02:46:17 +0000 X-MC-Unique: HG4q7pd-NqGU0GUpRUO8BQ-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.28; Sun, 13 Feb 2022 02:46:16 +0000 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.028; Sun, 13 Feb 2022 02:46:16 +0000 From: David Laight To: 'Christophe Leroy' , Andrew Morton CC: "linux-kernel@vger.kernel.org" , "linux-mm@kvack.org" Subject: RE: [PATCH v2] mm: Uninline copy_overflow() Thread-Topic: [PATCH v2] mm: Uninline copy_overflow() Thread-Index: AQHYHzBgIqINanSGXk+kH56ytNcFL6yQyJxg Date: Sun, 13 Feb 2022 02:46:16 +0000 Message-ID: <1301657af59b46858662c605edf795cf@AcuMS.aculab.com> References: <1b19e3168b6bed6b9488d35e50a592f5229a2d45.1644574519.git.christophe.leroy@csgroup.eu> In-Reply-To: <1b19e3168b6bed6b9488d35e50a592f5229a2d45.1644574519.git.christophe.leroy@csgroup.eu> Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Stat-Signature: 1rjpz58mrz74hiudde8emydxn3bdjn4b X-Rspamd-Server: rspam02 X-Rspamd-Queue-Id: D4E9380003 Authentication-Results: imf02.hostedemail.com; dkim=none; dmarc=pass (policy=none) header.from=aculab.com; spf=pass (imf02.hostedemail.com: domain of david.laight@aculab.com designates 185.58.85.151 as permitted sender) smtp.mailfrom=david.laight@aculab.com X-Rspam-User: X-HE-Tag: 1644720381-689931 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: 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. >=20 > check_copy_size() have to remain inlined in order to benefit > from constant folding, but copy_overflow() is not worth inlining. >=20 > Uninline it. >=20 > This reduces the size of vmlinux by almost 4kbytes. >=20 > Signed-off-by: Christophe Leroy > --- > 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(-) >=20 > 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); >=20 > -static inline void copy_overflow(int size, unsigned long count) > -{ > -=09WARN(1, "Buffer overflow detected (%d < %lu)!\n", size, count); > -} > +void copy_overflow(int size, unsigned long count); >=20 > 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_a= ddr, long count) >=20 > =09return ret; > } > + > +void copy_overflow(int size, unsigned long count) > +{ > +=09WARN(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. =09David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1= PT, UK Registration No: 1397386 (Wales)