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


Groups > linux.kernel > #1277865 > unrolled thread

[PATCH] sparc64/gup: check address scope legitimacy

Started byYang Shi <yang.shi@linaro.org>
First post2015-11-26 00:00 +0100
Last post2015-11-26 01:40 +0100
Articles 4 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] sparc64/gup: check address scope legitimacy Yang Shi <yang.shi@linaro.org> - 2015-11-26 00:00 +0100
    [V2 PATCH] sparc64/gup: check address scope legitimacy Yang Shi <yang.shi@linaro.org> - 2015-11-26 00:10 +0100
    Re: [PATCH] sparc64/gup: check address scope legitimacy kbuild test robot <lkp@intel.com> - 2015-11-26 01:30 +0100
      Re: [PATCH] sparc64/gup: check address scope legitimacy "Shi, Yang" <yang.shi@linaro.org> - 2015-11-26 01:40 +0100

#1277865 — [PATCH] sparc64/gup: check address scope legitimacy

FromYang Shi <yang.shi@linaro.org>
Date2015-11-26 00:00 +0100
Subject[PATCH] sparc64/gup: check address scope legitimacy
Message-ID<qyRcC-43u-15@gated-at.bofh.it>
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 <yang.shi@linaro.org>
---
 arch/sparc/mm/gup.c | 5 +++++
 1 file changed, 5 insertions(+)

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

[toc] | [next] | [standalone]


#1277871 — [V2 PATCH] sparc64/gup: check address scope legitimacy

FromYang Shi <yang.shi@linaro.org>
Date2015-11-26 00:10 +0100
Subject[V2 PATCH] sparc64/gup: check address scope legitimacy
Message-ID<qyRmi-4ml-17@gated-at.bofh.it>
In reply to#1277865
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 <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;
 
 	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
@@ -244,7 +249,7 @@ int get_user_pages_fast(unsigned long start, int nr_pages, int write,
 
 slow:
 		local_irq_enable();
-
+slow_irqon:
 		/* Try to get the remaining pages with get_user_pages */
 		start += nr << PAGE_SHIFT;
 		pages += nr;
-- 
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/

[toc] | [prev] | [next] | [standalone]


#1277910

Fromkbuild test robot <lkp@intel.com>
Date2015-11-26 01:30 +0100
Message-ID<qySBH-54s-7@gated-at.bofh.it>
In reply to#1277865

[Multipart message — attachments visible in raw view] — view raw

Hi Yang,

[auto build test ERROR on v4.4-rc2]
[also build test ERROR on next-20151124]

url:    https://github.com/0day-ci/linux/commits/Yang-Shi/sparc64-gup-check-address-scope-legitimacy/20151126-065342
config: sparc64-allnoconfig (attached as .config)
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=sparc64 

All errors (new ones prefixed by >>):

   arch/sparc/mm/gup.c: In function 'get_user_pages_fast':
>> arch/sparc/mm/gup.c:210:3: error: label 'slow_irqon' used but not defined
      goto slow_irqon;
      ^

vim +/slow_irqon +210 arch/sparc/mm/gup.c

   204	
   205		start &= PAGE_MASK;
   206		addr = start;
   207		len = (unsigned long) nr_pages << PAGE_SHIFT;
   208		end = start + len;
   209		if (end < start)
 > 210			goto slow_irqon;
   211	
   212		/*
   213		 * XXX: batch / limit 'nr', to avoid large irq off latency

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[toc] | [prev] | [next] | [standalone]


#1277911

From"Shi, Yang" <yang.shi@linaro.org>
Date2015-11-26 01:40 +0100
Message-ID<qySLn-57X-1@gated-at.bofh.it>
In reply to#1277910
On 11/25/2015 4:26 PM, kbuild test robot wrote:
> Hi Yang,
>
> [auto build test ERROR on v4.4-rc2]
> [also build test ERROR on next-20151124]
>
> url:    https://github.com/0day-ci/linux/commits/Yang-Shi/sparc64-gup-check-address-scope-legitimacy/20151126-065342
> config: sparc64-allnoconfig (attached as .config)
> reproduce:
>          wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
>          chmod +x ~/bin/make.cross
>          # save the attached .config to linux build tree
>          make.cross ARCH=sparc64
>
> All errors (new ones prefixed by >>):
>
>     arch/sparc/mm/gup.c: In function 'get_user_pages_fast':
>>> arch/sparc/mm/gup.c:210:3: error: label 'slow_irqon' used but not defined
>        goto slow_irqon;

Already fixed in v2.

Thanks,
Yang

>        ^
>
> vim +/slow_irqon +210 arch/sparc/mm/gup.c
>
>     204	
>     205		start &= PAGE_MASK;
>     206		addr = start;
>     207		len = (unsigned long) nr_pages << PAGE_SHIFT;
>     208		end = start + len;
>     209		if (end < start)
>   > 210			goto slow_irqon;
>     211	
>     212		/*
>     213		 * XXX: batch / limit 'nr', to avoid large irq off latency
>
> ---
> 0-DAY kernel test infrastructure                Open Source Technology Center
> https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
>

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

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web