From patchwork Tue Jul 26 20:36:40 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emese Revfy X-Patchwork-Id: 9248793 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 A60A76077C for ; Tue, 26 Jul 2016 20:18:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9922526B39 for ; Tue, 26 Jul 2016 20:18:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8D902272AA; Tue, 26 Jul 2016 20:18:35 +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 BBE5826B39 for ; Tue, 26 Jul 2016 20:18:34 +0000 (UTC) Received: (qmail 18311 invoked by uid 550); 26 Jul 2016 20:18:32 -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 18279 invoked from network); 26 Jul 2016 20:18:28 -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=+JeWw/p5IMa8Ghm1BeFzOWqt8+s2g/ObiQl//ZKMKGU=; b=yZ0i62wDsUXAyrdHnPhxGeBeXtNYHyYMm2bK6AyEixC+IN8T+3RSDU/NsB1+U3FJ4z ccqRgXz6tB5jNTltJA0iBavgldQa1VvZ/bIXC6I23vIxlU4hqFtBIyr1yNT7DNEBVKmG cGIldgmRDGt0oTqWZsIAk263Sqd4u/SHHQxOmkFHVY1K4K+5S+D+mYbRYvqYfoS4zCk7 in6vumhE6TxaSHukBgAdEzwUm2Sh9EIzl1cyhPlC1xEhGuLUaqFNJQFT4uOMGVq0IgR6 rI0AkIttxzlwtUSoxC7xNGqgJLunuDs3prcz9NTuUW3rZtMkV2D5TnS7ojEr17wxJ2/d Q4qQ== 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=+JeWw/p5IMa8Ghm1BeFzOWqt8+s2g/ObiQl//ZKMKGU=; b=M+YofXFS3J8o+af/JpodrZ/cG8fk+nbRZzn4UFUGi1AMZNEfYZz/y5jDozshofv84t 4pMWKAr2nPYyWCvLWnOX8+YKmhG7fqKQnOUp2dYDiBpT6i7jGieKp2vSLSWOWz2hMSoH CeQxvHguNPlOPyD90Aw4X0tE+33EtAga4hft7g7UoIGLRbsBu/YU/0C7Z1EKgvlWPCwM FaySqpn42qOr6TNHbW4a6Ehlv+jaWaTvoBBgAkSB96m7ACfEFGmfj0cH+XnHYTo7oroS Rs7Cvl0qXDFHlt6N7SNinMe3QgrKIvWy+lgtelmjHqfhnkTIOa5g3aKP2uzORO9NMFGY RdyA== X-Gm-Message-State: AEkooutD/sAw3oIdY9Db6NszEc1Veeo5cXItNkXSRzV+S9DR50UrwKWe8bK2lHRl/ghviQ== X-Received: by 10.194.89.129 with SMTP id bo1mr22887342wjb.105.1469564297626; Tue, 26 Jul 2016 13:18:17 -0700 (PDT) Date: Tue, 26 Jul 2016 22:36:40 +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: <20160726223640.fe5ae5cff05ff12faf26ff44@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 Subject: [kernel-hardening] [PATCH v3 1/7] Move type casts into is_kernel_rodata X-Virus-Scanned: ClamAV using ClamSMTP so that its parameter can be marked as nocapture. Signed-off-by: Emese Revfy --- mm/util.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mm/util.c b/mm/util.c index 662cddf..d95f10b 100644 --- a/mm/util.c +++ b/mm/util.c @@ -17,10 +17,10 @@ #include "internal.h" -static inline int is_kernel_rodata(unsigned long addr) +static inline int is_kernel_rodata(const void *addr) { - return addr >= (unsigned long)__start_rodata && - addr < (unsigned long)__end_rodata; + return (unsigned long)addr >= (unsigned long)__start_rodata && + (unsigned long)addr < (unsigned long)__end_rodata; } /** @@ -31,7 +31,7 @@ static inline int is_kernel_rodata(unsigned long addr) */ void kfree_const(const void *x) { - if (!is_kernel_rodata((unsigned long)x)) + if (!is_kernel_rodata(x)) kfree(x); } EXPORT_SYMBOL(kfree_const); @@ -68,7 +68,7 @@ EXPORT_SYMBOL(kstrdup); */ const char *kstrdup_const(const char *s, gfp_t gfp) { - if (is_kernel_rodata((unsigned long)s)) + if (is_kernel_rodata(s)) return s; return kstrdup(s, gfp);