From patchwork Thu Mar 2 23:58:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joe Perches X-Patchwork-Id: 39722 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cjadu-0007nW-Ru; Fri, 03 Mar 2017 00:00:18 +0000 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.84_2/mailfrontend-8) with esmtp id 1cjads-0004fR-ji; Fri, 03 Mar 2017 01:00:18 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751439AbdCBX7P (ORCPT + 1 other); Thu, 2 Mar 2017 18:59:15 -0500 Received: from smtprelay0098.hostedemail.com ([216.40.44.98]:54157 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750910AbdCBX7N (ORCPT ); Thu, 2 Mar 2017 18:59:13 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay02.hostedemail.com (Postfix) with ESMTP id C577812BA12; Thu, 2 Mar 2017 23:58:20 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2, 0, 0, , d41d8cd98f00b204, joe@perches.com, :::::::::::::::::::::, RULES_HIT:41:355:379:541:599:973:981:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1543:1593:1594:1711:1730:1747:1777:1792:2194:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3874:4321:4605:5007:6119:7808:8603:8660:10004:10400:10848:11026:11232:11473:11658:11914:12296:12438:12555:12679:12740:12760:12895:12986:13148:13230:13439:14181:14659:14721:21080:21324:21433:21434:21451:30054:30056:30060:30090:30091, 0, RBL:none, CacheIP:none, Bayesian:0.5, 0.5, 0.5, Netcheck:none, DomainCache:0, MSF:not bulk, SPF:fn, MSBL:0, DNSBL:none, Custom_rules:0:0:0, LFtime:2, LUA_SUMMARY:none X-HE-Tag: slave68_e660ff6f4d13 X-Filterd-Recvd-Size: 4404 Received: from XPS-9350 (unknown [47.151.132.55]) (Authenticated sender: joe@perches.com) by omf05.hostedemail.com (Postfix) with ESMTPA; Thu, 2 Mar 2017 23:58:18 +0000 (UTC) Message-ID: <1488499097.2179.27.camel@perches.com> Subject: Re: [PATCH 24/26] ocfs2: reduce stack size with KASAN From: Joe Perches To: Arnd Bergmann Cc: kasan-dev , Andrey Ryabinin , Alexander Potapenko , Dmitry Vyukov , Networking , Linux Kernel Mailing List , linux-media@vger.kernel.org, linux-wireless , kernel-build-reports@lists.linaro.org, "David S . Miller" Date: Thu, 02 Mar 2017 15:58:17 -0800 In-Reply-To: References: <20170302163834.2273519-1-arnd@arndb.de> <20170302163834.2273519-25-arnd@arndb.de> <1488476770.2179.6.camel@perches.com> <1488494428.2179.23.camel@perches.com> X-Mailer: Evolution 3.22.3-0ubuntu0.1 Mime-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 6.0.0.2142326, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2017.3.2.235116 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, MIME_LOWER_CASE 0.05, MSGID_ADDED_BY_MTA 0.05, BODYTEXTP_SIZE_3000_LESS 0, BODY_SIZE_2000_2999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, DATE_TZ_NA 0, IN_REP_TO 0, LEGITIMATE_SIGNS 0, MSG_THREAD 0, MULTIPLE_REAL_RCPTS 0, NO_CTA_URI_FOUND 0, NO_URI_FOUND 0, NO_URI_HTTPS 0, REFERENCES 0, __BOUNCE_CHALLENGE_SUBJ 0, __BOUNCE_NDR_SUBJ_EXEMPT 0, __CC_NAME 0, __CC_NAME_DIFF_FROM_ACC 0, __CC_REAL_NAMES 0, __CT 0, __CTE 0, __CT_TEXT_PLAIN 0, __FORWARDED_MSG 0, __FRAUD_MONEY_CURRENCY 0, __FRAUD_MONEY_CURRENCY_DOLLAR 0, __HAS_CC_HDR 0, __HAS_FROM 0, __HAS_LIST_ID 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __IN_REP_TO 0, __MIME_TEXT_ONLY 0, __MIME_TEXT_P 0, __MIME_TEXT_P1 0, __MIME_VERSION 0, __MULTIPLE_RCPTS_CC_X2 0, __NO_HTML_TAG_RAW 0, __REFERENCES 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __SUBJ_ALPHA_NEGATE 0, __TO_MALFORMED_2 0, __TO_NAME 0, __TO_NAME_DIFF_FROM_ACC 0, __TO_REAL_NAMES 0' On Thu, 2017-03-02 at 23:59 +0100, Arnd Bergmann wrote: > KASAN decides that passing a pointer to _m into an extern function > (_mlog_printk) is potentially dangerous, as that function might > keep a reference to that pointer after it goes out of scope, > or it might not know the correct length of the stack object pointed to. > > We can see from looking at the __mlog_printk() function definition > that it's actually safe, but the compiler cannot see that when looking > at another source file. OK, thanks. btw: changing __mlog_printk can save ~11% (90+KB) of object text size by removing __func__ and __LINE__ and using vsprintf pointer extension %pS, __builtin_return_address(0) as it is already used in dlmmaster. (defconfig x86-64, with ocfs2) $ size fs/ocfs2/built-in.o* text data bss dec hex filename 759791 111373 105688 976852 ee7d4 fs/ocfs2/built-in.o.new 852959 111373 105688 1070020 1053c4 fs/ocfs2/built-in.o.old It's nearly the same output. --- fs/ocfs2/cluster/masklog.c | 8 ++++---- fs/ocfs2/cluster/masklog.h | 8 +++----- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/fs/ocfs2/cluster/masklog.c b/fs/ocfs2/cluster/masklog.c index d331c2386b94..a3f080f37108 100644 --- a/fs/ocfs2/cluster/masklog.c +++ b/fs/ocfs2/cluster/masklog.c @@ -64,8 +64,7 @@ static ssize_t mlog_mask_store(u64 mask, const char *buf, size_t count) return count; } -void __mlog_printk(const u64 *mask, const char *func, int line, - const char *fmt, ...) +void __mlog_printk(const u64 *mask, const char *fmt, ...) { struct va_format vaf; va_list args; @@ -90,9 +89,10 @@ void __mlog_printk(const u64 *mask, const char *func, int line, vaf.fmt = fmt; vaf.va = &args; - printk("%s(%s,%u,%u):%s:%d %s%pV", + printk("%s(%s,%u,%u):%pS %s%pV", level, current->comm, task_pid_nr(current), - raw_smp_processor_id(), func, line, prefix, &vaf); + raw_smp_processor_id(), __builtin_return_address(0), + prefix, &vaf); va_end(args); } diff --git a/fs/ocfs2/cluster/masklog.h b/fs/ocfs2/cluster/masklog.h index 3c16da69605d..56ba5baf625b 100644 --- a/fs/ocfs2/cluster/masklog.h +++ b/fs/ocfs2/cluster/masklog.h @@ -162,9 +162,8 @@ extern struct mlog_bits mlog_and_bits, mlog_not_bits; #endif -__printf(4, 5) __nocapture(2) -void __mlog_printk(const u64 *m, const char *func, int line, - const char *fmt, ...); +__printf(2, 3) __nocapture(2) +void __mlog_printk(const u64 *m, const char *fmt, ...); /* * Testing before the __mlog_printk call lets the compiler eliminate the @@ -174,8 +173,7 @@ void __mlog_printk(const u64 *m, const char *func, int line, do { \ u64 _m = MLOG_MASK_PREFIX | (mask); \ if (_m & ML_ALLOWED_BITS) \ - __mlog_printk(&_m, __func__, __LINE__, fmt, \ - ##__VA_ARGS__); \ + __mlog_printk(&_m, fmt, ##__VA_ARGS__); \ } while (0) #define mlog_errno(st) ({ \