From patchwork Tue Nov 29 18:55:28 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 9453031 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 30F7D60710 for ; Tue, 29 Nov 2016 19:02:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1E95727DCD for ; Tue, 29 Nov 2016 19:02:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 10ADB283E6; Tue, 29 Nov 2016 19:02:37 +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.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A1A0427DCD for ; Tue, 29 Nov 2016 19:02:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBneH-0000mP-KF; Tue, 29 Nov 2016 19:01:01 +0000 Received: from mail-qk0-f177.google.com ([209.85.220.177]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBnZo-0004mO-Ch for linux-arm-kernel@lists.infradead.org; Tue, 29 Nov 2016 18:56:26 +0000 Received: by mail-qk0-f177.google.com with SMTP id n21so184728200qka.3 for ; Tue, 29 Nov 2016 10:56:04 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ne1DjEeAdXBn+dohTyGJgLcBb+AOI+k+PTnwECmkCGQ=; b=a0N2umiJtUjOuF2UIf2tlgisfo5L/rGBEijHE3l5pvsQ+oQWDYDeK2xbKsf2CzfygF Hs3hn0Yq2jLH/IoCFeg8qeIbUanaGpG3PXAplrPvpRIgiQM6pa6jc3VXSAiytJ7Fb9pS 5DNhyHcPxVvXbg2JzDzTpPAk3IoIh9sZefnXtPi4ItLkkBm7Dnd3HiOCWMPce39jZFnd pHLnwLqmTvozXc/8jNAvyhV10lOn1VvzKMuLfyHe2S+tiaWTt+hz7vGM6Ru3RnNBaZts tNENyGuVP0hXkTkuIciApwV4N1szpTaTDuwxQdGzZrDAfONYqNNIq861phxS57DpMPm+ YNyA== X-Gm-Message-State: AKaTC01mr92Hc1ZItzQLkA4iz0Hiq82dQtFk5XK/CZzdVECBDXOWhDE02p2te1AYQKSFytVK X-Received: by 10.55.125.194 with SMTP id y185mr25073848qkc.38.1480445763426; Tue, 29 Nov 2016 10:56:03 -0800 (PST) Received: from labbott-redhat-machine.redhat.com ([2601:602:9800:177f::df9b]) by smtp.gmail.com with ESMTPSA id p28sm31446489qtb.31.2016.11.29.10.56.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 Nov 2016 10:56:02 -0800 (PST) From: Laura Abbott To: Mark Rutland , Ard Biesheuvel , Will Deacon , Catalin Marinas , Kees Cook Subject: [PATCHv4 09/10] mm/usercopy: Switch to using lm_alias Date: Tue, 29 Nov 2016 10:55:28 -0800 Message-Id: <1480445729-27130-10-git-send-email-labbott@redhat.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1480445729-27130-1-git-send-email-labbott@redhat.com> References: <1480445729-27130-1-git-send-email-labbott@redhat.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161129_105624_738104_AFFC473A X-CRM114-Status: GOOD ( 12.64 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: x86@kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org, Ingo Molnar , "H. Peter Anvin" , Joonsoo Kim , Thomas Gleixner , Laura Abbott , Andrew Morton , linux-arm-kernel@lists.infradead.org, Marek Szyprowski MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP The usercopy checking code currently calls __va(__pa(...)) to check for aliases on symbols. Switch to using lm_alias instead. Signed-off-by: Laura Abbott Acked-by: Kees Cook Reviewed-by: Mark Rutland Tested-by: Mark Rutland --- Found when reviewing the kernel. Tested. --- mm/usercopy.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mm/usercopy.c b/mm/usercopy.c index 3c8da0a..8345299 100644 --- a/mm/usercopy.c +++ b/mm/usercopy.c @@ -108,13 +108,13 @@ static inline const char *check_kernel_text_object(const void *ptr, * __pa() is not just the reverse of __va(). This can be detected * and checked: */ - textlow_linear = (unsigned long)__va(__pa(textlow)); + textlow_linear = (unsigned long)lm_alias(textlow); /* No different mapping: we're done. */ if (textlow_linear == textlow) return NULL; /* Check the secondary mapping... */ - texthigh_linear = (unsigned long)__va(__pa(texthigh)); + texthigh_linear = (unsigned long)lm_alias(texthigh); if (overlaps(ptr, n, textlow_linear, texthigh_linear)) return "";