From patchwork Mon Mar 5 11:17:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jinbum Park X-Patchwork-Id: 10258717 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 D4B4260134 for ; Mon, 5 Mar 2018 11:18:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C444328553 for ; Mon, 5 Mar 2018 11:18:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B8B3428935; Mon, 5 Mar 2018 11:18:09 +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 E71C028553 for ; Mon, 5 Mar 2018 11:18:07 +0000 (UTC) Received: (qmail 9967 invoked by uid 550); 5 Mar 2018 11:18:05 -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 9925 invoked from network); 5 Mar 2018 11:18:04 -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=A8iIm/CXEgV3m1ADZaTfq8VgkAJiYbJddmzSFFnPJp4=; b=YJFponBO1rqgURNXqnkw8Rn7h51JY9DAvvBJolLOlnHfRlakmLzzImklw9EmJbFkrb qmym6cjbKncfRumhYazM4tcKpqSkGQruv9PQtxx9j67YA5Cy8zK2xzXx4IJ+roQilpEP /kWQHVCqZVUJMP/Vw00XyDZnn+ROmYLtwHyUAQiic4snMCPJh7TQRN+OrrrrFZnZ6Y9v VPZRxsfhu51Hc8EYUtNURna8UcBDtBno1MUGbCv7NAC4CgRcfvuLYAUaNArO4Z3LmUdm K6txX//cj21bmhQmB8YVrQ+tyegvuAxJfpsSHLMsi+9glplCTLmdqTFpqfXc686LoCws 1nmA== 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=A8iIm/CXEgV3m1ADZaTfq8VgkAJiYbJddmzSFFnPJp4=; b=X4NnqEWEKeipWvJxsrKXZGtvUaZkdX1DlGh9+JleDdmntlcaezZEVer3DklIiez7Cf 2so11+LO7cA/IxEcgWHj/P9oybOTgZtwGZLIjfIJj7S4p5C5/9Wlw0H2Sz+GKkwHn9iq A2m2vVR3+3oC4v5npToQ9wc92JiKKQKaWPXJQHQeqH3ZnmiQBpWvWAkY5+oKEHzPzOSb DtujysX+7KLD2ztHFtCNm0oKolBYdV6Mt74gtuZmFZvWaQYRU7/OBxkI8pf8LvS8rOtA 5FbgmOEQ2OK9gPlZ1TofpUgfsFjS4l2LIG9fOfFv/gWVWqILf+zIOrfdEC4OcJJbPhj5 g88w== X-Gm-Message-State: APf1xPB7wCMfPAYzjexwT82c9hdynbvsO0KKWhRuNmYDcVHaKfpGlroa /vSIbmoT3SYSX3VS2zl+0/A= X-Google-Smtp-Source: AG47ELubqxMeIDbSVhJK439vs90xfFafutWnnkUYgYX2cVOth7JzYCkG7w6VqUg/NA68zLerYjbBBg== X-Received: by 2002:a17:902:7c84:: with SMTP id y4-v6mr12610993pll.305.1520248673260; Mon, 05 Mar 2018 03:17:53 -0800 (PST) Date: Mon, 5 Mar 2018 20:17:45 +0900 From: Jinbum Park To: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kernel-hardening@lists.openwall.com Cc: 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: [PATCH v2 1/2] arm: mm: Define vdso_start, vdso_end as array Message-ID: <20180305111745.GA4193@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. Acked-by: Kees Cook Signed-off-by: Jinbum Park --- v2: No changes --- 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; }