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

manager.sh: add ro.boot.vbmeta.size + ro.product.ab_ota_partitions to vbmeta check #7220

Merged
merged 3 commits into from
Aug 28, 2023

Conversation

osm0sis
Copy link
Collaborator

@osm0sis osm0sis commented Aug 8, 2023

  • ro.boot.vbmeta.device doesn't seem to be in use on all devices, so add some alternative props which may be instead

- ro.boot.vbmeta.device doesn't seem to be in use on all A/B devices
@osm0sis osm0sis linked an issue Aug 8, 2023 that may be closed by this pull request
@vvb2060
Copy link
Collaborator

vvb2060 commented Aug 9, 2023

val hideVbmeta = Info.vbmeta || Info.isSamsung || Info.isAB

I think we may have forgotten something.

https://android-review.googlesource.com/c/platform/external/avb/+/320888
Looks like ro.boot.vbmeta.device not only exist on a/b devices

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 9, 2023

Hmm yeah, the original non-working path check also had the non-A/B partition name:

[ -e /dev/block/by-name/vbmeta_a ] || [ -e /dev/block/by-name/vbmeta ]

But if there's no A-only equivalent to ro.product.ab_ota_partitions that will tell us vbmeta exists then I'm not sure what else we can do for unrooted checks.

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 9, 2023

My A-only Poco X2 on stock MIUI 12 (Android 11) has a vbmeta partition. Here's what I got there:

:/ $ getprop | grep vbmeta
[ro.boot.vbmeta.avb_version]: [1.0]
[ro.boot.vbmeta.device_state]: [locked]
[ro.boot.vbmeta.digest]: [1e3b40d142d6ab0b644a448d8bbc4e4b0a13d47f0bd592814c5431440bf79bd2]
[ro.boot.vbmeta.hash_alg]: [sha256]
[ro.boot.vbmeta.invalidate_on_error]: [yes]
[ro.boot.vbmeta.size]: [6720]
:/ $

Full getprop output

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 9, 2023

Per my above grep output and https://android.googlesource.com/platform/external/avb/+/88b13e12a0ebe3c5195dbb5f48ba00ec896d1517, size having a value could be another good indicator on an A-only device.

Still not sure what to do about devices like @Stillhard's though: #7216 (comment)

@salvogiangri
Copy link
Contributor

salvogiangri commented Aug 9, 2023

Still not sure what to do about devices like @Stillhard's though: #7216 (comment)

I noticed some differences in Samsung devices as well:

  • Galaxy A52s 5G (A-only, Qualcomm, shipped with Android 11):
a52sxq:/ $ getprop | grep vb                                                                                                                              
[ro.boot.avb_version]: [1.1]
[ro.boot.svb.ver]: [SVB1.0]
[ro.boot.vbmeta.device_state]: [locked]
[vendor.boot.vbmeta.device_state]: [locked]
  • Galaxy A54 5G (A-only, Exynos, shipped with Android 13):
a54x:/ $ getprop | grep vb
[ro.boot.avb_version]: [1.2]
[ro.boot.svb.ver]: [SVB1.0]
[ro.boot.vbmeta.avb_version]: [1.1]
[ro.boot.vbmeta.device_state]: [locked]
[ro.boot.vbmeta.digest]: [e62daf841bf694f837fb17290e90dc6c62fe7dfba9538e4d3b873584af59fe54]
[ro.boot.vbmeta.hash_alg]: [sha256]
[ro.boot.vbmeta.invalidate_on_error]: [yes]
[ro.boot.vbmeta.size]: [15808]

@osm0sis osm0sis changed the title manager.sh: check vbmeta in ro.product.ab_ota_partitions as well manager.sh: add ro.boot.vbmeta.size + ro.product.ab_ota_partitions to vbmeta check Aug 9, 2023
@vvb2060
Copy link
Collaborator

vvb2060 commented Aug 9, 2023

