Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RFC: provide KASLR support to u-boot v2024.07 general availability #7078

Merged
merged 12 commits into from
Aug 15, 2024

Conversation

alexl83
Copy link
Contributor

@alexl83 alexl83 commented Aug 13, 2024

Description

KASRL-supporting u-boot 2024.07 for everyone:

  • move /chosen/kaslr-seed DTC node support patchset to general 2024.07 BOOTPATCHDIR
  • attach nanopi-r5c and orangepi5-plus BOOTPACHDIR to patches/uboot/v2024.07

Hopefully, other boards using same uboot-version can benefit from the added support

note for Maintainers - to enable KASLR seed, you need:
- CONFIG_RANDOMIZE_BASE=y configured in your kernel .config
- CONFIG_CMD_KASLRSEED=y and CONFIG_DM_RNG=y configured in your u-boot .config
- exposed crypto and rng nodes in you board's device-tree
- kaslrseed command before kernel boot in your boot.cmd
- CONFIG_SECURITY_DMESG_RESTRICT=y in kernel .config is also advisable (integrated by #7079 and #7080 for orangepi5-plus/nanopi-r5c)

note for Maintainers 2 - please place your u-boot patches [defconfig and device-trees (when needed) come to mind] in patch/u-boot/v2024.07/board_${BOARD}

How Has This Been Tested?

  • Built and ran BRANCH=edge RELEASE=trixie BOARDS=(nanopi-r5c orangepi5-plus)
  • Built and ran BRANCH=current RELEASE=trixie BOARD=nanopi-r5c

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings

- move /chosen/kaslr-seed support patchset to general 2024.07 BOOTPATCHDIR
- attach nanopi-r5c and oprangepi5-plus BOOTPACHDIR to patches/uboot/v2024.07 general dir

Hopefully, other boards using same uboot-version can benefit from the added support

note for Maintainers -  to enable KASLR seed, you need:
	- CONFIG_RANDOMIZE_BASE=y configured in your kernel .config
	- CONFIG_CMD_KASLRSEED=y and CONFIG_DM_RNG=y configure in your u-boot .config
	- exposed crypto and rng nodes in you board's device-tree
	- kasrlseed command before kernel boot in your boot.cmd
	- CONFIG_SECURITY_DMESG_RESTRICT=y in kernel .config is also advisable
@github-actions github-actions bot added size/large PR with 250 lines or more Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... labels Aug 13, 2024
@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

Given we're approaching 08 milestone, perhaps milestone 11 tag could be wise
@ColorfulRhino @igorpecovnik - any thoughts?

Thank you :)
Ale

@igorpecovnik igorpecovnik added 11 Milestone: Fourth quarter release Needs review Seeking for review labels Aug 13, 2024
@alexl83 alexl83 marked this pull request as draft August 13, 2024 10:16
@alexl83 alexl83 marked this pull request as ready for review August 13, 2024 10:31
@alexl83 alexl83 force-pushed the kaslr_v2024.07_for_everyone branch from 0c0666d to 21965c1 Compare August 13, 2024 10:37
Copy link
Collaborator

@ColorfulRhino ColorfulRhino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!
Using the patch for the defconfigs is probably better since you can quickly glance over what's changed from the default defconfig file. You can use the board_nanopi-r5c folder without needing to use BOOTPATCHDIR="v2024.07/board_${BOARD}", this folder will get included automatically, but only for the board it is for. For this reason, I'd keep the two ***_kaslrseed.patch (but maybe rename it to e.g. nanopi-r5c-Add-kaslrseed-support-defconfig-patch, it's always better to be able to quickly see thigns based on naming while glancing over it 😄).

Also, not sure if the two placeholder files for the dt directory are neccessary.

@alexl83 alexl83 force-pushed the kaslr_v2024.07_for_everyone branch from 21965c1 to 1751551 Compare August 13, 2024 15:38
@alexl83 alexl83 force-pushed the kaslr_v2024.07_for_everyone branch from 71bd617 to ae21336 Compare August 13, 2024 15:44
@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

Nice! Using the patch for the defconfigs is probably better since you can quickly glance over what's changed from the default defconfig file. You can use the board_nanopi-r5c folder without needing to use BOOTPATCHDIR="v2024.07/board_${BOARD}", this folder will get included automatically, but only for the board it is for. For this reason, I'd keep the two ***_kaslrseed.patch (but maybe rename it to e.g. nanopi-r5c-Add-kaslrseed-support-defconfig-patch, it's always better to be able to quickly see thigns based on naming while glancing over it 😄).

Also, not sure if the two placeholder files for the dt directory are neccessary.

Done ;-) Thanks!

@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Aug 13, 2024

Great, thanks! Did you try to do a rewrite-uboot-patches?
It will probably complain that the patches do not have a proper description, author and so on. In the future, try to keep the commit descriptions and such in the patch :) Like in this patch for example: https://github.com/armbian/build/blob/main/patch/u-boot/v2024.07/general-btrfs-fix-out-of-bounds-write.patch (this patch was also not yet rewritten though, so not the best example)

@alexl83 alexl83 force-pushed the kaslr_v2024.07_for_everyone branch from 1c28ae6 to ed2ad82 Compare August 13, 2024 16:48
@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

Great, thanks! Did you try to do a rewrite-uboot-patches? It will probably complain that the patches do not have a proper description, author and so on. In the future, try to keep the commit descriptions and such in the patch :) Like in this patch for example: https://github.com/armbian/build/blob/main/patch/u-boot/v2024.07/general-btrfs-fix-out-of-bounds-write.patch (this patch was also not yet rewritten though, so not the best example)

Didn't even know there was a rewrite-uboot-patches process - thanks for the hint!
rewrote patches to provide a simple description

@ColorfulRhino
Copy link
Collaborator

