Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1283321 > unrolled thread
| Started by | Sam Ravnborg <sam@ravnborg.org> |
|---|---|
| First post | 2015-12-03 21:40 +0100 |
| Last post | 2015-12-05 11:10 +0100 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
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
| From | Sam Ravnborg <sam@ravnborg.org> |
|---|---|
| Date | 2015-12-03 21:40 +0100 |
| Subject | Re: [V2 PATCH] sparc64/gup: check address scope legitimacy |
| Message-ID | <qBIPv-1uA-3@gated-at.bofh.it> |
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. > > 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. 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/
[toc] | [next] | [standalone]
| From | "Shi, Yang" <yang.shi@linaro.org> |
|---|---|
| Date | 2015-12-03 23:30 +0100 |
| Message-ID | <qBKxY-2Cl-1@gated-at.bofh.it> |
| In reply to | #1283321 |
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/
[toc] | [prev] | [next] | [standalone]
| From | Sam Ravnborg <sam@ravnborg.org> |
|---|---|
| Date | 2015-12-05 11:10 +0100 |
| Message-ID | <qChWW-87s-15@gated-at.bofh.it> |
| In reply to | #1283421 |
> >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? I do not know - sorry. > >>@@ -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. The the other archs are likely confused as well - there is most likely some history behind that can be found if digging a little. The code is not present in the generic version. 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/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web