lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Message-ID: <CAJF2gTQjixePmc8qNJZB+kfyzjVb+NqFHR6GOow-aNhN883CQA@mail.gmail.com> Date: Sun, 24 Dec 2023 09:24:00 +0800 From: Guo Ren <guoren@...nel.org> To: David Laight <David.Laight@...lab.com> Cc: Leonardo Bras <leobras@...hat.com>, "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>, "paul.walmsley@...ive.com" <paul.walmsley@...ive.com>, "palmer@...belt.com" <palmer@...belt.com>, "alexghiti@...osinc.com" <alexghiti@...osinc.com>, "charlie@...osinc.com" <charlie@...osinc.com>, "xiao.w.wang@...el.com" <xiao.w.wang@...el.com>, "david@...hat.com" <david@...hat.com>, "panqinglin2020@...as.ac.cn" <panqinglin2020@...as.ac.cn>, "rick.p.edgecombe@...el.com" <rick.p.edgecombe@...el.com>, "willy@...radead.org" <willy@...radead.org>, "bjorn@...osinc.com" <bjorn@...osinc.com>, "conor.dooley@...rochip.com" <conor.dooley@...rochip.com>, "cleger@...osinc.com" <cleger@...osinc.com>, "linux-riscv@...ts.infradead.org" <linux-riscv@...ts.infradead.org>, Guo Ren <guoren@...ux.alibaba.com> Subject: Re: [PATCH V2 4/4] riscv: mm: Optimize TASK_SIZE definition On Sat, Dec 23, 2023 at 6:31 PM David Laight <David.Laight@...lab.com> wrote: > > From: Guo Ren > > Sent: 23 December 2023 02:53 > > > > On Fri, Dec 22, 2023 at 7:52 PM David Laight <David.Laight@...lab.com> wrote: > > > > > > From: Guo Ren > > > > Sent: 22 December 2023 11:25 > > > ... > > > > > > +#define TASK_SIZE (is_compat_task() ? \ > > > > > > TASK_SIZE_32 : TASK_SIZE_64) > > > > I would remove is_compat_task() in the next version because your patch > > > > contains that. > > > > > > Does TASK_SIZE get used in access_ok() ? > > > If so the repeated expansion of that 'mess' will slow things down. > > > > > > OTOH access_ok(ptr, len) can just check (ptr | (ptr + len)) < 0) > > > and rely on the page faults for everything else. > > Or do you want to discuss the bad side effect of is_compat_task()? > > > > Yes, test_thread_flag(TIF_32BIT) would slow down access_ok(). But if > > we use TASK_SIZE_MAX, VA_BITS still needs pgtable_l5_enabled, > > pgtable_l4_enabled detectation for riscv. > > > > It's not only for compat mode, but also Sv39, Sv48, Sv57. All treat > > TASK_SIZE_MAX as 0x8000000000000000, right? Then: > > access_ok(ptr, len) can just check (ptr | (ptr + len)) < 0) > > > > It's another feature and does not relate to compat mode. > > Compat mode just makes it worse... It's hard to observe. > > One possibility would be to save the task's max user address > in the task structure itself - that would save all the conditionals > at a cost of an extra value in the task structure. It would still cause memory load operation, although it is $tp->xxx. If we want to gain observability benefits, "just check (ptr | (ptr + len)) < 0)" is better. > > There is also the question of whether a normally 64-bit task > can actually make the compat mmap() system call? No. > On x86 that is certainly possible (IIRC wine does it), x86 > userspace can flip between 32bit and 63bit mode without a > system call. RISC-V can't do that because it needs sstatux.uxl=32/64, which can only be modified in S-mode. > > David > > - > Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK > Registration No: 1397386 (Wales) -- Best Regards Guo Ren
Powered by blists - more mailing lists