Re: LUKS multiple passphrase retries

2023-04-09 Thread Maxim Fomin
--- Original Message ---
On Saturday, April 8th, 2023 at 2:59 AM, Simon Perry via Grub-devel 
 wrote:
> 
> Hi there,
> 
> I've recently moved to using a LUKS2 encrypted boot and it's working
> great, however one of the frustrating things is that you get dropped to
> grub rescue after a single failed passphrase attempt.
> 
> I see there was a patch proposed back in 2019, but it didn't seem to
> progress any further (and the guy's git repo has since disappeared).
> 
> https://lists.gnu.org/archive/html/grub-devel/2019-08/msg00015.html
> 
> Anyway, I was wondering if any future consideration would be given to
> adding a feature allowing multiple retries when entering a passphrase?
> 
> Appreciate your time.
> 
> Cheers.
> 
> --
> Simon Perry (aka Pezz)
> 
> ___
> Grub-devel mailing list
> Grub-devel@gnu.org
> https://lists.gnu.org/mailman/listinfo/grub-devel

AFAIK this patch[1] allows to have several passphrase attempts. It was 
originally proposed by John Lane as a part of crypto enhancement patch set[2].
Several versions of this patch set were sent to grub-devel mailing list in 
2015-2018, but nothing was directly included into git. The patch was written
for LUKS1 version because support for LUKS2 in grub was included later. 
However, it seems it would be trivial to add support for LUKS2.

[1] https://lists.gnu.org/archive/html/grub-devel/2015-06/msg00113.html

[2] https://grub.johnlane.ie/

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: LUKS multiple passphrase retries

2023-04-09 Thread Simon Perry via Grub-devel

On 2023-04-09 06:17 PM, Maxim Fomin wrote:

AFAIK this patch[1] allows to have several passphrase attempts. It was 
originally proposed by John Lane as a part of crypto enhancement patch 
set[2].
Several versions of this patch set were sent to grub-devel mailing list 
in 2015-2018, but nothing was directly included into git. The patch was 
written
for LUKS1 version because support for LUKS2 in grub was included later. 
However, it seems it would be trivial to add support for LUKS2.


I've actually completely solved this through scripting thanks to what 
I've learned from Maximilian Stendler's Github repo (who replied 
earlier).


There's a weird trick to it though, where you make a tar file with a 
simple cfg in it that sources another config and then you have things 
like functions, loops and if tests available.


Working great now, thanks to him.

Cheers.

---
Simon Perry (aka Pezz)

___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


[PATCH] tests/util/grub-fs-tester: Add missing redirect to /dev/null

2023-04-09 Thread Glenn Washburn
In filesystem timestamp test, a check is done to verify that the timestamp
for a file as reported in Linux by the filesystem is within a few seconds
of the timestamp as reported by GRUB. This is done by grepping the output
of GRUB's ls command for the timestamp as reported by the filesystem in
Linux and for each of 3 seconds past that timestamp. All of these checks
except one redirect the output of grep to /dev/null. Fix this exception
to behave as the other checks.

Signed-off-by: Glenn Washburn 
---
 tests/util/grub-fs-tester.in | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 064464eb2..9cc6b5811 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -1465,7 +1465,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
"$MAXLOGSECSIZE" 1); do
FSTIMEM2="$(date -d "$FSTIME UTC -2 second" -u "+%Y-%m-%d 
%H:%M:%S")"
FSTIMEM3="$(date -d "$FSTIME UTC -3 second" -u "+%Y-%m-%d 
%H:%M:%S")"
 
-   if echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > 
/dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > 
/dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" || 
echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > /dev/null; then
+   if echo "$LSOUT" | grep -F 'Last modification time '"$FSTIME" > 
/dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM1" > 
/dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM2" > 
/dev/null || echo "$LSOUT" | grep -F 'Last modification time '"$FSTIMEM3" > 
/dev/null; then
:
else
echo FSTIME FAIL
-- 
2.34.1


___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v14 09/10] tests: Fix timezone inconsistency in squashfs_test

2023-04-09 Thread Glenn Washburn
This patch is not related to this series, so IMHO I think it would be 
better to send it as a separate patch.


On 4/8/23 02:04, Xiaotian Wu wrote:

The image timestamp was not returned in UTC, but the following logic
expected and used UTC.


