From patchwork Wed Feb 28 14:29:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinbum Park X-Patchwork-Id: 10247635 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 2762660211 for ; Wed, 28 Feb 2018 14:30:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1660928D6A for ; Wed, 28 Feb 2018 14:30:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0A1AB28D75; Wed, 28 Feb 2018 14:30:17 +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.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_MED 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 3343528D6D for ; Wed, 28 Feb 2018 14:30:16 +0000 (UTC) Received: (qmail 27823 invoked by uid 550); 28 Feb 2018 14:30:14 -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: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 27771 invoked from network); 28 Feb 2018 14:30:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mime-version:content-disposition :user-agent; bh=PAXcxfqKsRssBG3g9JLPQQTJ+xYxS8QQMlC/qiutrtM=; b=Ql1ekRvaAFmRrynzNssJko5YOekgYK21HI9Y/NBS75L0CSUU3DW6uUA2XEGpejUWIz NGmlm9JHRFtjndq+H3aRXVgrn4WdIDM3KQrN6DKlB0CkZ5/UD+M5sJ5q4UuxD3ss/RWe +wbUb5scI2IIwrUpVJn/ycloa09lcdTHdf+bQNuKuzjaO0SdI9ROlh4Vh0WpFyHPw/rD RNxq36OFyIP4ljw6axZPyWemN4WbYGvuD5ShdhXOLIKEZWvZVbV4UhfOuTn6ra5znS47 8cnTX+H2eDkcr9TgsfZa7TKo6MwAgwnHw1CvI6fGfoF/5xPQlBtySLM1C1P/kmbtw8Tu 30cQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition:user-agent; bh=PAXcxfqKsRssBG3g9JLPQQTJ+xYxS8QQMlC/qiutrtM=; b=nUchaXRdj33+A0wj3fiH6AnrRUO7U+b/iO6oqipe+te88Ep4np0JGVW2FR7xTl+K44 yrquZzta5nzXzG+rnuRANzlFM80MpKlm/QvE/haOaiHchNZ9EJB3CIzxQ4ufk5B1NLFX gKJXN0iHKV+flKdb9j6SrQcjRE2+V3h4RgSQXtAXv/NON5BaHCkbCAKvlIMrSkS19gUS 4s629AKJXxRYtu37r7ju/9dKdlfehj+o4Kif6YdXdvd7FBpKfs/KRBQ5+vKb8c+2a+6a 0fsF2kY7wsNWXU128nydhEpi98/qW6gd4e01dHH9wM3Cu698ZC7WeKiUjZkSS5jVavQY /tyg== X-Gm-Message-State: APf1xPBwYobkK3kVk6/vM5ZaaC6Ble3WdBtihxIUxafOFvBfTxdBtfZD WnPVwOgphQtYmljm8HUFRGGfsQ== X-Google-Smtp-Source: AG47ELttwvPDhysQ33Z1ojYmqlU6h5EgDUuVgL0DEcz97pb8QEIQHyy56i4Q74qAtycRhBIDbea6wg== X-Received: by 2002:a17:902:7290:: with SMTP id d16-v6mr16094262pll.31.1519828200614; Wed, 28 Feb 2018 06:30:00 -0800 (PST) Date: Wed, 28 Feb 2018 23:29:51 +0900 From: Jinbum Park To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: pombredanne@nexb.co, gregkh@linuxfoundation.org, tglx@linutronix.de, kstewart@linuxfoundation.org, luto@amacapital.net, dsafonov@virtuozzo.com, keescook@chromium.org, will.deacon@arm.com, mark.rutland@arm.com, danielmicay@gmail.com, arnd@arndb.de, catalin.marinas@arm.com Subject: [kernel-hardening] [PATCH 1/2] arm: mm: Define vdso_start, vdso_end as array Message-ID: <20180228142951.GA3136@pjb1027-Latitude-E5410> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.21 (2010-09-15) X-Virus-Scanned: ClamAV using ClamSMTP Define vdso_start, vdso_end as array to avoid compile-time analysis error for the case of built with CONFIG_FORTIFY_SOURCE. and, since vdso_start, vdso_end are used in vdso.c only, move extern-declaration from vdso.h to vdso.c. If kernel is built with CONFIG_FORTIFY_SOURCE, compile-time error happens at this code. - if (memcmp(&vdso_start, "\177ELF", 4)) The size of "&vdso_start" is recognized as 1 byte, but n is 4, So that compile-time error is reported. Signed-off-by: Jinbum Park Acked-by: Kees Cook --- arch/arm/include/asm/vdso.h | 2 -- arch/arm/kernel/vdso.c | 12 +++++++----- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/arch/arm/include/asm/vdso.h b/arch/arm/include/asm/vdso.h index 9c99e81..5b85889 100644 --- a/arch/arm/include/asm/vdso.h +++ b/arch/arm/include/asm/vdso.h @@ -12,8 +12,6 @@ void arm_install_vdso(struct mm_struct *mm, unsigned long addr); -extern char vdso_start, vdso_end; - extern unsigned int vdso_total_pages; #else /* CONFIG_VDSO */ diff --git a/arch/arm/kernel/vdso.c b/arch/arm/kernel/vdso.c index a4d6dc0..f4dd7f9 100644 --- a/arch/arm/kernel/vdso.c +++ b/arch/arm/kernel/vdso.c @@ -39,6 +39,8 @@ static struct page **vdso_text_pagelist; +extern char vdso_start[], vdso_end[]; + /* Total number of pages needed for the data and text portions of the VDSO. */ unsigned int vdso_total_pages __ro_after_init; @@ -197,13 +199,13 @@ static int __init vdso_init(void) unsigned int text_pages; int i; - if (memcmp(&vdso_start, "\177ELF", 4)) { + if (memcmp(vdso_start, "\177ELF", 4)) { pr_err("VDSO is not a valid ELF object!\n"); return -ENOEXEC; } - text_pages = (&vdso_end - &vdso_start) >> PAGE_SHIFT; - pr_debug("vdso: %i text pages at base %p\n", text_pages, &vdso_start); + text_pages = (vdso_end - vdso_start) >> PAGE_SHIFT; + pr_debug("vdso: %i text pages at base %p\n", text_pages, vdso_start); /* Allocate the VDSO text pagelist */ vdso_text_pagelist = kcalloc(text_pages, sizeof(struct page *), @@ -218,7 +220,7 @@ static int __init vdso_init(void) for (i = 0; i < text_pages; i++) { struct page *page; - page = virt_to_page(&vdso_start + i * PAGE_SIZE); + page = virt_to_page(vdso_start + i * PAGE_SIZE); vdso_text_pagelist[i] = page; } @@ -229,7 +231,7 @@ static int __init vdso_init(void) cntvct_ok = cntvct_functional(); - patch_vdso(&vdso_start); + patch_vdso(vdso_start); return 0; }