ro.product.ab_ota_partitions must be an a/b device, we have detected a/b device, so it can be deleted.

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 9, 2023

ro.product.ab_ota_partitions must be an a/b device, we have detected a/b device, so it can be deleted.

But do A/B devices always have a vbmeta partition? I don't believe they always did/do, so checking that prop for vbmeta could still be useful to more likely have the info be accurate.

@vvb2060
Copy link
Collaborator

vvb2060 commented Aug 9, 2023

val hideVbmeta = Info.vbmeta || Info.isSamsung || Info.isAB

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 9, 2023

val hideVbmeta = Info.vbmeta || Info.isSamsung || Info.isAB

I didn't mean how it's used in Magisk, I mean in reality, so I still think it's worth leaving so the results of the check are more accurate, for whatever it later gets used for.

@salvogiangri
Copy link
Contributor

I still don't understand if implementing AVB without a vbmeta image is possible and there are devices that do not have it. Also regarding the "Patch vbmeta in boot image" option in the install page: from my understanding, changing the flags in a non-vbmeta image shouldn't be possible (avb_slot_verify.c#801), is it?

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 10, 2023

At least the first generation of A/B devices (e.g. Pixel XL, Essential PH-1, and apparently some ChromeOS devices before that) didn't have a vbmeta partition. Not sure what their prop situation looks like (maybe someone can post output from last stock?)

As for the boot.img vbmeta flags, yeah, Magisk started doing that awhile back; it only has effect on non-vbmeta partition devices, hence the check: f4ed627

@ipdev99
Copy link

ipdev99 commented Aug 12, 2023

At least the first generation of A/B devices (e.g. Pixel XL, Essential PH-1, and apparently some ChromeOS devices before that) didn't have a vbmeta partition. Not sure what their prop situation looks like (maybe someone can post output from last stock?)

Dug out my PH-1 (mata) and flashed the last factory build.
(QQ1A.200105.032)

No ro.product.ab_ota_partitions prop.

No separate vbemta partition.
No vbmeta at all?

mata:/ $ getprop | grep vb
1|mata:/ $ getprop | grep ro.product.ab_ota_partitions
1|mata:/ $ 

Patched with Magisk f86c66c-ip (26105).

  • Magisk did not give the option to patch vbmeta in boot image.
mata:/ $ su
mata:/ # getprop | grep vb
1|mata:/ # getprop | grep ro.product.ab_ota_partitions
1|mata:/ # 

PH1 dev/block/by-name
PH1 getprop
PH1 getprop as root
Magisk install log
Magisk initial boot log

Edit:
It looks like vbmeta was introduced in AVB 2.0 ?
PH-1 appears to be using AVB 1.0.

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 12, 2023

Edit: It looks like vbmeta was introduced in AVB 2.0 ? PH-1 appears to be using AVB 1.0.

Sort of? Check out my Poco X2 output above, avb 1.0 (with vbmeta prop as such), but has A-only vbmeta partition.

@osm0sis
Copy link
Collaborator Author

osm0sis commented Aug 13, 2023

@vvb2060 I wonder if we could just check if ro.boot.vbmeta.avb_version has a value at all, or if ro.boot.avb_version is > 1.0, they do seem to be the common props on all the vbmeta devices, including @Stillhard's. Just not sure if that's true everywhere.

I think this PR is good to go for now though, until we can figure more of that stuff out.

@Stillhard
Copy link

ro.boot.avb_version

Infinix-X695C:/ $ getprop ro.boot.vbmeta.avb_version

Infinix-X695C:/ $ getprop ro.boot.avb_version
1.1
Infinix-X695C:/ $

@topjohnwu topjohnwu merged commit 474268a into master Aug 28, 2023
3 checks passed
@topjohnwu topjohnwu deleted the fix/vbmeta-detect branch August 28, 2023 07:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ro.boot.vbmeta.device could not be found on many devices
6 participants