Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1283421

Re: [V2 PATCH] sparc64/gup: check address scope legitimacy

Path csiph.com!news.mixmin.net!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From "Shi, Yang" <yang.shi@linaro.org>
Newsgroups linux.kernel
Subject Re: [V2 PATCH] sparc64/gup: check address scope legitimacy
Date Thu, 03 Dec 2015 23:30:02 +0100
Message-ID <qBKxY-2Cl-1@gated-at.bofh.it> (permalink)
References <qyRcC-43u-15@gated-at.bofh.it> <qyRmi-4ml-17@gated-at.bofh.it> <qBIPv-1uA-3@gated-at.bofh.it>
X-Original-To Sam Ravnborg <sam@ravnborg.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro-org.20150623.gappssmtp.com; s=20150623; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=DUpXb+YuYwet/9pmnuEpnRI+li3ZKqMCKR6+0s1rE/o=; b=NDHjSeRry5amvy1N+C2RL4iQRxgNG7UOYp3Z1M8hg8iafbF5c8wsC7s3AlOSSHtLLB UvVSBaiyxRZIoUjv49/vCzSXH+NWHq0Q04xPJ16S13cnyBU7nDk8lLqUr/y0gByGBMGL S8O1jFkdiAehz+WzZeWenENShoV2ydCiK2mOJp8DqwymUaINvYA0Js2GIOfXAC6CpqDo 52+EIuc1C1x3tFSk5wBl6JRRimPE4ZzV8j9KAym4jnj5Zb63Us4qK0O3Q15y6uCdBT2H 4rUscEfKxefWc/akAWYUbmTBj7wf8VkV2v432WkgDjieWDugJKUkm1zUXhH8VkkKyBHT Xmxg==
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:content-type :content-transfer-encoding; bh=DUpXb+YuYwet/9pmnuEpnRI+li3ZKqMCKR6+0s1rE/o=; b=bT4Y6TRMegjE0OpNidHovcBJHpQoDK/iEQ4mavt85EwYFev7jm1mCTSdz+hDwLMCdQ G6ycb9N0KhBE1O66T4XOjdZ73DtuuD1KjK8XSFTt/xcoGADHG0vhWCHREEHq9Tzm+XGe NiJWhaJOVllhwLytOqEy1pD4qjWLCYheb04cI8BOrPaD/R5xmFRc73M19RkEtqQPJ3ln i2ax5kkIwR7+CLt47j3+bJJyiU5KFY6YWLzUByG32dWuIcS8HTB9i9hsnCnoge0sKy/a tqke233ABu0Pf2Cddf26Gbs0iT8j03jv5cXn4r9hUF3NxZoXW2vTd3rrzbn7tD/PMdia SDqA==
X-Gm-Message-State ALoCoQnzi3Sp7atykO6aiUKA5hAHcesJcBHmjPsmVJTjEyb0kR0g93fs3DUxrVm0wbIwrU0Ki7Fj
X-Received by 10.98.16.219 with SMTP id 88mr16720575pfq.154.1449181398044; Thu, 03 Dec 2015 14:23:18 -0800 (PST)
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0
MIME-Version 1.0
Content-Type text/plain; charset=windows-1252; format=flowed
Content-Transfer-Encoding 7bit
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 80
Organization linux.* mail to news gateway
X-Original-Cc davem@davemloft.net, linux-kernel@vger.kernel.org, sparclinux@vger.kernel.org, linaro-kernel@lists.linaro.org
X-Original-Date Thu, 03 Dec 2015 14:23:16 -0800
X-Original-Message-ID <5660C0D4.8050800@linaro.org>
X-Original-References <1448490684-17171-1-git-send-email-yang.shi@linaro.org> <1448491543-17946-1-git-send-email-yang.shi@linaro.org> <20151203203809.GA15235@ravnborg.org>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1283421

Show key headers only | View raw


On 12/3/2015 12:38 PM, Sam Ravnborg wrote:
> Hi Yang.
>
> On Wed, Nov 25, 2015 at 02:45:43PM -0800, Yang Shi wrote:
>> 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.
>
> Two different but related things in one patch is often a bad thing.
> It would have been better to split it up.
>
>
>>
>> Signed-off-by: Yang Shi <yang.shi@linaro.org>
>> ---
>> Just found slow_irqon label is not defined, added it to avoid compile error.
>>
>>   arch/sparc/mm/gup.c | 7 ++++++-
>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>
>> diff --git a/arch/sparc/mm/gup.c b/arch/sparc/mm/gup.c
>> index 2e5c4fc..cf4fb47 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;
> This change is not justified.
> Why would we take the time to first do the access_ok() stuff.
> If this had been an expensive operation then we had made this function
> slower in the normal case ( assuming there were no access violations in the
> normal case).
> When I look at the implementation of access_ok() I get the impression that
> this is not really a check we need.
>
> access_ok() always returns 1.

Thanks for pointing it out. And, I didn't notice that gup is just built 
for SPARC64. I though it is built by both 64 bit and 32 bit.

A follow-up question, is there any reason to just have sparc specific 
fast gup for 64 bit not for 32 bit?

>
>
>>
>>   	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;
>
> end can only be smaller than start if there is some overflow.
> See how end is calculated just the line above.
>
> This looks like a highly suspicious change.

I'm supposed this is used to protect the overflow. I copied the code 
from other arch. Actually, every arch has this except sparc.

Thanks,
Yang

>
> 	Sam
>

--
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/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [V2 PATCH] sparc64/gup: check address scope legitimacy Sam Ravnborg <sam@ravnborg.org> - 2015-12-03 21:40 +0100
  Re: [V2 PATCH] sparc64/gup: check address scope legitimacy "Shi, Yang" <yang.shi@linaro.org> - 2015-12-03 23:30 +0100
    Re: [V2 PATCH] sparc64/gup: check address scope legitimacy Sam Ravnborg <sam@ravnborg.org> - 2015-12-05 11:10 +0100

csiph-web