summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile.in4
-rw-r--r--platform.c14
-rw-r--r--platform.h1
-rw-r--r--sftp-server.c10
-rw-r--r--ssh-agent.c9
5 files changed, 20 insertions, 18 deletions
diff --git a/Makefile.in b/Makefile.in
index 76626fc6b..1a2e743a6 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -92,13 +92,13 @@ LIBSSH_OBJS=${LIBOPENSSH_OBJS} \
92 kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \ 92 kex.o kexdh.o kexgex.o kexecdh.o kexc25519.o \
93 kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \ 93 kexdhc.o kexgexc.o kexecdhc.o kexc25519c.o \
94 kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \ 94 kexdhs.o kexgexs.o kexecdhs.o kexc25519s.o \
95 platform-pledge.o 95 platform.o platform-pledge.o
96 96
97SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \ 97SSHOBJS= ssh.o readconf.o clientloop.o sshtty.o \
98 sshconnect.o sshconnect1.o sshconnect2.o mux.o 98 sshconnect.o sshconnect1.o sshconnect2.o mux.o
99 99
100SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \ 100SSHDOBJS=sshd.o auth-rhosts.o auth-passwd.o auth-rsa.o auth-rh-rsa.o \
101 audit.o audit-bsm.o audit-linux.o platform.o \ 101 audit.o audit-bsm.o audit-linux.o \
102 sshpty.o sshlogin.o servconf.o serverloop.o \ 102 sshpty.o sshlogin.o servconf.o serverloop.o \
103 auth.o auth1.o auth2.o auth-options.o session.o \ 103 auth.o auth1.o auth2.o auth-options.o session.o \
104 auth-chall.o auth2-chall.o groupaccess.o \ 104 auth-chall.o auth2-chall.o groupaccess.o \
diff --git a/platform.c b/platform.c
index 1f68df3a6..ee3e06914 100644
--- a/platform.c
+++ b/platform.c
@@ -19,6 +19,9 @@
19#include "includes.h" 19#include "includes.h"
20 20
21#include <sys/types.h> 21#include <sys/types.h>
22#if defined(HAVE_SYS_PRCTL_H)
23#include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */
24#endif
22 25
23#include <stdarg.h> 26#include <stdarg.h>
24#include <unistd.h> 27#include <unistd.h>
@@ -217,3 +220,14 @@ platform_sys_dir_uid(uid_t uid)
217#endif 220#endif
218 return 0; 221 return 0;
219} 222}
223
224void
225platform_disable_tracing(int strict)
226{
227#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
228 /* Disable ptrace on Linux without sgid bit */
229 if (prctl(PR_SET_DUMPABLE, 0) != 0)
230 if (strict)
231 fatal("unable to make the process undumpable");
232#endif
233}
diff --git a/platform.h b/platform.h
index e687c99b6..e97ecd909 100644
--- a/platform.h
+++ b/platform.h
@@ -31,6 +31,7 @@ void platform_setusercontext_post_groups(struct passwd *);
31char *platform_get_krb5_client(const char *); 31char *platform_get_krb5_client(const char *);
32char *platform_krb5_get_principal_name(const char *); 32char *platform_krb5_get_principal_name(const char *);
33int platform_sys_dir_uid(uid_t); 33int platform_sys_dir_uid(uid_t);
34void platform_disable_tracing(int);
34 35
35/* in platform-pledge.c */ 36/* in platform-pledge.c */
36void platform_pledge_agent(void); 37void platform_pledge_agent(void);
diff --git a/sftp-server.c b/sftp-server.c
index e11a1b89b..646286a3c 100644
--- a/sftp-server.c
+++ b/sftp-server.c
@@ -29,9 +29,6 @@
29#ifdef HAVE_SYS_STATVFS_H 29#ifdef HAVE_SYS_STATVFS_H
30#include <sys/statvfs.h> 30#include <sys/statvfs.h>
31#endif 31#endif
32#ifdef HAVE_SYS_PRCTL_H
33#include <sys/prctl.h>
34#endif
35 32
36#include <dirent.h> 33#include <dirent.h>
37#include <errno.h> 34#include <errno.h>
@@ -1588,16 +1585,13 @@ sftp_server_main(int argc, char **argv, struct passwd *user_pw)
1588 1585
1589 log_init(__progname, log_level, log_facility, log_stderr); 1586 log_init(__progname, log_level, log_facility, log_stderr);
1590 1587
1591#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE)
1592 /* 1588 /*
1593 * On Linux, we should try to avoid making /proc/self/{mem,maps} 1589 * On platforms where we can, avoid making /proc/self/{mem,maps}
1594 * available to the user so that sftp access doesn't automatically 1590 * available to the user so that sftp access doesn't automatically
1595 * imply arbitrary code execution access that will break 1591 * imply arbitrary code execution access that will break
1596 * restricted configurations. 1592 * restricted configurations.
1597 */ 1593 */
1598 if (prctl(PR_SET_DUMPABLE, 0) != 0) 1594 platform_disable_tracing(1); /* strict */
1599 fatal("unable to make the process undumpable");
1600#endif /* defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) */
1601 1595
1602 /* Drop any fine-grained privileges we don't need */ 1596 /* Drop any fine-grained privileges we don't need */
1603 platform_pledge_sftp_server(); 1597 platform_pledge_sftp_server();
diff --git a/ssh-agent.c b/ssh-agent.c
index 8aa25b30d..25d6ebc53 100644
--- a/ssh-agent.c
+++ b/ssh-agent.c
@@ -88,10 +88,6 @@
88#include "ssh-pkcs11.h" 88#include "ssh-pkcs11.h"
89#endif 89#endif
90 90
91#if defined(HAVE_SYS_PRCTL_H)
92#include <sys/prctl.h> /* For prctl() and PR_SET_DUMPABLE */
93#endif
94
95typedef enum { 91typedef enum {
96 AUTH_UNUSED, 92 AUTH_UNUSED,
97 AUTH_SOCKET, 93 AUTH_SOCKET,
@@ -1209,10 +1205,7 @@ main(int ac, char **av)
1209 setegid(getgid()); 1205 setegid(getgid());
1210 setgid(getgid()); 1206 setgid(getgid());
1211 1207
1212#if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) 1208 platform_disable_tracing(0); /* strict=no */
1213 /* Disable ptrace on Linux without sgid bit */
1214 prctl(PR_SET_DUMPABLE, 0);
1215#endif
1216 1209
1217#ifdef WITH_OPENSSL 1210#ifdef WITH_OPENSSL
1218 OpenSSL_add_all_algorithms(); 1211 OpenSSL_add_all_algorithms();