From mboxrd@z Thu Jan 1 00:00:00 1970 From: ebiederm@xmission.com (Eric W. Biederman) Subject: Re: [PATCH 1/2] alpha/ptrace: Record and handle the absence of switch_stack Date: Wed, 16 Jun 2021 15:42:05 -0500 Message-ID: <87czsla6ea.fsf@disp2133> References: <87sg1p30a1.fsf@disp2133> <87pmwsytb3.fsf@disp2133> <87sg1lwhvm.fsf@disp2133> <6e47eff8-d0a4-8390-1222-e975bfbf3a65@gmail.com> <924ec53c-2fd9-2e1c-bbb1-3fda49809be4@gmail.com> <87eed4v2dc.fsf@disp2133> <5929e116-fa61-b211-342a-c706dcb834ca@gmail.com> <87fsxjorgs.fsf@disp2133> <87zgvqor7d.fsf_-_@disp2133> <87mtrpg47k.fsf@disp2133> <87pmwlek8d.fsf_-_@disp2133> <87k0mtek4n.fsf_-_@disp2133> Mime-Version: 1.0 Return-path: In-Reply-To: (Linus Torvalds's message of "Wed, 16 Jun 2021 13:00:52 -0700") List-ID: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: Linus Torvalds Cc: Michael Schmitz , linux-arch , Jens Axboe , Oleg Nesterov , Al Viro , Linux Kernel Mailing List , Richard Henderson , Ivan Kokshaysky , Matt Turner , alpha , Geert Uytterhoeven , linux-m68k , Arnd Bergmann , Ley Foon Tan , Tejun Heo , Kees Cook Linus Torvalds writes: > On Wed, Jun 16, 2021 at 11:32 AM Eric W. Biederman > wrote: >> >> Prevent security holes by recording when all of the registers are >> available so generic code changes do not result in security holes >> on alpha. > > Please no, not this way. ldl/stc is extremely expensive on some alpha cpus. > > I really think thatTIF_ALLREGS_SAVED bit isn't worth it, except > perhaps for debugging. > > And even for debugging, I think it would be both easier and cheaper to > just add a magic word to the entry stack instead. I think I can do something like that. Looking at arch/alpha/asm/cache.h it looks like alpha had either 32byte or 64bit cachelines. Which makes struct switch_stack a full 10 or 5 cachelines in size. So pushing something extra might hit an extra cacheline. However it looks like struct pt_regs is 16 bytes short of a full cache line so struct switch_stack isn't going to be cacheline aligned. Adding an extra 8 bytes of magic number will hopefully be in the noise. If I can I would like to find something that is cheap enough that I can always leave on. Mostly because there is little enough testing that a bug that allows anyone to stomp the kernel stack has existed for 17 years without being noticed. If you want it to be a debug option only I can certainly make that happen. I am still going "Eek! Arbitrary stack smash!" in my head. Eric