mtd: intel-dg: fix array-index-out-of-bounds in intel_dg_mtd_probe()
PATCH 1/1 mtd: intel-dg: fix array-index-out-of-bounds in intel_dg_mtd_probe()
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter nvm->nregions before the first access to flexible-array member nvm->regions[].
from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823
Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15
Notice that this flexible array is annotated with the counted_by() attribute, hence the counter must always be updated before the first access to the array.
--- drivers/mtd/devices/mtd_intel_dg.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/mtd/devices/mtd_intel_dg.c +3 -0
@@ -768,6 +768,9 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,if (!nvm)return -ENOMEM ; +/* Update nvm->nregions before first access to nvm->regions[] below. */ + nvm->nregions = nregions; +kref_init (&nvm->refcnt);mutex_init (&nvm->lock);
Signature · 1 line
2.43.0
Hi,
Quoted 3 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].
Yeah, I suspected something like that but didn't find any in-tree documentation about it.
Quoted 5 lines
from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15
Quoted 8 lines
Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.Fixes ceb5ab3cb646 ("mtd: add driver for intel graphics non-volatile memory device")Reported-by Randy Dunlap <[email protected]>
More appropriately:
Thanks.
Quoted 19 lines
Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/mtd/devices/mtd_intel_dg.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mtd/devices/mtd_intel_dg.c +3
-0@@ -768,6 +768,9 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,if (!nvm)return -ENOMEM ; +/* Update nvm->nregions before first access to nvm->regions[] below. */ + nvm->nregions = nregions; +kref_init (&nvm->refcnt);mutex_init (&nvm->lock);
Signature · 1 line
~Randy
Quoted 4 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].
Quoted 8 lines
from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.
Already fixed[1], but not sure if it's landed yet.
[1] https://lore.kernel.org/linux-mtd/[email protected]/
Raag
Quoted 26 lines
Fixes ceb5ab3cb646 ("mtd: add driver for intel graphics non-volatile memory device")Reported-by Randy Dunlap <[email protected]>Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/mtd/devices/mtd_intel_dg.c | 3 +++ 1 file changed, 3 insertions(+)drivers/mtd/devices/mtd_intel_dg.c +3
-0@@ -768,6 +768,9 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,if (!nvm)return -ENOMEM ; +/* Update nvm->nregions before first access to nvm->regions[] below. */ + nvm->nregions = nregions; +kref_init (&nvm->refcnt);mutex_init (&nvm->lock);Signature · 1 line
2.43.0
Quoted 10 lines · Raag Jadav
Quoted 9 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15
Quoted 7 lines
Quoted 3 lines
Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.Already fixed[1], but not sure if it's landed yet.
Great! :)
Thanks
-Gustavo
Hi,
Quoted 10 lines · Raag Jadav
Quoted 9 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15
Quoted 7 lines
Quoted 3 lines
Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.Already fixed[1], but not sure if it's landed yet.
What's the status of this patch, please?
Signature · 1 line
~Randy
Quoted 17 lines · Randy Dunlap
Hi,
Quoted 14 lines · Raag Jadav
Quoted 12 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in /var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.
Quoted 5 lines
Quoted 3 lines
Already fixed[1], but not sure if it's landed yet.
What's the status of this patch, please?
I'm assuming it'll go through mtd tree? Miquel?
Raag
Miquel Raynal
maintainerQuoted 19 lines · Raag Jadav
Quoted 18 lines · Randy Dunlap
Hi,
Quoted 15 lines · Raag Jadav
Quoted 13 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Already fixed[1], but not sure if it's landed yet.
What's the status of this patch, please?
I'm assuming it'll go through mtd tree? Miquel?
It should indeed. However only the mtd list has been included, so it won't appear in "my" todo list. Lucas can you please resend, and use a tool such as b4 to manage the series or at least run get_maintainers.pl?
Thanks,
Miquèl
Quoted 24 lines · Miquel Raynal
Quoted 23 lines · Raag Jadav
Quoted 22 lines · Randy Dunlap
Hi,
Quoted 18 lines · Raag Jadav
Quoted 7 lines · Gustavo A. R. Silva
Fix the UBSAN: array-index-out-of-bounds issue below by updating counter
nvm->nregionsbefore the first access to flexible-array member nvm->regions[].from kernel bugzilla:
https://bugzilla.kernel.org/show_bug.cgi?id=220823Quoted 6 lines
Dec 15 22:01:52 orpheus kernel: UBSAN: array-index-out-of-bounds in
/var/tmp/portage/sys-kernel/gentoo-kernel-6.18.1/work/linux-6.18/drivers/mtd/devices/mtd_intel_dg.c:750:15Notice that this flexible array is annotated with the
counted_by()attribute, hence the counter must always be updated before the first access to the array.Already fixed[1], but not sure if it's landed yet.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
What's the status of this patch, please?
I'm assuming it'll go through mtd tree? Miquel?
It should indeed. However only the mtd list has been included, so it won't appear in "my" todo list. Lucas can you please resend, and use a tool such as b4 to manage the series or at least run get_maintainers.pl?
Lucas is no longer with Intel. Sasha, would you be up for it?
Raag