From patchwork Wed Nov 25 22:31:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 57308 Delivered-To: patch@linaro.org Received: by 10.112.155.196 with SMTP id vy4csp168393lbb; Wed, 25 Nov 2015 14:50:49 -0800 (PST) X-Received: by 10.98.13.25 with SMTP id v25mr35180025pfi.123.1448491849014; Wed, 25 Nov 2015 14:50:49 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ih4si3912160pad.179.2015.11.25.14.50.47; Wed, 25 Nov 2015 14:50:48 -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; 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; dkim=neutral (body hash did not verify) header.i=@linaro-org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752891AbbKYWuq (ORCPT + 28 others); Wed, 25 Nov 2015 17:50:46 -0500 Received: from mail-pa0-f48.google.com ([209.85.220.48]:35733 "EHLO mail-pa0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752324AbbKYWuo (ORCPT ); Wed, 25 Nov 2015 17:50:44 -0500 Received: by pacej9 with SMTP id ej9so69954013pac.2 for ; Wed, 25 Nov 2015 14:50:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=918sKGvbjPYBAxCeiujQJ1LnxhH7viay5Fs4GCfuMh0=; b=uHcDjI847szmiHjHAReRiuW21nJS2y+vKYW0Z9ezZgETa+GmDU7Fa23iIvrv5meeeV +WthsrXyPOqpDmmir6Ohmk4ghRB+m3ixwxiXGRoHrvTmulBl0Rc4q1xCZSRUEzyzfpel BSH5WiooOPYHC5ggD5MzN7T1f+Du7U7UgWIYxF2T/1inTgqy+U045r5RytUZtc8/zija bTiyqGnuDJ4nS3MaE7EerF8PXINPQxvjLfmrQj+ALyIWG56Ybde9O4/Wc+m1HNfCU55v 7TWcyO0lBXM8U1yQ7UvpGKFub0nCFGTiG3tqFDSEH2ZSnERvKpR6/2fttkHKGFZVtQ0k JqjA== 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; bh=918sKGvbjPYBAxCeiujQJ1LnxhH7viay5Fs4GCfuMh0=; b=mbwArrBUYgaHen8RjRa6ZzDnJwUFpAmPBvBjgRTURgWyKSyrkL2aWCMEH4ugCXENNZ MPsHDetd2r7Wh1Q5/UBnNVMM28X3sHRkuQCRr2trghj5YX6b95eCfMAaotUI+9kRxmQe zqgdtK+4w0v8OhqGsehV3Zun++psozWbJTeDt+jTgw3TyhOa8wzBUh31M+QHz1uUohGp IPfQE1lILfegMObEeM4X7Kmn/94Uwh27nJSmOnhwd4KYjzodZ5OO7Ri1Q7F1uWGw0eO3 s2u1/1wvFhh1NB4GX/o27f2SQlJRQ86/ZAIF8UIhZAuazVZIe79C60xW+u6/2WuHrtPp /8nQ== X-Gm-Message-State: ALoCoQkUmA4JvRk/i+P/lcOKkqlGVM0RYewf1gEHKJV11BN6dFhHvZSQWqaFxXOT29NAhB4Jz8gD X-Received: by 10.98.89.136 with SMTP id k8mr35287979pfj.58.1448491843631; Wed, 25 Nov 2015 14:50:43 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id 79sm22941885pfb.67.2015.11.25.14.50.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 25 Nov 2015 14:50:42 -0800 (PST) From: Yang Shi To: davem@davemloft.net Cc: linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] sparc64/gup: check address scope legitimacy Date: Wed, 25 Nov 2015 14:31:24 -0800 Message-Id: <1448490684-17171-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Check if user address is accessible in atomic version __get_user_pages_fast() before walking the page table. And, check if end > start in get_user_pages_fast(), otherwise fallback to slow path. Signed-off-by: Yang Shi --- arch/sparc/mm/gup.c | 5 +++++ 1 file changed, 5 insertions(+) -- 2.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ diff --git a/arch/sparc/mm/gup.c b/arch/sparc/mm/gup.c index 2e5c4fc..08b8da5 100644 --- a/arch/sparc/mm/gup.c +++ b/arch/sparc/mm/gup.c @@ -173,6 +173,9 @@ int __get_user_pages_fast(unsigned long start, int nr_pages, int write, addr = start; len = (unsigned long) nr_pages << PAGE_SHIFT; end = start + len; + if (unlikely(!access_ok(write ? VERIFY_WRITE : VERIFY_READ, + (void __user *)start, len))) + return 0; local_irq_save(flags); pgdp = pgd_offset(mm, addr); @@ -203,6 +206,8 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write, addr = start; len = (unsigned long) nr_pages << PAGE_SHIFT; end = start + len; + if (end < start) + goto slow_irqon; /* * XXX: batch / limit 'nr', to avoid large irq off latency