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

Disable asserts if force flag enabled #162

Open
bmx666 opened this issue Dec 18, 2024 · 5 comments
Open

Disable asserts if force flag enabled #162

bmx666 opened this issue Dec 18, 2024 · 5 comments
Assignees

Comments

@bmx666
Copy link

bmx666 commented Dec 18, 2024

I have some dtb to analyze from one of embedded device, it contains some errors, but during conversation from dtb to dts tool throws assert.

dtc -f -I dtb -O dts broken.dtb > broken.dts
dtc: livetree.c:437: propval_cell: Assertion `prop->val.len == sizeof(cell_t)' failed.

Could you please ignore assert if "force" has been enabled?

cell_t propval_cell(struct property *prop)
{
        if (!force)
                assert(prop->val.len == sizeof(cell_t));
        return fdt32_to_cpu(*((fdt32_t *)prop->val.val));
}

cell_t propval_cell_n(struct property *prop, unsigned int n)
{
        if (!force)
                assert(prop->val.len / sizeof(cell_t) > n);
        return fdt32_to_cpu(*((fdt32_t *)prop->val.val + n));
}
@dgibson dgibson self-assigned this Dec 24, 2024
@dgibson
Copy link
Owner

dgibson commented Dec 24, 2024

@bmx666 that's certainly a bug, but the proposed solution isn't quite right. The problem lies in the caller of propval_cell() - it shouldn't be calling that on untrusted input without first verifying that the property has the expected form.

Can you attach the dtb causing the problem, then I can work out exactly what path is causing this and fix it.

@bmx666
Copy link
Author

bmx666 commented Dec 24, 2024

@dgibson
Copy link
Owner

dgibson commented Dec 25, 2024

I've had a preliminary look and it sems like the problem is in the graph checks. As an interim approach, you should be able to disable those with -Wno-graph_nodes.

@bmx666
Copy link
Author

bmx666 commented Dec 25, 2024

Probably I'm not the first and not the last. The most people use dtc from package delivery system in OS. Because I had experience early it took me 5 min to find and fix this issue to generate at least some dts. My question, do you have plans to fix it or just left it as-is? If you don't want to fix it, just close the current issue.

@dgibson
Copy link
Owner

dgibson commented Dec 26, 2024

Sorry, I wasn't clear. Yes I plan to fix this, probably soon - it doesn't look too hard. But, it will be at least a few days, probably not until the new year. In the meantime you can disable the graph_nodes check as a workaround.

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

No branches or pull requests

2 participants