Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp798056imu; Tue, 11 Dec 2018 07:45:41 -0800 (PST) X-Google-Smtp-Source: AFSGD/UEKraMk+1RJFuKL3TzyvEIQzVgcNmyuKrVgy8d3jIyqhOEsgBb8lK4V2OsC9wFuYtHhPaK X-Received: by 2002:a63:6150:: with SMTP id v77mr14719076pgb.266.1544543141119; Tue, 11 Dec 2018 07:45:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544543141; cv=none; d=google.com; s=arc-20160816; b=B2EiJh8Uzex6YfHc23JR58IwqwxF6ksfFne534nerGPnRasPQ/cmP05iA2Qy+o0xE/ /AqENDIZyzYq2L3KA3RMdkZKf9mkive3UafAjT5bALBgtPTL1r7EiLQmyvAQX4A7U6ud Hwe3Jexy4xb3vZYN5gCvEwt78tGqA9zeeOEHYK5oa6doxUK18AmbB89ABRLulk8Ji3Np QGyOnAzvhjKVygm6Me493RqXFxEQtcGBkyRmkxNA59ZrxeisjT3x0m+8ip1YPWGkkLat xrYpdp1t/BQURj/0wz/tYMRZ38VLK8A2sKTISPHOIHNGII99mgl2IMegZLz+a16ZlT7Z gHBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0QQvd9vNH4i7EpBTNqK3JVqOVOS7hLvPrOGvMm7Gb20=; b=QWfIsWHMQ48FU2IuqXZy9b8pPnEoY/wmzpD01OxkWuWF2KiSmISoYBM+T+Yv1hy5Ak pd5BY/+WbexOdieqVVwT8FKNpWHZxQZ7QVNTfL564vpGtElPU62yKcPySuoI8h+bNirN S4MznifFpJMh/4MkjCEJLJ9wodBlWwHDjjYrACcYVsy6Ayjbh1ql1I0T7GrZLa9NME9I m9m9cqXWXiUqCdq7v7h9HrZdbwC18oLQtLFs3fG9rgORKLHte6F7G5tKCnBG6jx+m8nM mvIh8nOv0G/aB9F5qiJLirzy18eCV9lWTmQVL2iLQmKTsLYYyF8iDn46BHq2AsWfGd+D EpXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CuP5Purr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r81si14862924pfr.164.2018.12.11.07.45.26; Tue, 11 Dec 2018 07:45:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=CuP5Purr; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727694AbeLKPn7 (ORCPT + 99 others); Tue, 11 Dec 2018 10:43:59 -0500 Received: from mail.kernel.org ([198.145.29.99]:60458 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727659AbeLKPnx (ORCPT ); Tue, 11 Dec 2018 10:43:53 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id AA8A520672; Tue, 11 Dec 2018 15:43:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1544543033; bh=EQhQ/jz9GSiri87p6mOhVl8XyyJr/v8PTvooQVHCRyQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CuP5PurrpA2NBed5Zp6kmh/PtKZuTHjRJH1/UlxlBV31ox7dzL9UGBTChXODGd7o9 668VwvWcF3PcO+K0JxD9pZAteAqn6I55ox/jVWcwY1F3vuBoRUGyArirvp5CC/prY8 aIpgx6nHqgfsTgts64NHDhmv6KvWemTqyPa+Cbaw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Anton Blanchard , Michael Ellerman , Sasha Levin Subject: [PATCH 3.18 40/54] powerpc/vdso64: Use double word compare on pointers Date: Tue, 11 Dec 2018 16:41:28 +0100 Message-Id: <20181211151548.329260078@linuxfoundation.org> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20181211151546.010073210@linuxfoundation.org> References: <20181211151546.010073210@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit 5045ea37377ce8cca6890d32b127ad6770e6dce5 ] __kernel_get_syscall_map() and __kernel_clock_getres() use cmpli to check if the passed in pointer is non zero. cmpli maps to a 32 bit compare on binutils, so we ignore the top 32 bits. A simple test case can be created by passing in a bogus pointer with the bottom 32 bits clear. Using a clk_id that is handled by the VDSO, then one that is handled by the kernel shows the problem: printf("%d\n", clock_getres(CLOCK_REALTIME, (void *)0x100000000)); printf("%d\n", clock_getres(CLOCK_BOOTTIME, (void *)0x100000000)); And we get: 0 -1 The bigger issue is if we pass a valid pointer with the bottom 32 bits clear, in this case we will return success but won't write any data to the pointer. I stumbled across this issue because the LLVM integrated assembler doesn't accept cmpli with 3 arguments. Fix this by converting them to cmpldi. Fixes: a7f290dad32e ("[PATCH] powerpc: Merge vdso's and add vdso support to 32 bits kernel") Cc: stable@vger.kernel.org # v2.6.15+ Signed-off-by: Anton Blanchard Signed-off-by: Michael Ellerman Signed-off-by: Sasha Levin --- arch/powerpc/kernel/vdso64/datapage.S | 2 +- arch/powerpc/kernel/vdso64/gettimeofday.S | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/vdso64/datapage.S b/arch/powerpc/kernel/vdso64/datapage.S index 79796de11737..3263ee23170d 100644 --- a/arch/powerpc/kernel/vdso64/datapage.S +++ b/arch/powerpc/kernel/vdso64/datapage.S @@ -57,7 +57,7 @@ V_FUNCTION_BEGIN(__kernel_get_syscall_map) bl V_LOCAL_FUNC(__get_datapage) mtlr r12 addi r3,r3,CFG_SYSCALL_MAP64 - cmpli cr0,r4,0 + cmpldi cr0,r4,0 crclr cr0*4+so beqlr li r0,__NR_syscalls diff --git a/arch/powerpc/kernel/vdso64/gettimeofday.S b/arch/powerpc/kernel/vdso64/gettimeofday.S index a76b4af37ef2..382021324883 100644 --- a/arch/powerpc/kernel/vdso64/gettimeofday.S +++ b/arch/powerpc/kernel/vdso64/gettimeofday.S @@ -145,7 +145,7 @@ V_FUNCTION_BEGIN(__kernel_clock_getres) bne cr0,99f li r3,0 - cmpli cr0,r4,0 + cmpldi cr0,r4,0 crclr cr0*4+so beqlr lis r5,CLOCK_REALTIME_RES@h -- 2.19.1