Hello,
On 18/11/2024 19:59, Colin Watson wrote:
I just ran "sbuild -Ad unstable --chroot-mode unshare putty" and it
built fine. Perhaps pbuilder is doing something odd. sbuild is the
tool used on Debian's build daemons, so I always prefer it. Try that
and see if it behaves better?
(This was using sbuild from testing, which has some changes to simplify
setup. With older versions you'd need to follow
https://wiki.debian.org/sbuild#Setup first.)
Thanks for the quick reply and for pointing me to sbuild.
I tried to rebuild the package in Debian Unstable (following the
instructions in [1] to install and configure sbuild), but it fails with
the same errors as pbuilder.
On 18/11/2024 20:22, Jacob Nevins wrote:
This fault is in a cryptography self-test (testcrypt/cryptsuite).
The past few upstream releases of PuTTY, including 0.81, have had a
couple of bugs where if these crypto tests are run on a machine whose
processor doesn't support certain types of hardware crypto acceleration,
there can be a segfault
https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=a1d80e41ddc9fc7e280a9d7167533d33aee7cdae
and spurious test failures (the 'EEEEE' bit)
https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=5ced517428f57275c47a5b99b18fbdbba2105bb8
and spurious test failures (the 'EEEEE' bit)
[..]
(I think the SyntaxWarnings are unrelated, and probably fixed by
https://git.tartarus.org/?p=simon/putty.git;a=commitdiff;h=22f8122b13e6c856aad9c8a76ace72d1f783dc2f
which will also be in the next release.)
Thank you for your insight. This is it, I suppose. I'm currently using
an Intel(R) Core(TM)2 Duo CPU, and according to [2] the CLMUL
instruction is probably not available in it (it is available since the
Intel Westmere processor release in March 2010 and subsequent models).
This seems to be confirmed by the cpuid command [3], the CLMUL
instruction is not supported by my is not supported by my CPU:
----%<----%<----%<----%<----%<----%<----%<
$ cpuid | grep PCLMUL
PCLMULDQ instruction = false
VPCLMULQDQ instruction = false
PCLMULDQ instruction = false
VPCLMULQDQ instruction = false
---->%---->%---->%---->%---->%---->%---->%
So I installed and configured sbuild (https://wiki.debian.org/sbuild#Setup).
Then I applied the three patches quoted above (and attached to this
post) from your previous message to the putty source code using quilt [4].
Then was able to successfully rebuild a local modified version of the
putty 0.81 package using the following commands in Debian Unstable:
----%<----%<----%<----%<----%<----%<----%<
sudo apt install devscripts quilt
sudo apt install sbuild mmdebstrap uidmap piuparts
mkdir -p ~/.cache/sbuild
mmdebstrap --variant=buildd unstable ~/.cache/sbuild/unstable-amd64.tar.zst
cat << "EOF" > ~/.sbuildrc
$chroot_mode = 'unshare';
$external_commands = { "build-failed-commands" => [ [ '%SBUILD_SHELL' ] ] };
# run autopkgtest after every build: use --no-run-autopkgtest to override
$run_autopkgtest = 1;
$autopkgtest_root_args = [''];
$autopkgtest_opts = [ '--apt-upgrade', '--', 'unshare', '--release',
'%r', '--arch', '%a' ];
# run piuparts after every build: use --no-run-piuparts to override
$run_piuparts = 1;
$piuparts_root_args = ['PATH=/usr/sbin:/usr/bin:/sbin:/bin', 'unshare',
'--pid', '--fork', '--mount-proc', '--map-root-user', '--map-auto'];
$piuparts_opts = ["--basetgz=$HOME/.cache/sbuild/%r-%a.tar.zst",
'--fake-essential-packages=systemd-sysv', '--distribution=%r'];
EOF
apt source putty
cd putty-0.81/
quilt import ../fix-cryptotest-segfault.patch
quilt import ../fix-hw-accelerated-GCM-and-AES.patch
quilt import ../fix-parenthesis.patch
quilt push
quilt pop -a
dch -i "test build"
cd ..
dpkg-source -b putty-0.81/
sbuild -A -d unstable --chroot-mode unshare putty_0.81-3.1.dsc
----%<----%<----%<----%<----%<----%<----%<
On 18/11/2024 20:22, Jacob Nevins wrote:
These bugs will be fixed in the next upstream release.
When will the next version of Putty be released upstream ?
What about the bug report, since it only appears on not so new CPUs ?
Should the patches be included in the current unstable release (even if
it only affects some CPUs) or is it worth waiting for the next upstream
release?
Really many thanks to both of you, Colin and Jacob.
--
[1] https://wiki.debian.org/sbuild#Setup
[2] https://en.wikipedia.org/wiki/CLMUL_instruction_set
[3] https://packages.debian.org/cpuid
[4]
https://raphaelhertzog.com/2012/08/08/how-to-use-quilt-to-manage-patches-in-debian-packages/
From a1d80e41ddc9fc7e280a9d7167533d33aee7cdae Mon Sep 17 00:00:00 2001
From: Jacob Nevins <jac...@chiark.greenend.org.uk>
Date: Tue, 22 Aug 2023 17:59:19 +0100
Subject: [PATCH] testcrypt: allow null return from ssh2_mac_new.
This can now happen if, for instance, the CLMUL implementation of
aesgcm is compiled in, but not available at runtime because we're on
an old Intel CPU.
In this situation, testcrypt would segfault when driven by
test/cryptsuite.py, and test/list-accel.py would erroneously claim the
CLMUL implementation was available when it wasn't.
---
test/testcrypt-func.h | 2 +-
test/testcrypt.c | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/test/testcrypt-func.h b/test/testcrypt-func.h
index bd007293..7b955b92 100644
--- a/test/testcrypt-func.h
+++ b/test/testcrypt-func.h
@@ -269,7 +269,7 @@ FUNC(opt_val_hash, blake2b_new_general, ARG(uint, hashlen))
* to ssh2_mac_new. Also, again, I've invented an ssh2_mac_update so
* you can put data into the MAC.
*/
-FUNC(val_mac, ssh2_mac_new, ARG(macalg, alg), ARG(opt_val_cipher, cipher))
+FUNC(opt_val_mac, ssh2_mac_new, ARG(macalg, alg), ARG(opt_val_cipher, cipher))
FUNC(void, ssh2_mac_setkey, ARG(val_mac, m), ARG(val_string_ptrlen, key))
FUNC(void, ssh2_mac_start, ARG(val_mac, m))
FUNC(void, ssh2_mac_update, ARG(val_mac, m), ARG(val_string_ptrlen, data))
diff --git a/test/testcrypt.c b/test/testcrypt.c
index 54941cb2..3b495bba 100644
--- a/test/testcrypt.c
+++ b/test/testcrypt.c
@@ -584,6 +584,7 @@ NULLABLE_RETURN_WRAPPER(val_string, strbuf *)
NULLABLE_RETURN_WRAPPER(val_string_asciz, char *)
NULLABLE_RETURN_WRAPPER(val_string_asciz_const, const char *)
NULLABLE_RETURN_WRAPPER(val_cipher, ssh_cipher *)
+NULLABLE_RETURN_WRAPPER(val_mac, ssh2_mac *)
NULLABLE_RETURN_WRAPPER(val_hash, ssh_hash *)
NULLABLE_RETURN_WRAPPER(val_key, ssh_key *)
NULLABLE_RETURN_WRAPPER(val_mpint, mp_int *)
--
2.20.1
From 5ced517428f57275c47a5b99b18fbdbba2105bb8 Mon Sep 17 00:00:00 2001
From: Jacob Nevins <jac...@chiark.greenend.org.uk>
Date: Tue, 22 Aug 2023 19:05:21 +0100
Subject: [PATCH] cryptsuite: gracefully handle unavailable HW accel.
Hardware-accelerated GCM and AES implementations which were compiled in,
but unavailable at runtime, would cause GCM tests to give errors.
---
test/cryptsuite.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/cryptsuite.py b/test/cryptsuite.py
index 9d2c215c..99b23d25 100755
--- a/test/cryptsuite.py
+++ b/test/cryptsuite.py
@@ -2946,8 +2946,9 @@ Private-MAC: 5b1f6f4cc43eb0060d2c3e181bc0129343adba2b
def aesgcm(key, iv, aes_impl, gcm_impl):
c = ssh_cipher_new('aes{:d}_gcm_{}'.format(8*len(key), aes_impl))
+ if c is None: return None, None # skip test if HW AES not available
m = ssh2_mac_new('aesgcm_{}'.format(gcm_impl), c)
- if m is None: return # skip test if HW GCM not available
+ if m is None: return None, None # skip test if HW GCM not available
c.setkey(key)
c.setiv(iv + b'\0'*4)
m.setkey(b'')
@@ -3001,6 +3002,7 @@ Private-MAC: 5b1f6f4cc43eb0060d2c3e181bc0129343adba2b
'5b60142bfcf4e5b0a9ada3451799866e')
c, m = aesgcm(key, iv, aes_impl, gcm_impl)
+ if c is None or m is None: return # skip if HW impl unavailable
len_dec = c.decrypt_length(aad, 123)
self.assertEqual(len_dec, aad) # length not actually encrypted
m.start()
@@ -3098,9 +3100,11 @@ Private-MAC: 5b1f6f4cc43eb0060d2c3e181bc0129343adba2b
for impl in get_aes_impls():
with self.subTest(aes_impl=impl):
gcm = ssh_cipher_new('aes{:d}_gcm_{}'.format(8*len(key), impl))
+ if gcm is None: continue # skip if HW AES unavailable
gcm.setkey(key)
cbc = ssh_cipher_new('aes{:d}_cbc_{}'.format(8*len(key), impl))
+ # assume if gcm_<impl> is available, cbc_<impl> will be too
cbc.setkey(key)
# A simple test to ensure the low word gets
--
2.20.1
From 22f8122b13e6c856aad9c8a76ace72d1f783dc2f Mon Sep 17 00:00:00 2001
From: Colin Watson <cjwat...@debian.org>
Date: Thu, 1 Aug 2024 15:18:57 +0100
Subject: [PATCH] Suppress syntax warnings on Python 3.12.
Python 3.12 has a new warning for backslash-character pairs that are not
valid escape sequences at the level of string literals, as opposed to in
some interior syntax such as regular expressions
(https://docs.python.org/3/whatsnew/3.12.html#other-language-changes).
Suppress it by using raw strings.
---
contrib/kh2reg.py | 4 ++--
test/testcrypt.py | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/kh2reg.py b/contrib/kh2reg.py
index cff06c8f..81e79a43 100755
--- a/contrib/kh2reg.py
+++ b/contrib/kh2reg.py
@@ -27,7 +27,7 @@ def winmungestr(s):
candot = 0
r = ""
for c in s:
- if c in ' \*?%~' or ord(c)<ord(' ') or (c == '.' and not candot):
+ if c in r' \*?%~' or ord(c)<ord(' ') or (c == '.' and not candot):
r = r + ("%%%02X" % ord(c))
else:
r = r + c
@@ -385,7 +385,7 @@ class OutputFormatter(object):
class WindowsOutputFormatter(OutputFormatter):
def header(self):
# Output REG file header.
- self.fh.write("""REGEDIT4
+ self.fh.write(r"""REGEDIT4
[HKEY_CURRENT_USER\Software\SimonTatham\PuTTY\SshHostKeys]
""")
diff --git a/test/testcrypt.py b/test/testcrypt.py
index 66f63d5c..217dbf35 100644
--- a/test/testcrypt.py
+++ b/test/testcrypt.py
@@ -308,8 +308,8 @@ def _lex_testcrypt_header(header):
# And then match a token
'({})'.format('|'.join((
# Punctuation
- '\(',
- '\)',
+ r'\(',
+ r'\)',
',',
# Identifier
'[A-Za-z_][A-Za-z0-9_]*',
--
2.20.1