The branch, v4-14-test has been updated via 77fac5ed243 libcli/smb: let smb2_signing_decrypt_pdu() cope with gnutls_aead_cipher_decrypt() ptext_len bug via bbd4cd045ad libcli/smb: fix error checking in smb2_signing_decrypt_pdu() invalid ptext_len via f75a0588512 selftest/quick: add smb2.session from e59bf6bb2c3 s3/libads: ensure a sockaddr variable is correctly zero initialized
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-14-test - Log ----------------------------------------------------------------- commit 77fac5ed243d7cc1b5f288ba7d4c7bbe2685789e Author: Stefan Metzmacher <me...@samba.org> Date: Mon Jan 31 20:33:43 2022 +0100 libcli/smb: let smb2_signing_decrypt_pdu() cope with gnutls_aead_cipher_decrypt() ptext_len bug The initial implementation of gnutls_aead_cipher_decrypt() had a bug and used: *ptext_len = ctext_len; instead of: *ptext_len = ctext_len - tag_size; This got fixed with gnutls 3.5.2. As we only require gnutls 3.4.7 we need to cope with this... BUG: https://bugzilla.samba.org/show_bug.cgi?id=14968 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> Autobuild-User(master): Stefan Metzmacher <me...@samba.org> Autobuild-Date(master): Wed Feb 2 18:29:08 UTC 2022 on sn-devel-184 (cherry picked from commit 735f3d7dde3daf5d0af2e8a1de60422b88663992) Autobuild-User(v4-14-test): Jule Anger <jan...@samba.org> Autobuild-Date(v4-14-test): Mon Feb 14 10:34:10 UTC 2022 on sn-devel-184 commit bbd4cd045ad8ac0519180f302832663c81551427 Author: Stefan Metzmacher <me...@samba.org> Date: Mon Jan 31 20:33:43 2022 +0100 libcli/smb: fix error checking in smb2_signing_decrypt_pdu() invalid ptext_len When the ptext_size != m_total check fails, we call this: status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); goto out; As rc is 0 at that point we'll exit smb2_signing_decrypt_pdu() with NT_STATUS_OK, but without copying the decrypted data back into the callers buffer. Which leads to strange errors in the caller. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14968 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 99182af4ab5a3413311e27c2a193e09babceb01c) commit f75a05885123a05dc191b2271e161ee7c505160d Author: Stefan Metzmacher <me...@samba.org> Date: Tue Feb 1 10:52:27 2022 +0100 selftest/quick: add smb2.session We run the quicktest on each linux distro as part of samba-o3 builds. We should make sure smb2 signing/enctyption works on all of them and all different system libraries. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14968 Signed-off-by: Stefan Metzmacher <me...@samba.org> Reviewed-by: Andreas Schneider <a...@samba.org> (cherry picked from commit 68e62962b08497da8359ddbe4324443818c05cd1) ----------------------------------------------------------------------- Summary of changes: libcli/smb/smb2_signing.c | 24 +++++++++++++++++++++++- selftest/quick | 1 + wscript_configure_system_gnutls | 3 +++ 3 files changed, 27 insertions(+), 1 deletion(-) Changeset truncated at 500 lines: diff --git a/libcli/smb/smb2_signing.c b/libcli/smb/smb2_signing.c index d036fd95918..7411a3314aa 100644 --- a/libcli/smb/smb2_signing.c +++ b/libcli/smb/smb2_signing.c @@ -773,9 +773,31 @@ NTSTATUS smb2_signing_decrypt_pdu(struct smb2_signing_key *decryption_key, ctext_size, ptext, &ptext_size); - if (rc < 0 || ptext_size != m_total) { + if (rc < 0) { + TALLOC_FREE(ptext); + TALLOC_FREE(ctext); + status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); + goto out; + } +#ifdef HAVE_GNUTLS_AEAD_CIPHER_DECRYPT_PTEXT_LEN_BUG + /* + * Note that gnutls before 3.5.2 had a bug and returned + * *ptext_len = ctext_len, instead of + * *ptext_len = ctext_len - tag_size + */ + if (ptext_size != ctext_size) { + TALLOC_FREE(ptext); + TALLOC_FREE(ctext); + rc = GNUTLS_E_SHORT_MEMORY_BUFFER; + status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); + goto out; + } + ptext_size -= tag_size; +#endif /* HAVE_GNUTLS_AEAD_CIPHER_DECRYPT_PTEXT_LEN_BUG */ + if (ptext_size != m_total) { TALLOC_FREE(ptext); TALLOC_FREE(ctext); + rc = GNUTLS_E_SHORT_MEMORY_BUFFER; status = gnutls_error_to_ntstatus(rc, NT_STATUS_INTERNAL_ERROR); goto out; } diff --git a/selftest/quick b/selftest/quick index 0e79f1020bf..6700180c2c2 100644 --- a/selftest/quick +++ b/selftest/quick @@ -33,6 +33,7 @@ rpc.join rpc.handles rpc.echo smb.signing +smb2.session drs.unit samba4.blackbox.dbcheck.dc # This needs to be here to get testing of crypt_r() diff --git a/wscript_configure_system_gnutls b/wscript_configure_system_gnutls index 2ec217fb9dc..64f39b6a1de 100644 --- a/wscript_configure_system_gnutls +++ b/wscript_configure_system_gnutls @@ -35,6 +35,9 @@ conf.CHECK_FUNCS_IN('gnutls_set_default_priority_append', 'gnutls') if (parse_version(gnutls_version) > parse_version('3.6.14')): conf.CHECK_FUNCS_IN('gnutls_aead_cipher_encryptv2', 'gnutls') +if (parse_version(gnutls_version) < parse_version('3.5.2')): + conf.DEFINE('HAVE_GNUTLS_AEAD_CIPHER_DECRYPT_PTEXT_LEN_BUG', 1) + # Check if we have support for crypto policies if conf.CHECK_FUNCS_IN('gnutls_get_system_config_file', 'gnutls'): conf.DEFINE('HAVE_GNUTLS_CRYPTO_POLICIES', 1) -- Samba Shared Repository