Skip to content

Adding Address Space Layout Randomization support for SSH binaries in AIX#613

Open
AkankshaP15 wants to merge 3 commits intoopenssh:masterfrom
AkankshaP15:master
Open

Adding Address Space Layout Randomization support for SSH binaries in AIX#613
AkankshaP15 wants to merge 3 commits intoopenssh:masterfrom
AkankshaP15:master

Conversation

@AkankshaP15
Copy link

Adding Address Space Layout Randomization support for SSH binaries in AIX to enhance security against memory-based attacks.
This feature is designed to improve security by loading shared memory objects at random addresses instead of fixed addresses.

Copy link
Contributor

@daztucker daztucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will break any AIX systems using xlc whose linker doesn't support that flag, which will likely include a number where OpenSSH would otherwise work fine. Instead, could you please use the OSSH_CHECK_LDFLAG_LINK macro to only add it if the linker supports it?

@daztucker
Copy link
Contributor

also, you placed it inside a configure test that's for a completely different purpose. Given that it's a linker flag, does it work with alternative compilers such as gcc or clang on those systems? Either way I think it should be its own stand-alone test, not inside AC_MSG_CHECKING([if compiler allows macro redefinitions]).

@AkankshaP15
Copy link
Author

I have updated configure.ac in the latest commit. Below are the test scenarios executed for the cc, gcc, and ibm-clang compilers:

  1. cc compiler (Supports -baslr flag)
# ./configure --with-zlib=<zlib_directory> --with-ssl-dir=<openssl_directory> --with-baslr
checking for cc... cc
…
…
checking if cc -qlanglvl=extc1x supports link flag -baslr... yes
checking whether linker supports -baslr... yes
…
…
# grep '^LDFLAGS' Makefile
LDFLAGS=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory>  -baslr -blibpath:/usr/lib:/lib 
LDFLAGS_NOPIE=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory>  -baslr -blibpath:/usr/lib:/lib 

  1. gcc compiler (Doesn’t support -baslr flag)
# ./configure --with-zlib=<zlib_directory> --with-ssl-dir=<openssl_directory> --with-baslr
checking for gcc... gcc
…
…
checking if gcc supports link flag -baslr... no
checking whether linker supports -baslr... no
…
…
# grep '^LDFLAGS' Makefile
LDFLAGS=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory>  -Wl,-blibpath:/usr/lib:/lib 
LDFLAGS_NOPIE=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory> -Wl,-blibpath:/usr/lib:/lib

  1. ibm-clang compiler (Supports -baslr flag)
# ./configure --with-zlib=<zlib_directory> --with-ssl-dir=<openssl_directory> --with-baslr
checking for ibm-clang... ibm-clang
…
…
checking if ibm-clang supports link flag -baslr... yes
checking whether linker supports -baslr... yes
…
…
# grep '^LDFLAGS' Makefile
LDFLAGS=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory> -fstack-protector-strong -baslr -Wl,-blibpath:/usr/lib:/lib 
LDFLAGS_NOPIE=-L. -Lopenbsd-compat/ -L/<openssl_directory> -L/<zlib_directory> -fstack-protector-strong -baslr -Wl,-blibpath:/usr/lib:/lib 

@AkankshaP15
Copy link
Author

@daztucker, Please let me know if there are any comments.

configure.ac Outdated
dnl Check whether the linker accepts -baslr
OSSH_CHECK_LDFLAG_LINK([-baslr])

AC_MSG_CHECKING([whether linker supports -baslr])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this part is unnecessary, since OSSH_CHECK_LDFLAG_LINK already provides all of this information in its output, and adds it to LDFLAGS if it's supported (see m4/openssh.m4).

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay. We will address it.

fi
LDFLAGS="$saved_LDFLAGS"

AC_ARG_WITH([baslr],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is there any reason this can't be part of the rest of the use_toolchain_hardening --with-hardening flags and be on by default when supported?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-baslr is linker/loader specific option for AIX (similar to pie for other OS). Hence, we are handling it under aix target specific case instead.

Since the existing code is built without ASLR, we wish to keep this behavior as is and enable it when explicitly specified.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

-baslr is linker/loader specific option for AIX (similar to pie for other OS). Hence, we are handling it under aix target specific case instead.

If it's not supported, the OSSH_CHECK_LDFLAG_LINK check will fail and the flag won't be added.

Since the existing code is built without ASLR, we wish to keep this behavior as is and enable it when explicitly specified.

Why? What's the point of having a security feature that's off by default? Now if it was problematic or very slow that might be a good reason, but is it?

@AkankshaP15
Copy link
Author

I have updated configure.ac in the latest commit to drop redundant -baslr linker check.
@daztucker, Please let me know if there are any comments.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants