From patchwork Wed Jul 27 15:31:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emese Revfy X-Patchwork-Id: 9249991 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 22025607F0 for ; Wed, 27 Jul 2016 15:13:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1412C269B2 for ; Wed, 27 Jul 2016 15:13:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0879826D17; Wed, 27 Jul 2016 15:13:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id 7168426B39 for ; Wed, 27 Jul 2016 15:13:37 +0000 (UTC) Received: (qmail 23813 invoked by uid 550); 27 Jul 2016 15:13:36 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: kernel-hardening@lists.openwall.com Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 23739 invoked from network); 27 Jul 2016 15:13:31 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RUO9ChFqZ4QNNhswRfSGK3YdCd4u2X3xojCZ59Cb7EQ=; b=D2xS9E7D2h7zZYARh81Ays5YsN8ib5omSlNhcl5RYpou8v7IHWxTYwWFTMO5wHgqtM 4slV/Gu2+7wECctNN287FoAh0FXdGjsBULXndEF9uDjWxtgT8Hm1WI1rWh/1Ib4QyYOx JF+YWpXhw7GmPQnDuzZjI4EHo42Xt8UqCQ+41bdE9zaRJ4i0uyMoE0xB/znlW8DaehjP fKaxQ1fN+BQqlkQ6EeWQlSF2vKGYs03USvNMEtekvy+EnE31Yt2QYlVq5edafSt/H7Kn ctp0xIsLSgdOWXy/JplpeMWYJlhIxO6BlVTjczszta5U/vL5lrcPY5e0UbHjOVNU80a2 2/UQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RUO9ChFqZ4QNNhswRfSGK3YdCd4u2X3xojCZ59Cb7EQ=; b=CFq4xPDwvU2zMHlkLqouOQtXjBV7mRtCGjv2YyBh9Z8g2xk+gbwxfw4fH7GOT5BKKa QDwcCaAaBiln9t/wovin7Qydvhv8Cm6V9lkl/azqWCS0CqSa5R7af2IN58q2XNjbbBj3 J+xez6laoP54mjiECa1Koi9KUWfTlRNHGDyyScMgq59EfyZ/qXMCAfAjXl1A1QD/LMuS dmJPW204aC9i27l4gdOmSQ+4Jas1NvGGrMRWpqSO2JOsJ2wxEi05++hxNBZX5BuvEKgv iCURRO5ncUZXJ9bR1nYLEx7FAle8DZSJwlq5cDKNiwbEMSlMrTTj2pT8sWI+X6LnEDD5 U2YA== X-Gm-Message-State: AEkoouvKiNlYKAzT05pK67kXHrYtF4izQSUXO1uaZlcS2ZKcEaNUEa2s0LmhuQ8uhz770g== X-Received: by 10.194.18.198 with SMTP id y6mr30055345wjd.87.1469632400309; Wed, 27 Jul 2016 08:13:20 -0700 (PDT) Date: Wed, 27 Jul 2016 17:31:42 +0200 From: Emese Revfy To: kernel-hardening@lists.openwall.com Cc: pageexec@freemail.hu, spender@grsecurity.net, mmarek@suse.com, keescook@chromium.org, linux-kernel@vger.kernel.org, yamada.masahiro@socionext.com, linux-kbuild@vger.kernel.org, minipli@ld-linux.so, linux@armlinux.org.uk, catalin.marinas@arm.com, linux@rasmusvillemoes.dk, david.brown@linaro.org, benh@kernel.crashing.org, tglx@linutronix.de, akpm@linux-foundation.org, jlayton@poochiereds.net, arnd@arndb.de, sam@ravnborg.org, isdn@linux-pingi.de Message-Id: <20160727173142.c8bba4e83d80e9020018216d@gmail.com> In-Reply-To: <20160726223813.16d7cfd7f7dc514c6f7f9e9d@gmail.com> References: <20160726223541.513ce76f6de65389da6a6abe@gmail.com> <20160726223813.16d7cfd7f7dc514c6f7f9e9d@gmail.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Subject: [kernel-hardening] [PATCH v3 2/7] Split up struct warn_args X-Virus-Scanned: ClamAV using ClamSMTP Disable the initify plugin on the 6th parameter of __warn() because the va_list type can't be NULL on the tile arch. Signed-off-by: Emese Revfy --- include/asm-generic/bug.h | 7 +++++-- kernel/panic.c | 32 ++++++++++++++++++++------------ lib/bug.c | 2 +- 3 files changed, 26 insertions(+), 15 deletions(-) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 13a9241..f6ae0d7 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -81,9 +81,12 @@ extern __nocapture(1) void warn_slowpath_null(const char *file, const int line); do { printk(arg); __WARN_TAINT(taint); } while (0) #endif -__nocapture(1, 6) +/* used internally by panic.c */ +struct warn_args; + +__nocapture(1, 0) void __warn(const char *file, int line, void *caller, unsigned taint, - struct pt_regs *regs, const char *fmt, va_list args); + struct pt_regs *regs, struct warn_args *args); #ifndef WARN_ON #define WARN_ON(condition) ({ \ diff --git a/kernel/panic.c b/kernel/panic.c index 993ad20..ca8cea1 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -475,8 +475,13 @@ void oops_exit(void) kmsg_dump(KMSG_DUMP_OOPS); } +struct warn_args { + const char *fmt; + va_list args; +}; + void __warn(const char *file, int line, void *caller, unsigned taint, - struct pt_regs *regs, const char *fmt, va_list args) + struct pt_regs *regs, struct warn_args *args) { disable_trace_on_warning(); @@ -490,8 +495,8 @@ void __warn(const char *file, int line, void *caller, unsigned taint, pr_warn("WARNING: CPU: %d PID: %d at %pS\n", raw_smp_processor_id(), current->pid, caller); - if (fmt) - vprintk(fmt, args); + if (args) + vprintk(args->fmt, args->args); if (panic_on_warn) { /* @@ -520,28 +525,31 @@ void __warn(const char *file, int line, void *caller, unsigned taint, #ifdef WANT_WARN_ON_SLOWPATH void warn_slowpath_fmt(const char *file, int line, const char *fmt, ...) { - va_list args; + struct warn_args args; - va_start(args, fmt); - __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, fmt, args); - va_end(args); + args.fmt = fmt; + va_start(args.args, fmt); + __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, + &args); + va_end(args.args); } EXPORT_SYMBOL(warn_slowpath_fmt); void warn_slowpath_fmt_taint(const char *file, int line, unsigned taint, const char *fmt, ...) { - va_list args; + struct warn_args args; - va_start(args, fmt); - __warn(file, line, __builtin_return_address(0), taint, NULL, fmt, args); - va_end(args); + args.fmt = fmt; + va_start(args.args, fmt); + __warn(file, line, __builtin_return_address(0), taint, NULL, &args); + va_end(args.args); } EXPORT_SYMBOL(warn_slowpath_fmt_taint); void warn_slowpath_null(const char *file, int line) { - __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL); + __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL); } EXPORT_SYMBOL(warn_slowpath_null); #endif diff --git a/lib/bug.c b/lib/bug.c index c8bdebb..bc3656e 100644 --- a/lib/bug.c +++ b/lib/bug.c @@ -168,7 +168,7 @@ enum bug_trap_type report_bug(unsigned long bugaddr, struct pt_regs *regs) if (warning) { /* this is a WARN_ON rather than BUG/BUG_ON */ __warn(file, line, (void *)bugaddr, BUG_GET_TAINT(bug), regs, - NULL, NULL); + NULL); return BUG_TRAP_TYPE_WARN; }