Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-16 Thread Thomas Bogendoerfer
On Thu, Apr 15, 2021 at 11:26:40PM +0200, Thomas Bogendoerfer wrote: > Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") changed the access_ok > for strnlen_user to check the whole range, which broke some callers > of strndup_user(). Restore the old behaviour and just check the first byte. > > Fi

[PATCH] MIPS: Fix strnlen_user access check

2021-04-15 Thread Thomas Bogendoerfer
Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") changed the access_ok for strnlen_user to check the whole range, which broke some callers of strndup_user(). Restore the old behaviour and just check the first byte. Fixes: 04324f44cb69 ("MIPS: Remove get_fs/set_fs") Signed-off-by: Thomas Bogendoe

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-14 Thread Thomas Bogendoerfer
On Tue, Apr 13, 2021 at 04:01:13PM +, David Laight wrote: > From: Thomas Bogendoerfer > > Sent: 13 April 2021 16:19 > > > > On Tue, Apr 13, 2021 at 12:37:25PM +, David Laight wrote: > > > From: Thomas Bogendoerfer > > > > Sent: 13 April 2021 12:15 > > > ... > > > > > The __access_ok() is

RE: [PATCH] MIPS: Fix strnlen_user access check

2021-04-13 Thread David Laight
From: Thomas Bogendoerfer > Sent: 13 April 2021 16:19 > > On Tue, Apr 13, 2021 at 12:37:25PM +, David Laight wrote: > > From: Thomas Bogendoerfer > > > Sent: 13 April 2021 12:15 > > ... > > > > The __access_ok() is noted with `Ensure that the range [addr, addr+size) > > > > is within the proc

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-13 Thread Thomas Bogendoerfer
On Tue, Apr 13, 2021 at 12:37:25PM +, David Laight wrote: > From: Thomas Bogendoerfer > > Sent: 13 April 2021 12:15 > ... > > > The __access_ok() is noted with `Ensure that the range [addr, addr+size) > > > is within the process's address space`. Does the range checked by > > > __access_ok() o

RE: [PATCH] MIPS: Fix strnlen_user access check

2021-04-13 Thread David Laight
From: Thomas Bogendoerfer > Sent: 13 April 2021 12:15 ... > > The __access_ok() is noted with `Ensure that the range [addr, addr+size) > > is within the process's address space`. Does the range checked by > > __access_ok() on MIPS is [addr, addr+size]. So if we want to use > > access_ok(s, 1), sho

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-13 Thread Thomas Bogendoerfer
On Tue, Apr 13, 2021 at 09:15:48AM +0800, Jinyang He wrote: > On 04/12/2021 10:27 PM, Thomas Bogendoerfer wrote: > > > diff --git a/arch/mips/include/asm/uaccess.h > > > b/arch/mips/include/asm/uaccess.h > > > index 91bc7fb..eafc99b 100644 > > > --- a/arch/mips/include/asm/uaccess.h > > > +++ b/ar

RE: [PATCH] MIPS: Fix strnlen_user access check

2021-04-13 Thread David Laight
From: Jinyang He > Sent: 13 April 2021 02:16 > > > On Mon, Apr 12, 2021 at 11:02:19AM +0800, Tiezhu Yang wrote: > >> On 04/11/2021 07:04 PM, Jinyang He wrote: > >>> Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for > >>> strnlen_user(). Jump out when checking access_ok() wit

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-12 Thread Jinyang He
On 04/12/2021 10:27 PM, Thomas Bogendoerfer wrote: On Mon, Apr 12, 2021 at 11:02:19AM +0800, Tiezhu Yang wrote: On 04/11/2021 07:04 PM, Jinyang He wrote: Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition t

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-12 Thread Thomas Bogendoerfer
On Mon, Apr 12, 2021 at 11:02:19AM +0800, Tiezhu Yang wrote: > On 04/11/2021 07:04 PM, Jinyang He wrote: > > Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for > > strnlen_user(). Jump out when checking access_ok() with condition that > > (s + strlen(s)) < __UA_LIMIT <= (s + n

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-12 Thread Jinyang He
On 04/11/2021 07:04 PM, Jinyang He wrote: Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition that (s + strlen(s)) < __UA_LIMIT <= (s + n). The old __strnlen_user_asm() just checked (ua_limit & s) without check

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-12 Thread Tiezhu Yang
On 04/12/2021 11:02 AM, Tiezhu Yang wrote: On 04/11/2021 07:04 PM, Jinyang He wrote: Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition that (s + strlen(s)) < __UA_LIMIT <= (s + n). The old __strnlen_user_asm

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-11 Thread Jinyang He
On 04/12/2021 11:02 AM, Tiezhu Yang wrote: On 04/11/2021 07:04 PM, Jinyang He wrote: Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition that (s + strlen(s)) < __UA_LIMIT <= (s + n). The old __strnlen_user_as

Re: [PATCH] MIPS: Fix strnlen_user access check

2021-04-11 Thread Tiezhu Yang
On 04/11/2021 07:04 PM, Jinyang He wrote: Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition that (s + strlen(s)) < __UA_LIMIT <= (s + n). The old __strnlen_user_asm() just checked (ua_limit & s) without check

[PATCH] MIPS: Fix strnlen_user access check

2021-04-11 Thread Jinyang He
Commit 04324f44cb69 ("MIPS: Remove get_fs/set_fs") brought a problem for strnlen_user(). Jump out when checking access_ok() with condition that (s + strlen(s)) < __UA_LIMIT <= (s + n). The old __strnlen_user_asm() just checked (ua_limit & s) without checking (ua_limit & (s + n)). Therefore, find st