Grub HTTP Driver implementation example

2024-05-24 Thread xlordz dev
Can someone share a snipped code using the Grub HTTP Driver implementation (not efi) to get IP from DHCP (or using fixed IP/Gateway) and do a HTTP Connection to read data from server during boot time ? I'm been trying a while, looking for examples and AI is writing wrong examples. Thanks in

Re: [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol

2024-05-24 Thread Mate Kukri
Hi Vladimir, Thanks for the reviews, I'll get back to addressing your comments next week. In the meantime, I am not sure what happened to patch 15/15, but I at least tried sending it, and it seems to be available in the archive here:

Re: [PATCH 13/15] efi: Provide wrappers for load_image, start_image, unload_image

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
WDYT of moving this logic to chainloader? Yes, it will make linux depend on chainloader but I think given its current logic it's a honest dependency On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Julian Andres Klode > > These can be used to register a different implementation

Re: [PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
> Future work: > - Completely disable non-NX compatible loaders when heap allocation are > marked NX. > This should be independent from the NX-enforcement flag and Secure Boot > status. > (Note that this is non-crtitical for security, as non-UEFI/Linux loaders > are disabled >by SB

Re: [PATCH 10/15] grub_dl_set_mem_attrs(): add self-check for the tramp/GOT sizes

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Do you mean that this crash is introduced and not fixed in this patch series? Can't we fix it by bumping total allocation size to multiple of page size? On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Laszlo Ersek > > On aarch64 UEFI, we currently have a crasher: > >

Re: [PATCH 09/15] grub_dl_load_segments(): page-align the tramp/GOT areas too

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
> - tsize += ALIGN_UP (tramp, GRUB_ARCH_DL_TRAMP_ALIGN); > - if (talign < GRUB_ARCH_DL_TRAMP_ALIGN) > -talign = GRUB_ARCH_DL_TRAMP_ALIGN; > - tsize += ALIGN_UP (got, GRUB_ARCH_DL_GOT_ALIGN); > - if (talign < GRUB_ARCH_DL_GOT_ALIGN) > -talign = GRUB_ARCH_DL_GOT_ALIGN; > + tramp_align =

Re: [PATCH 08/15] nx: set the nx compatible flag in EFI grub images

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Reviewed By: Vladimir Serbinenko On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Peter Jones > > For NX, we need the grub binary to announce that it is compatible with > the NX feature. This implies that when loading the executable grub > image, several attributes are true: > > -

Re: [PATCH 07/15] nx: set page permissions for loaded modules.

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Can you not add needless dprintf's ? This part is size-constrained on i386-pc and part of the patch just adds dprintf's unrelated to the topic at hand. Can we skip all this on non-efi and have it ifdef-ed out for the sake of size? On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Peter

Re: [PATCH 06/15] nx: add memory attribute get/set API

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
> + if (!proto) > +return GRUB_ERR_NOT_IMPLEMENTED_YET; > + Here and in other places you return an error without using grub_error. Also NOT_IMPLEMENTED_YET means that *GRUB* doesn't implement it yet, not firmware. Also given that you ignore the return here anyway a single bool or even void

Re: [PATCH 05/15] modules: load module sections at page-aligned addresses

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
What happens when 2 sections with the same NX and WR attributes follow each other? Do we need to split them per page? How often do we needlessly split in the current codebase? > to dump into the ELF section header, which is often pretty useless. I think this is not true. It's not useless, just

Re: [PATCH 04/15] pe: add the DOS header struct and fix some bad naming.

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
> struct grub_msdos_image_header > { >/* This is always 'MZ'. (GRUB_PE32_MAGIC) */ Please adjust this > @@ -171,6 +194,8 @@ struct grub_pe32_optional_header >struct grub_pe32_data_directory reserved_entry; > }; > > +#define GRUB_PE32_NX_COMPAT 0x0100 > + This was not mentioned in the

Re: [PATCH 03/15] modules: Don't allocate space for non-allocable sections.

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Reviewed-By: Vladimir Serbinenko On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Peter Jones > > Currently when loading grub modules, we allocate space for all sections, > including those without SHF_ALLOC set. We then copy the sections that > /do/ have SHF_ALLOC set into the

Re: [PATCH 02/15] modules: strip .llvm_addrsig sections and similar.

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Reviewed-By: Vladimir Serbinenko On Fri, May 24, 2024 at 2:06 PM Mate Kukri wrote: > > From: Peter Jones > > Currently grub modules built with clang or gcc have several sections > which we don't actually need or support. > > We already have a list of section to skip in genmod.sh, and this patch

Re: [PATCH 01/15] modules: make .module_license read-only

2024-05-24 Thread Vladimir 'phcoder' Serbinenko
Reviewed-By: Vladimir Serbinenko On Fri, May 24, 2024 at 2:05 PM Mate Kukri wrote: > > From: Peter Jones > > Currently .module_license is set writable (that is, the section has the > SHF_WRITE flag set) in the module's ELF headers. This probably never > actually matters, but it can't possibly

[PATCH v3 2/5] Import b64dec from gpg-error

2024-05-24 Thread Vladimir Serbinenko
--- grub-core/lib/b64dec.c | 293 + 1 file changed, 293 insertions(+) create mode 100644 grub-core/lib/b64dec.c diff --git a/grub-core/lib/b64dec.c b/grub-core/lib/b64dec.c new file mode 100644 index 0..8aafa9700 --- /dev/null +++

[PATCH v3 3/5] Adjust import script, definitions and API users for libgcrypt 1.10

2024-05-24 Thread Vladimir Serbinenko
--- autogen.sh | 5 + conf/Makefile.common | 4 +- grub-core/Makefile.core.def| 36 ++- grub-core/commands/hashsum.c | 2 +- grub-core/commands/legacycfg.c | 6 +- grub-core/commands/pgp.c

[PATCH v3 5/5] keccak: Disable acceleration with SSE asm

2024-05-24 Thread Vladimir Serbinenko
--- .../lib/libgcrypt-patches/02_keccak_sse.diff | 19 +++ 1 file changed, 19 insertions(+) create mode 100644 grub-core/lib/libgcrypt-patches/02_keccak_sse.diff diff --git a/grub-core/lib/libgcrypt-patches/02_keccak_sse.diff

[PATCH v3 4/5] Add DSA and RSA SEXP tests

2024-05-24 Thread Vladimir Serbinenko
--- grub-core/tests/dsa_sexp_test.c | 107 grub-core/tests/rsa_sexp_test.c | 81 2 files changed, 188 insertions(+) create mode 100644 grub-core/tests/dsa_sexp_test.c create mode 100644 grub-core/tests/rsa_sexp_test.c diff --git

[PATCH 15/15] efi: Disallow fallback to legacy Linux loader when shim says NX is required.

2024-05-24 Thread Mate Kukri
Signed-off-by: Mate Kukri --- grub-core/loader/efi/linux.c | 41 +++- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/grub-core/loader/efi/linux.c b/grub-core/loader/efi/linux.c index 99365536a..e44692c92 100644 --- a/grub-core/loader/efi/linux.c

[PATCH 07/15] nx: set page permissions for loaded modules.

2024-05-24 Thread Mate Kukri
From: Peter Jones For NX, we need to set write and executable permissions on the sections of grub modules when we load them. On sections with SHF_ALLOC set, which is typically everything except .modname and the symbol and string tables, this patch clears the Read Only flag on sections that have

[PATCH 03/15] modules: Don't allocate space for non-allocable sections.

2024-05-24 Thread Mate Kukri
From: Peter Jones Currently when loading grub modules, we allocate space for all sections, including those without SHF_ALLOC set. We then copy the sections that /do/ have SHF_ALLOC set into the allocated memory, leaving some of our allocation untouched forever. Additionally, on platforms with

[PATCH 02/15] modules: strip .llvm_addrsig sections and similar.

2024-05-24 Thread Mate Kukri
From: Peter Jones Currently grub modules built with clang or gcc have several sections which we don't actually need or support. We already have a list of section to skip in genmod.sh, and this patch adds the following sections to that list (as well as a few newlines): .note.gnu.property .llvm*

[PATCH 08/15] nx: set the nx compatible flag in EFI grub images

2024-05-24 Thread Mate Kukri
From: Peter Jones For NX, we need the grub binary to announce that it is compatible with the NX feature. This implies that when loading the executable grub image, several attributes are true: - the binary doesn't need an executable stack - the binary doesn't need sections to be both executable

[PATCH 12/15] mm: Fixup bogus assumptions about types sizes in format strings

2024-05-24 Thread Mate Kukri
Signed-off-by: Mate Kukri --- grub-core/kern/efi/mm.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/grub-core/kern/efi/mm.c b/grub-core/kern/efi/mm.c index 46f2266e1..1064036f4 100644 --- a/grub-core/kern/efi/mm.c +++ b/grub-core/kern/efi/mm.c @@ -741,7 +741,7 @@

[PATCH 06/15] nx: add memory attribute get/set API

2024-05-24 Thread Mate Kukri
From: Peter Jones For NX, we need to set the page access permission attributes for write and execute permissions. This patch adds two new primitives, grub_set_mem_attrs() and grub_clear_mem_attrs(), and associated constant definitions, to be used for that purpose. For most platforms, it adds a

[PATCH 10/15] grub_dl_set_mem_attrs(): add self-check for the tramp/GOT sizes

2024-05-24 Thread Mate Kukri
From: Laszlo Ersek On aarch64 UEFI, we currently have a crasher: grub_dl_load_core() grub_dl_load_core_noinit() /* independent allocation: must remain writable */ mod = grub_zalloc(); /* allocates module image with incorrect tail alignment */

[PATCH 14/15] efi: Use shim's loader protocol for EFI image verification and loading

2024-05-24 Thread Mate Kukri
Signed-off-by: Mate Kukri --- grub-core/kern/efi/sb.c | 39 +--- grub-core/loader/efi/linux.c | 16 --- include/grub/efi/api.h | 5 + include/grub/efi/efi.h | 19 +++--- include/grub/efi/sb.h| 3 --- 5 files

[PATCH 04/15] pe: add the DOS header struct and fix some bad naming.

2024-05-24 Thread Mate Kukri
From: Peter Jones In order to properly validate a loaded kernel's support for being loaded without a writable stack or executable, we need to be able to properly parse arbitrary PE headers. Currently, pe32.h is written in such a way that the MS-DOS header that tells us where to find the PE

[PATCH 11/15] grub_dl_set_mem_attrs(): fix format string

2024-05-24 Thread Mate Kukri
From: Laszlo Ersek The grub_dprintf() call for printing the message updating attributes for GOT and trampolines passes the argument "mod->name", but the format string doesn't accept that argument. Print the module name too. Example output: > kern/dl.c:736: updating attributes for GOT and

[PATCH 13/15] efi: Provide wrappers for load_image, start_image, unload_image

2024-05-24 Thread Mate Kukri
From: Julian Andres Klode These can be used to register a different implementation later, for example, when shim provides a protocol with those functions. Signed-off-by: Mate Kukri --- grub-core/kern/efi/efi.c | 57 ++ grub-core/loader/efi/chainloader.c |

[PATCH 01/15] modules: make .module_license read-only

2024-05-24 Thread Mate Kukri
From: Peter Jones Currently .module_license is set writable (that is, the section has the SHF_WRITE flag set) in the module's ELF headers. This probably never actually matters, but it can't possibly be correct. This patch sets that data as "const", which causes that flag not to be set.

[PATCH 09/15] grub_dl_load_segments(): page-align the tramp/GOT areas too

2024-05-24 Thread Mate Kukri
From: Laszlo Ersek The tramp/GOT write-protection in grub_dl_set_mem_attrs() requires that the tramp/GOT areas of the module image *not* share a page with any other memory allocations. Page-align the tramp/GOT areas, while satisfying their intrinsic alignment requirements too. Fixes:

[PATCH 00/15] UEFI NX support and NX Linux loader using shim loader protocol

2024-05-24 Thread Mate Kukri
Current state of the patchset: - Cherry-picked Fedora NX patches to make GRUB itself work under NX. This required some fixups to build on non-64 bit arches (operation on 32-bit is currently untested) - Cherry-picked Julian Andres Klode's loader framework patch (used in Debian and Ubuntu for

[PATCH 05/15] modules: load module sections at page-aligned addresses

2024-05-24 Thread Mate Kukri
From: Peter Jones Currently we load module sections at whatever alignment gcc+ld happened to dump into the ELF section header, which is often pretty useless. For example, by default time.mod has these sections on a current x86_64 build: $ eu-readelf -a grub-core/time.mod |& grep ^Section -A13