This looks good to me. I introduced this bug in b314807a0e (tests: When 
checking squashfs fstime, use superblock last modified time) and never 
hit it because all my test systems are in the UTC timezone, so 
"unsquashfs -s" was already outputting in UTC.


Reviewed-by: Glenn Washburn 

Glenn


This patch fixes the test failure like described below:

   unsquashfs -s 
/tmp/grub-fs-tester.20230407111703613257436.squash4_gzip.9R4/squash4_gzip_512_4096_1_0.img
   grep '^Creation'
   awk '{print $6 " " $7 " " $8 " " $9 " " $10; }'
   FSTIME='Fri Apr 7 11:17:05 2023'
   date -d 'Fri Apr 7 11:17:05 2023' -u '+%Y-%m-%d %H:%M:%S'
   FSTIME='2023-04-07 11:17:05'
   date -d '2023-04-07 11:17:05 UTC -1 second' -u '+%Y-%m-%d %H:%M:%S'
   FSTIMEM1='2023-04-07 11:17:04'
   date -d '2023-04-07 11:17:05 UTC -2 second' -u '+%Y-%m-%d %H:%M:%S'
   FSTIMEM2='2023-04-07 11:17:03'
   date -d '2023-04-07 11:17:05 UTC -3 second' -u '+%Y-%m-%d %H:%M:%S'
   FSTIMEM3='2023-04-07 11:17:02'
   grep -F 'Last modification time 2023-04-07 11:17:05'
   echo 'Device loop0: Filesystem type squash4 - Last modification time 
2023-04-07 03:17:05 Friday - Sector size 512B - Total size 10680KiB'
   echo 'Device loop0: Filesystem type squash4 - Last modification time 
2023-04-07 03:17:05 Friday - Sector size 512B - Total size 10680KiB'
   grep -F 'Last modification time 2023-04-07 11:17:04'
   echo 'Device loop0: Filesystem type squash4 - Last modification time 
2023-04-07 03:17:05 Friday - Sector size 512B - Total size 10680KiB'
   grep -F 'Last modification time 2023-04-07 11:17:03'
   echo 'Device loop0: Filesystem type squash4 - Last modification time 
2023-04-07 03:17:05 Friday - Sector size 512B - Total size 10680KiB'
   grep -F 'Last modification time 2023-04-07 11:17:02'
   echo FSTIME FAIL






Signed-off-by: Xiaotian Wu 
---
  tests/util/grub-fs-tester.in | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tests/util/grub-fs-tester.in b/tests/util/grub-fs-tester.in
index 064464eb2..64638d2e9 100644
--- a/tests/util/grub-fs-tester.in
+++ b/tests/util/grub-fs-tester.in
@@ -1454,7 +1454,7 @@ for LOGSECSIZE in $(range "$MINLOGSECSIZE" 
"$MAXLOGSECSIZE" 1); do
# Creating the squash image may take more than a few
# seconds. Use the more accurate timestamp from the
# superblock.
-   FSTIME="$(unsquashfs -s "${FSIMAGEP}0.img" | grep ^Creation | awk '{print $6 " " $7 " 
" $8 " " $9 " " $10; }')"
+   FSTIME="$(unsquashfs -UTC -s "${FSIMAGEP}0.img" | grep ^Creation | awk '{print $6 " " $7 
" " $8 " " $9 " " $10; }')"
FSTIME="$(date -d "$FSTIME" -u '+%Y-%m-%d %H:%M:%S')";;
*)
FSTIME="$(TZ=UTC ls --time-style="+%Y-%m-%d_%H:%M:%S" -l -d 
"${FSIMAGEP}0.img"|awk '{print $6; }'|sed 's,_, ,g')";;



___
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel


Re: [PATCH v14 10/10] tests: Add LoongArch to various test cases

2023-04-09 Thread Glenn Washburn

On 4/8/23 02:05, Xiaotian Wu wrote:

The test results of running "make check" with qemu 7.2 are as follows:
   
   Testsuite summary for GRUB 2.11
   
   # TOTAL: 85
   # PASS:  57
   # SKIP:  8
   # XFAIL: 0
   # FAIL:  1
   # XPASS: 0
   # ERROR: 19
   

