From patchwork Tue Jul 26 20:38:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emese Revfy X-Patchwork-Id: 9248799 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 A2EE4607F2 for ; Tue, 26 Jul 2016 20:20:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 625A6271FD for ; Tue, 26 Jul 2016 20:20:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EDCA2766D; Tue, 26 Jul 2016 20:20:07 +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=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4857271FD for ; Tue, 26 Jul 2016 20:20:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757579AbcGZUT4 (ORCPT ); Tue, 26 Jul 2016 16:19:56 -0400 Received: from mail-wm0-f65.google.com ([74.125.82.65]:32788 "EHLO mail-wm0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757109AbcGZUTz (ORCPT ); Tue, 26 Jul 2016 16:19:55 -0400 Received: by mail-wm0-f65.google.com with SMTP id o80so3399554wme.0; Tue, 26 Jul 2016 13:19:54 -0700 (PDT) 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=gSCr9R0sDdNVHk+4ryg49QNk+hSloVtB+hSiZW11eKY=; b=AVvwLTjObc0JcHZNrLj3mz0Q75nH6HltGi5hMNCAzkS4a/ipccaQ2JUzmWECB18elD gU15VZCcIbxoiqJg6eg7CdfwHXCy3MDaR5bA8bUthhpe7PWKuVM+w3ToU/mDSGYuqSvf C304S/eSs/1imT4J21pOrwmhcpOPFyXnNVl3iyAqMnIwuN9m+ucxDlGQkkahwyJ4d1VH WvhwGVray0RxHByqWPB3wSqJRmpLlJf0FkMXcjKS0QCdE08CmbxfDhqF57/Sdi2wf62j Rb/b9YwLi6eNQluwxCOng7rHGuZUXxBdcS4wlLmzV8uDyCWvqNQMiAxDDoqtISpNftsU qK2A== 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=gSCr9R0sDdNVHk+4ryg49QNk+hSloVtB+hSiZW11eKY=; b=P/BUO0HfGgNofK4bPhBerO7VtahEMEGBD2aGg+EtjPqkXdy9DuqVsk1PYOtxqbQuit IzOodevl9quoe++6TinkbxaNb648fe9GjeA2ZcygZCrrH6qjHLA0h6Sxbh9dnkxBid5F cV0586UGLo4DAfHhyv+4uaKxC5ZzSybauj/YHkbkjOcg8GFEXGNaxjzR54pgO15PnyOF NiZ2lQ6wts5ZyoSVZixZYHNKbP/wiDJ048pm4p+Lr8lb+p9n49HDrQl9BUR48acT8kQ8 KFgvn54iQz4IAXtR4hYPoBp0hQYm8cexHz6zttFaA7eOPu+NkUuJQc/JrpgJKyoN5C2L T4CA== X-Gm-Message-State: AEkoouuJS5qDB5cexmWN0kueKua5HQoTmtjnaGTOD+8M0PCRryhqKvJFcEg0fggMBpmzFg== X-Received: by 10.28.4.77 with SMTP id 74mr28623906wme.84.1469564393762; Tue, 26 Jul 2016 13:19:53 -0700 (PDT) Received: from vakond.lan (beleg.madhouse-project.org. [128.199.36.147]) by smtp.gmail.com with ESMTPSA id x203sm34578544wmg.0.2016.07.26.13.19.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jul 2016 13:19:49 -0700 (PDT) Date: Tue, 26 Jul 2016 22:38:13 +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 Subject: [PATCH v3 2/7] Split up struct warn_args Message-Id: <20160726223813.16d7cfd7f7dc514c6f7f9e9d@gmail.com> In-Reply-To: <20160726223541.513ce76f6de65389da6a6abe@gmail.com> References: <20160726223541.513ce76f6de65389da6a6abe@gmail.com> X-Mailer: Sylpheed 3.5.0 (GTK+ 2.24.30; x86_64-pc-linux-gnu) Mime-Version: 1.0 Sender: linux-kbuild-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP to enable dataflow verification by the initify plugin. This allows marking warn_slowpath* parameters as nocapture and compile time verification of the related dataflows. Signed-off-by: Emese Revfy --- include/asm-generic/bug.h | 5 +---- kernel/panic.c | 32 ++++++++++++-------------------- lib/bug.c | 2 +- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 6f96247..3048d10 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h @@ -81,11 +81,8 @@ extern void warn_slowpath_null(const char *file, const int line); do { printk(arg); __WARN_TAINT(taint); } while (0) #endif -/* used internally by panic.c */ -struct warn_args; - void __warn(const char *file, int line, void *caller, unsigned taint, - struct pt_regs *regs, struct warn_args *args); + struct pt_regs *regs, const char *fmt, va_list args); #ifndef WARN_ON #define WARN_ON(condition) ({ \ diff --git a/kernel/panic.c b/kernel/panic.c index ca8cea1..993ad20 100644 --- a/kernel/panic.c +++ b/kernel/panic.c @@ -475,13 +475,8 @@ 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, struct warn_args *args) + struct pt_regs *regs, const char *fmt, va_list args) { disable_trace_on_warning(); @@ -495,8 +490,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 (args) - vprintk(args->fmt, args->args); + if (fmt) + vprintk(fmt, args); if (panic_on_warn) { /* @@ -525,31 +520,28 @@ 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, ...) { - struct warn_args args; + va_list args; - args.fmt = fmt; - va_start(args.args, fmt); - __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, - &args); - va_end(args.args); + va_start(args, fmt); + __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, fmt, args); + va_end(args); } EXPORT_SYMBOL(warn_slowpath_fmt); void warn_slowpath_fmt_taint(const char *file, int line, unsigned taint, const char *fmt, ...) { - struct warn_args args; + va_list args; - args.fmt = fmt; - va_start(args.args, fmt); - __warn(file, line, __builtin_return_address(0), taint, NULL, &args); - va_end(args.args); + va_start(args, fmt); + __warn(file, line, __builtin_return_address(0), taint, NULL, fmt, args); + va_end(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); + __warn(file, line, __builtin_return_address(0), TAINT_WARN, NULL, NULL, NULL); } EXPORT_SYMBOL(warn_slowpath_null); #endif diff --git a/lib/bug.c b/lib/bug.c index bc3656e..c8bdebb 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; }