]> git.ipfire.org Git - thirdparty/shadow.git/commit
su: Prevent stack overflow in check_perms
authorSamanta Navarro <ferivoz@riseup.net>
Tue, 23 May 2023 11:55:09 +0000 (11:55 +0000)
committerSerge Hallyn <serge@hallyn.com>
Thu, 25 May 2023 13:25:42 +0000 (08:25 -0500)
commita116e20c76f36d6f72f101508f634b6c1bddb9be
treeab4705b349d9ecddb6c42dd863c60416793da3d0
parent4ad359ccc69ebfac5e6447562fca5a1741111324
su: Prevent stack overflow in check_perms

This is no real world security fix.

The overflow could occur if too many layered subsystems are encountered
because the function check_perms calls itself recursively.

It would already take a misconfigured system for this to achieve it.

Use an iterative approach by calling the do_check_perms in a loop
instead of calling itself recursively.

As a side note: At least GCC 13 optimized this code and already uses
a jmp in its assembler code. I could only see the stack overflow by
activating address sanitizer which prevented the optimization.

Co-developed-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Samanta Navarro <ferivoz@riseup.net>
src/su.c