ColorfulRhino commented Aug 13, 2024

Didn't even know there was a rewrite-uboot-patches process - thanks for the hint! rewrote patches to provide a simple description

Oh, it's basically doing the same like rewrite-kernel-patches :) Great!

I was more referring to the four patches that you (I think?) took from somewhere like 1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch https://github.com/armbian/build/blob/ed2ad82bc31b98f4e279668ecf23074c2b1bb51d/patch/u-boot/v2024.07/1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch to keep the description from the original commit and author which added this.
You can keep this in midn for the future though :)

ColorfulRhino
ColorfulRhino previously approved these changes Aug 13, 2024
Copy link
Collaborator

@ColorfulRhino ColorfulRhino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good besides the nit mentioned above 👍

@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

Didn't even know there was a rewrite-uboot-patches process - thanks for the hint! rewrote patches to provide a simple description

Oh, it's basically doing the same like rewrite-kernel-patches :) Great!

I was more referring to the four patches that you (I think?) took from somewhere like 1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch https://github.com/armbian/build/blob/ed2ad82bc31b98f4e279668ecf23074c2b1bb51d/patch/u-boot/v2024.07/1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch to keep the description from the original commit and author which added this. You can keep this in midn for the future though :)

Understood, thanks
I took them from patchwork and haven't been able to convert to an armbian-digestible mbox format; so I ended up git-diff-ing each one of them
I literally tried for hours but that patchwork format gave me only sorrow :D

Reference patchset: 1949474
Credit: Tim Harvey

@ColorfulRhino
Copy link
Collaborator

Didn't even know there was a rewrite-uboot-patches process - thanks for the hint! rewrote patches to provide a simple description

Oh, it's basically doing the same like rewrite-kernel-patches :) Great!
I was more referring to the four patches that you (I think?) took from somewhere like 1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch https://github.com/armbian/build/blob/ed2ad82bc31b98f4e279668ecf23074c2b1bb51d/patch/u-boot/v2024.07/1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch to keep the description from the original commit and author which added this. You can keep this in midn for the future though :)

Understood, thanks I took them from patchwork and haven't been able to convert to an armbian-digestible mbox format; so I ended up git-diff-ing each one of them I literally tried for hours but that patchwork format gave me only sorrow :D

Reference patchset: 1949474 Credit: Tim Harvey

Oh. You just need to

  1. Download the patch series from patchwork (sometimes single patches is better for visibility reasons and if we might want to remove certain patches later, depends on case by case)
  2. Replace the date From ... with From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 for every patch in the series (look through the file if you downloaded the series as one file)
  3. Use rewrite-uboot-patches

Then it's done :) Example: 6d78bd1

@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

Didn't even know there was a rewrite-uboot-patches process - thanks for the hint! rewrote patches to provide a simple description

Oh, it's basically doing the same like rewrite-kernel-patches :) Great!
I was more referring to the four patches that you (I think?) took from somewhere like 1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch https://github.com/armbian/build/blob/ed2ad82bc31b98f4e279668ecf23074c2b1bb51d/patch/u-boot/v2024.07/1-4-Add-fdt_kaslrseed-function-to-add-kaslr-seed-to-chosen-node.patch to keep the description from the original commit and author which added this. You can keep this in midn for the future though :)

Understood, thanks I took them from patchwork and haven't been able to convert to an armbian-digestible mbox format; so I ended up git-diff-ing each one of them I literally tried for hours but that patchwork format gave me only sorrow :D
Reference patchset: 1949474 Credit: Tim Harvey

Oh. You just need to

1. Download the patch series from patchwork (sometimes single patches is better for visibility reasons and if we might want to remove certain patches later, depends on case by case)

2. Replace the date `From ... ` with `From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001` for every patch in the series (look through the file if you downloaded the series as one file)

3. Use `rewrite-uboot-patches`

Then it's done :) Example: 6d78bd1

Grazie!!!!!!

@ColorfulRhino
Copy link
Collaborator

You're welcome! :)
Maybe there's an even easier method to convert the patchwork series into a patch. We could even make a command which does this automatically. The manual process really doesn't take long, but automating stuff is nice! As long as it doesn't add complexity 😂

Copy link
Collaborator

@ColorfulRhino ColorfulRhino left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: We should probably squash + merge this PR instead of the usual rebase + merge since there was quite some add, remove and add again stuff going on :D

@alexl83
Copy link
Contributor Author

alexl83 commented Aug 13, 2024

You're welcome! :) Maybe there's an even easier method to convert the patchwork series into a patch. We could even make a command which does this automatically. The manual process really doesn't take long, but automating stuff is nice! As long as it doesn't add complexity 😂

Maybe a command switch to rewrite-xxx-patches: like --patchwork with a sed s'/From:/From 0000/g'

@ColorfulRhino
Copy link
Collaborator

You're welcome! :) Maybe there's an even easier method to convert the patchwork series into a patch. We could even make a command which does this automatically. The manual process really doesn't take long, but automating stuff is nice! As long as it doesn't add complexity 😂

Maybe a command switch to rewrite-xxx-patches: like --patchwork with a sed s'/From:/From 0000/g'

I was more thinking of providing the patch series URL so it can download and apply it automatically. But well, probably that's too much complexity for not much added benefit.

The important thing here is the date, it has to be a magic date for Git.

@ColorfulRhino ColorfulRhino removed the Needs review Seeking for review label Aug 15, 2024
@ColorfulRhino ColorfulRhino merged commit 314447d into armbian:main Aug 15, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
11 Milestone: Fourth quarter release Hardware Hardware related like kernel, U-Boot, ... Patches Patches related to kernel, U-Boot, ... size/large PR with 250 lines or more
Development

Successfully merging this pull request may close these issues.

3 participants