These ERROR cases need to be run as root user:
   ERROR: ext234_test
   ERROR: hfsplus_test
   ERROR: ntfs_test
   ERROR: reiserfs_test
   ERROR: fat_test
   ERROR: minixfs_test
   ERROR: xfs_test
   ERROR: f2fs_test
   ERROR: nilfs2_test
   ERROR: romfs_test
   ERROR: exfat_test
   ERROR: udf_test
   ERROR: hfs_test
   ERROR: jfs_test
   ERROR: btrfs_test
   ERROR: zfs_test
   ERROR: luks1_test
   ERROR: luks2_test
   ERROR: grub_cmd_cryptomount


It would be great if you would follow the instructions in the INSTALL 
file to install the appropriate dependencies and to run the tests as 
root. Are you suggesting that you do not have access to the root user?




These test cases are skipped:
   SKIP: pata_test
   SKIP: ahci_test
   SKIP: uhci_test
   SKIP: ohci_test
   SKIP: ehci_test
   SKIP: fddboot_test
   SKIP: netboot_test
   SKIP: pseries_test

This test case fails because of: qemu-system-loongarch64: ram_size must be 
greater than 1G.
   FAIL: grub_func_test


This sounds strange to me because you give QEMU 4G of memory in 
grub-shell (see below). Are you saying that you ran the tests on a 
system with 1G or less of memory?




Signed-off-by: Xiaotian Wu 
---
  tests/ahci_test.in   |  2 +-
  tests/ehci_test.in   |  2 +-
  tests/ohci_test.in   |  2 +-
  tests/pata_test.in   |  2 +-
  tests/uhci_test.in   |  2 +-
  tests/util/grub-shell.in | 14 ++
  6 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/tests/ahci_test.in b/tests/ahci_test.in
index 6d2e61d4e..70646a24e 100644
--- a/tests/ahci_test.in
+++ b/tests/ahci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  mips*-arc | mips*-qemu_mips)
exit 77;;
  # FIXME: No native drivers are available for those
-powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
+powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
  esac
  
diff --git a/tests/ehci_test.in b/tests/ehci_test.in

index df671b4b6..bf823a5de 100644
--- a/tests/ehci_test.in
+++ b/tests/ehci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  mips*-arc | mips*-qemu_mips)
exit 77;;
  # FIXME: No native drivers are available for those
-powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
+powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
  esac
  
diff --git a/tests/ohci_test.in b/tests/ohci_test.in

index 741ad881f..a40d3bc0a 100644
--- a/tests/ohci_test.in
+++ b/tests/ohci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  mips*-arc | mips*-qemu_mips)
exit 77;;
  # FIXME: No native drivers are available for those
-powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
+powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
  esac
  
diff --git a/tests/pata_test.in b/tests/pata_test.in

index 31144a8fd..4d0e7d573 100644
--- a/tests/pata_test.in
+++ b/tests/pata_test.in
@@ -33,7 +33,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  i386-efi)
exit 77;;
  # FIXME: No native drivers are available for those
-powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
+powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
  i386-ieee1275)
disk=hdb
diff --git a/tests/uhci_test.in b/tests/uhci_test.in
index 5aa5eb726..de199a281 100644
--- a/tests/uhci_test.in
+++ b/tests/uhci_test.in
@@ -30,7 +30,7 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" in
  mips*-arc | mips*-qemu_mips)
exit 77;;
  # FIXME: No native drivers are available for those
-powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi)
+powerpc-ieee1275 | sparc64-ieee1275 | arm*-efi | loongarch64-efi)
exit 77;;
  esac
  
diff --git a/tests/util/grub-shell.in b/tests/util/grub-shell.in

index 75f71dc1a..bbeb63ef4 100644
--- a/tests/util/grub-shell.in
+++ b/tests/util/grub-shell.in
@@ -208,6 +208,16 @@ case "${grub_modinfo_target_cpu}-${grub_modinfo_platform}" 
in
disk="device virtio-blk-device,drive=hd1 -drive if=none,id=hd1,file="
serial_port=efi0
;;
+loongarch64-efi)
+   qemu=qemu-system-loongarch64
+   boot=hd
+   console=console
+   trim=1
+   qemuopts="-machine virt -cpu la464-loongarch-cpu -smp 4 -nographic -m 
4G \
+ -bios /usr/share/edk2/loongarch64/QEMU_CODE.fd $qemuopts"


The tests ar