1 From eb27f9b7bf9c1dc902d9545eecf805831bd4e46c Mon Sep 17 00:00:00 2001
2 From: Jeremy Allison <jra@samba.org>
3 Date: Tue, 5 Jan 2016 11:18:12 -0800
4 Subject: [PATCH 1/8] CVE-2015-7560: s3: smbd: Add refuse_symlink() function
5 that can be used to prevent operations on a symlink.
7 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
9 Signed-off-by: Jeremy Allison <jra@samba.org>
10 Reviewed-by: Michael Adam <obnox@samba.org>
12 source3/smbd/trans2.c | 28 ++++++++++++++++++++++++++++
13 1 file changed, 28 insertions(+)
15 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
16 index 26b6523..7f47579 100644
17 --- a/source3/smbd/trans2.c
18 +++ b/source3/smbd/trans2.c
19 @@ -51,6 +51,34 @@ static char *store_file_unix_basic_info2(connection_struct *conn,
21 const SMB_STRUCT_STAT *psbuf);
23 +/****************************************************************************
24 + Check if an open file handle or pathname is a symlink.
25 +****************************************************************************/
27 +static NTSTATUS refuse_symlink(connection_struct *conn,
28 + const files_struct *fsp,
31 + SMB_STRUCT_STAT sbuf;
32 + const SMB_STRUCT_STAT *pst = NULL;
35 + pst = &fsp->fsp_name->st;
37 + int ret = vfs_stat_smb_fname(conn,
41 + return map_nt_error_from_unix(errno);
45 + if (S_ISLNK(pst->st_ex_mode)) {
46 + return NT_STATUS_ACCESS_DENIED;
48 + return NT_STATUS_OK;
51 /********************************************************************
52 Roundup a value to the nearest allocation roundup size boundary.
53 Only do this for Windows clients.
58 From f5b1bcc51e18bc85f376701bb4ae6894d97addfd Mon Sep 17 00:00:00 2001
59 From: Jeremy Allison <jra@samba.org>
60 Date: Tue, 5 Jan 2016 10:38:28 -0800
61 Subject: [PATCH 2/8] CVE-2015-7560: s3: smbd: Refuse to get an ACL from a
62 POSIX file handle on a symlink.
64 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
66 Signed-off-by: Jeremy Allison <jra@samba.org>
67 Reviewed-by: Michael Adam <obnox@samba.org>
69 source3/smbd/nttrans.c | 6 ++++++
70 1 file changed, 6 insertions(+)
72 diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
73 index 4c145e0..7255600 100644
74 --- a/source3/smbd/nttrans.c
75 +++ b/source3/smbd/nttrans.c
76 @@ -1925,6 +1925,12 @@ NTSTATUS smbd_do_query_security_desc(connection_struct *conn,
77 return NT_STATUS_ACCESS_DENIED;
80 + if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
81 + DEBUG(10, ("ACL get on symlink %s denied.\n",
83 + return NT_STATUS_ACCESS_DENIED;
86 if (security_info_wanted & (SECINFO_DACL|SECINFO_OWNER|
87 SECINFO_GROUP|SECINFO_SACL)) {
88 /* Don't return SECINFO_LABEL if anything else was
93 From 8bdbe1c90c98efbd08fc70d773d236c4ba00b1ae Mon Sep 17 00:00:00 2001
94 From: Jeremy Allison <jra@samba.org>
95 Date: Tue, 5 Jan 2016 10:52:50 -0800
96 Subject: [PATCH 3/8] CVE-2015-7560: s3: smbd: Refuse to set an ACL from a
97 POSIX file handle on a symlink.
99 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
101 Signed-off-by: Jeremy Allison <jra@samba.org>
102 Reviewed-by: Michael Adam <obnox@samba.org>
104 source3/smbd/nttrans.c | 6 ++++++
105 1 file changed, 6 insertions(+)
107 diff --git a/source3/smbd/nttrans.c b/source3/smbd/nttrans.c
108 index 7255600..d2102ca 100644
109 --- a/source3/smbd/nttrans.c
110 +++ b/source3/smbd/nttrans.c
111 @@ -877,6 +877,12 @@ NTSTATUS set_sd(files_struct *fsp, struct security_descriptor *psd,
115 + if (S_ISLNK(fsp->fsp_name->st.st_ex_mode)) {
116 + DEBUG(10, ("ACL set on symlink %s denied.\n",
117 + fsp_str_dbg(fsp)));
118 + return NT_STATUS_ACCESS_DENIED;
121 if (psd->owner_sid == NULL) {
122 security_info_sent &= ~SECINFO_OWNER;
128 From 612b032e2dedd3e07bbe79718ecbb3b68ffbb7a5 Mon Sep 17 00:00:00 2001
129 From: Jeremy Allison <jra@samba.org>
130 Date: Tue, 5 Jan 2016 11:22:12 -0800
131 Subject: [PATCH 4/8] CVE-2015-7560: s3: smbd: Refuse to set a POSIX ACL on a
134 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
136 Signed-off-by: Jeremy Allison <jra@samba.org>
137 Reviewed-by: Michael Adam <obnox@samba.org>
139 source3/smbd/trans2.c | 6 ++++++
140 1 file changed, 6 insertions(+)
142 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
143 index 7f47579..2f01e87 100644
144 --- a/source3/smbd/trans2.c
145 +++ b/source3/smbd/trans2.c
146 @@ -6480,6 +6480,7 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
148 bool valid_file_acls = True;
149 bool valid_def_acls = True;
152 if (total_data < SMB_POSIX_ACL_HEADER_SIZE) {
153 return NT_STATUS_INVALID_PARAMETER;
154 @@ -6507,6 +6508,11 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
155 return NT_STATUS_INVALID_PARAMETER;
158 + status = refuse_symlink(conn, fsp, smb_fname->base_name);
159 + if (!NT_STATUS_IS_OK(status)) {
163 DEBUG(10,("smb_set_posix_acl: file %s num_file_acls = %u, num_def_acls = %u\n",
164 smb_fname ? smb_fname_str_dbg(smb_fname) : fsp_str_dbg(fsp),
165 (unsigned int)num_file_acls,
170 From 28e6120d14e5a942df386db0444abaa93a764207 Mon Sep 17 00:00:00 2001
171 From: Jeremy Allison <jra@samba.org>
172 Date: Tue, 5 Jan 2016 11:24:36 -0800
173 Subject: [PATCH 5/8] CVE-2015-7560: s3: smbd: Refuse to get a POSIX ACL on a
176 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
178 Signed-off-by: Jeremy Allison <jra@samba.org>
179 Reviewed-by: Michael Adam <obnox@samba.org>
181 source3/smbd/trans2.c | 7 +++++++
182 1 file changed, 7 insertions(+)
184 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
185 index 2f01e87..3a098d1 100644
186 --- a/source3/smbd/trans2.c
187 +++ b/source3/smbd/trans2.c
188 @@ -4959,6 +4959,13 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
189 uint16 num_file_acls = 0;
190 uint16 num_def_acls = 0;
192 + status = refuse_symlink(conn,
194 + smb_fname->base_name);
195 + if (!NT_STATUS_IS_OK(status)) {
199 if (fsp && fsp->fh->fd != -1) {
200 file_acl = SMB_VFS_SYS_ACL_GET_FD(fsp);
206 From 659bdb80aa65c02cf4f44377cc3bcffb2a817ee0 Mon Sep 17 00:00:00 2001
207 From: Jeremy Allison <jra@samba.org>
208 Date: Tue, 5 Jan 2016 11:05:48 -0800
209 Subject: [PATCH 6/8] CVE-2015-7560: s3: smbd: Set return values early, allows
210 removal of code duplication.
212 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
214 Signed-off-by: Jeremy Allison <jra@samba.org>
215 Reviewed-by: Michael Adam <obnox@samba.org>
217 source3/smbd/trans2.c | 13 +++++--------
218 1 file changed, 5 insertions(+), 8 deletions(-)
220 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
221 index 3a098d1..6fdd1da 100644
222 --- a/source3/smbd/trans2.c
223 +++ b/source3/smbd/trans2.c
224 @@ -210,11 +210,12 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
226 ssize_t sizeret = -1;
233 if (!lp_ea_support(SNUM(conn))) {
241 @@ -264,10 +265,6 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
256 From 4ba5e7cf01b8074b0313ecb7e218355d771df1cc Mon Sep 17 00:00:00 2001
257 From: Jeremy Allison <jra@samba.org>
258 Date: Tue, 5 Jan 2016 11:29:38 -0800
259 Subject: [PATCH 7/8] CVE-2015-7560: s3: smbd: Silently return no EA's
260 available on a symlink.
262 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
264 Signed-off-by: Jeremy Allison <jra@samba.org>
265 Reviewed-by: Michael Adam <obnox@samba.org>
267 source3/smbd/trans2.c | 9 +++++++++
268 1 file changed, 9 insertions(+)
270 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
271 index 6fdd1da..8b6e4b2 100644
272 --- a/source3/smbd/trans2.c
273 +++ b/source3/smbd/trans2.c
274 @@ -209,6 +209,7 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
277 ssize_t sizeret = -1;
282 @@ -219,6 +220,14 @@ NTSTATUS get_ea_names_from_file(TALLOC_CTX *mem_ctx, connection_struct *conn,
286 + status = refuse_symlink(conn, fsp, fname);
287 + if (!NT_STATUS_IS_OK(status)) {
289 + * Just return no EA's on a symlink.
291 + return NT_STATUS_OK;
295 * TALLOC the result early to get the talloc hierarchy right.
301 From 9d8c7274ab87a0c07367e872ca1db7fd72886fde Mon Sep 17 00:00:00 2001
302 From: Jeremy Allison <jra@samba.org>
303 Date: Tue, 5 Jan 2016 11:33:48 -0800
304 Subject: [PATCH 8/8] CVE-2015-7560: s3: smbd: Refuse to set EA's on a symlink.
306 BUG: https://bugzilla.samba.org/show_bug.cgi?id=11648
308 Signed-off-by: Jeremy Allison <jra@samba.org>
309 Reviewed-by: Michael Adam <obnox@samba.org>
311 source3/smbd/trans2.c | 7 +++++++
312 1 file changed, 7 insertions(+)
314 diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c
315 index 8b6e4b2..98fd2af 100644
316 --- a/source3/smbd/trans2.c
317 +++ b/source3/smbd/trans2.c
318 @@ -584,6 +584,7 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
319 const struct smb_filename *smb_fname, struct ea_list *ea_list)
324 if (!lp_ea_support(SNUM(conn))) {
325 return NT_STATUS_EAS_NOT_SUPPORTED;
326 @@ -593,6 +594,12 @@ NTSTATUS set_ea(connection_struct *conn, files_struct *fsp,
327 return NT_STATUS_ACCESS_DENIED;
330 + status = refuse_symlink(conn, fsp, smb_fname->base_name);
331 + if (!NT_STATUS_IS_OK(status)) {
336 /* For now setting EAs on streams isn't supported. */
337 fname = smb_fname->base_name;