On Thu, 23 Jul 2026 16:58:14 -0700 Bobby Eshleman wrote:
> > > + if (info->attrs[NETDEV_A_DMABUF_RX_BUF_SIZE]) {
> > > + u32 rx_buf_size = nla_get_u32(info->attrs[NETDEV_A_DMABUF_RX_BUF_SIZE]);
> > > +
> > > + if (!rx_buf_size || !is_power_of_2(rx_buf_size) ||
> > > + rx_buf_size < PAGE_SIZE) {
> >
> > we should add a check: min: page-size in the Netlink policy?
>
> I played around with this adding:
>
> Documentation/netlink/specs/netdev.yaml:
> definitions:
> + -
> + type: const
> + name: page-size
> + value: 4096 # dummy value, to pass ynl_gen_c.py checks
> + header: asm/page.h
> + scope: kernel
>
> Generating:
>
> +static const struct netlink_range_validation
> netdev_a_dmabuf_rx_page_size_range = {
> + .min = PAGE_SIZE,
> + .max = U32_MAX,
> +};
> +
>
> ... but the dummy 4096 is kind of annoying. ynl_gen_c.py can't know the
> value of PAGE_SIZE but needs some value for its arithmetic checks (e.g.,
> confirm min < max is true).
>
> Should we stick with using a dummy value, or should we add a patch
> teaching ynl_gen_c.py to allow value-less consts (skip the arithmetic
> checks)?
Let's stick to a dummy one for now, but maybe something obviously dummy
like 0 ?
BTW did you add both min and max checks? Cause the only risk with using
a dummy value would be that the policy will be rendered inline, and
inline policy is u16 so 64k wouldn't fit. But your sample above has a
max of u32_max which forces the out-of-line policy, which is what we
want.
In case MMIO size is bigger than 4G and peer2peer DMA goes
through host bridge, we trigger a code path that assigns the
total linked IOVA (which is greater than 4G) to mapped_len.
Previously, `mapped_len` was declared as 32-bit `unsigned int`.
When accumulating `size_t` lengths, this leads to a silent wrap-around.
This truncation causes truncated lengths to be passed to functions
like `fill_sg_entry()`.
Fix this by changing `mapped_len` to `size_t` (64-bit). While
at it, fix similar potential overflow issues in `calc_sg_nents`
by using `check_add_overflow()` for `nents` and using
`unsigned int` for the loop iterator in `fill_sg_entry` to match.
Fixes: 3aa31a8bb11e ("dma-buf: provide phys_vec to scatter-gather mapping routine")
Cc: stable(a)vger.kernel.org
Cc: iommu(a)lists.linux.dev
Reviewed-by: Pranjal Shrivastava <praan(a)google.com>
Reviewed-by: Kevin Tian <kevin.tian(a)intel.com>
Reviewed-by: Leon Romanovsky <leon(a)kernel.org>
Signed-off-by: David Hu <xuehaohu(a)google.com>
---
Changes in v7:
- Added a missing blank line after local variable declaration in
`calc_sg_nents()` (Leon).
- Collected Reviewed-by from Leon Romanovsky.
Changes in v6:
- Used `check_add_overflow()` in `calc_sg_nents()` for safer
accumulation (Leon).
- Dropped explicit `!nents` check and added a comment noting that
`sg_alloc_table` handles `nents == 0` (Leon).
- Collected Reviewed-by from Kevin Tian.
Changes in v5:
- Removed WARN_ON_ONCE from calc_sg_nents() to avoid log noise (Jason).
- Added explicit check for `!nents` in dma_buf_phys_vec_to_sgt() to
cleanly return -EINVAL on overflow (Jason).
Changes in v4:
- Added WARN_ON_ONCE() to the nents overflow check to prevent silent
failures (Claude Bot).
Changes in v3:
- Removed leftover sentence fragment from the commit message.
- Kept `nents = 0` initialization (previously stated as removed in the
v2 changelog) as it is strictly required for the `+=` accumulation
loop in `calc_sg_nents()`.
Changes in v2:
- Fixed 'IVOA' -> 'IOVA' typo and expanded commit message (Claude Bot).
- Added Reverse Xmas tree formatting (Pranjal).
- Folded in extra bounds checking for calc_sg_nents() (Pranjal).
- Folded in type consistency fix for fill_sg_entry() (Pranjal).
- Collected Reviewed-by from Pranjal Shrivastava.
drivers/dma-buf/dma-buf-mapping.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/drivers/dma-buf/dma-buf-mapping.c b/drivers/dma-buf/dma-buf-mapping.c
index 794acff2546a..80f6ab2f4809 100644
--- a/drivers/dma-buf/dma-buf-mapping.c
+++ b/drivers/dma-buf/dma-buf-mapping.c
@@ -5,12 +5,13 @@
*/
#include <linux/dma-buf-mapping.h>
#include <linux/dma-resv.h>
+#include <linux/overflow.h>
static struct scatterlist *fill_sg_entry(struct scatterlist *sgl, size_t length,
dma_addr_t addr)
{
unsigned int len, nents;
- int i;
+ unsigned int i;
nents = DIV_ROUND_UP(length, UINT_MAX);
for (i = 0; i < nents; i++) {
@@ -40,8 +41,12 @@ static unsigned int calc_sg_nents(struct dma_iova_state *state,
size_t i;
if (!state || !dma_use_iova(state)) {
- for (i = 0; i < nr_ranges; i++)
- nents += DIV_ROUND_UP(phys_vec[i].len, UINT_MAX);
+ for (i = 0; i < nr_ranges; i++) {
+ unsigned int added = DIV_ROUND_UP(phys_vec[i].len, UINT_MAX);
+
+ if (check_add_overflow(nents, added, &nents))
+ return 0;
+ }
} else {
/*
* In IOVA case, there is only one SG entry which spans
@@ -95,9 +100,10 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
size_t nr_ranges, size_t size,
enum dma_data_direction dir)
{
- unsigned int nents, mapped_len = 0;
struct dma_buf_dma *dma;
struct scatterlist *sgl;
+ size_t mapped_len = 0;
+ unsigned int nents;
dma_addr_t addr;
size_t i;
int ret;
@@ -133,6 +139,8 @@ struct sg_table *dma_buf_phys_vec_to_sgt(struct dma_buf_attachment *attach,
}
nents = calc_sg_nents(dma->state, phys_vec, nr_ranges, size);
+
+ /* sg_alloc_table will cleanly fail and return -EINVAL if nents == 0 */
ret = sg_alloc_table(&dma->sgt, nents, GFP_KERNEL | __GFP_ZERO);
if (ret)
goto err_free_state;
--
2.54.0.1064.gd145956f57-goog
+++27658690316 💊 Abortion Pills in DUBAI | Abu Dhabi ++27658690316 💊 | Sharjah | satwa | Price of Cytotec, Misoprostol, Mifepristone, Miso Cytotec 💊👉 pill clear, Mifegest-kit, Emergency contraceptive pills, Morning after sex pills, ipills, in Dubai | Qatar | + KuwaitGet your discreet 100% safe*++27658690316 💊 *❇️❇️MUSCAT RUWI +27658690316 💊*effective abortion pills in Dubai, We have mifepristone and misoprostol kit, Cytotec, Ma-Kare Kit For sale in Dubai,Abu Dhabi,+27658690316 💊,❇️Sharjah ,Ajman ++27658690316 💊, Alain, Fujairah, UAE. BUY++27658690316 💊 ❇️ Mifepristone and Misoprostol (Cytotec), Mtp Kit In UAE. Abortion pills available in UAE (United Arab Emirates), + +27658690316 💊, Oman ++27658690316 💊 Muscat ruwi❇️ Bahrain and Qatar.++27658690316 💊 ❇️ Contact us today.( +++27658690316 💊 -The UAE's leading abortion care service in Dubai. Abortion++27658690316 💊 ❇️ Treatment. Medical Abortion. Surgical Abortion. Find A Clinic like Dr Maria Abortion clinic in Dubai We have Abortion Pills / Cytotec Tablets Available in Dubai,AbuDhabi , ❇️++27658690316 💊 R, BAHRAIN, DOHA,SALMIYA,Sharjah, Ajman, Alain, Fujairah, ++27658690316 💊, UAE., buy cytotec in Dubai abortion Pills Cytotec ++27658690316 💊 also❇️❇️❇️ available ++27658690316 💊 Abortion Pills For Sale In Al Dair +(concealed information)Abortion Pills For Sale In Zinj +(concealed information)Northern Governorate +27658690316 💊👉+(conceal
⎞Cytote Pills☎️++27658690316 💊♻️in dubai, abu dhabi ++27658690316 💊 DOHA,SALMIYA,++27658690316 💊
+++27658690316 💊 Abortion Pills in DUBAI | Abu Dhabi ++27658690316 💊 | Sharjah | satwa | Price of Cytotec, Misoprostol, Mifepristone, Miso Cytotec 💊👉 pill clear, Mifegest-kit, Emergency contraceptive pills, Morning after sex pills, ipills, in Dubai | Qatar | + KuwaitGet your discreet 100% safe*++27658690316 💊 *❇️❇️MUSCAT RUWI +27658690316 💊*effective abortion pills in Dubai, We have mifepristone and misoprostol kit, Cytotec, Ma-Kare Kit For sale in Dubai,Abu Dhabi,+27658690316 💊,❇️Sharjah ,Ajman ++27658690316 💊, Alain, Fujairah, UAE. BUY++27658690316 💊 ❇️ Mifepristone and Misoprostol (Cytotec), Mtp Kit In UAE. Abortion pills available in UAE (United Arab Emirates), + +27658690316 💊, Oman ++27658690316 💊 Muscat ruwi❇️ Bahrain and Qatar.++27658690316 💊 ❇️ Contact us today.( +++27658690316 💊 -The UAE's leading abortion care service in Dubai. Abortion++27658690316 💊 ❇️ Treatment. Medical Abortion. Surgical Abortion. Find A Clinic like Dr Maria Abortion clinic in Dubai We have Abortion Pills / Cytotec Tablets Available in Dubai,AbuDhabi , ❇️++27658690316 💊 R, BAHRAIN, DOHA,SALMIYA,Sharjah, Ajman, Alain, Fujairah, ++27658690316 💊, UAE., buy cytotec in Dubai abortion Pills Cytotec ++27658690316 💊 also❇️❇️❇️ available ++27658690316 💊 Abortion Pills For Sale In Al Dair +(concealed information)Abortion Pills For Sale In Zinj +(concealed information)Northern Governorate +27658690316 💊👉+(conceal
Gifted Lost love spells +27697708943,❇️ Don’t be discouraged Come see Me, I am a Gifted Drwava Reader and Adviser or Call for a phone Session. I Specialise in :-
•Lost Love Spells
•Relationship problems
•Bad luck removal
•Spirit protection & cleansing
•Binding Love Spells
•Gay Love Spells Pay after job is done / results after pay +27697708943,❇️
HEALER DOCTORS,
Woodstock, +27697708943❇️THANKS TO KHULU MASIYE TRADITIONAL HEALER Sea Point, Green Point,+☎️++ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Clifton +♻️++27697708943,❇️ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Camps Bay, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, +♻️++27697708943,❇️,❇️ MuizenbergTHANKS TO KHULU MASIYE TRADITIONAL HEALER , Kalk Bay, Cape Town,THANKS TO KHULU MASIYE TRADITIONAL HEALER Atlantis, Bellville, Blue Downs, Brackenfell, Crossroads, Ceres, Paarl, Durbanville,THANKS TO KHULU MASIYE TRADITIONAL HEALER ++27697708943,❇️ Eerste River, THANKS TO KHULU MASIYE TRADITIONAL HEALER Elsie's River, Fish Hoek,+♻️++27697708943,❇️ Goodwood, Gordon's Bay, +27697708943 Worcester,+☎️+++27697708943,❇️ in ⎞⎞ Guguletu, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, Khayelitsha, ++27697708943,❇️ Kraaifontein, Kuils River, Langa, +27697708943 Malmesbury,++27697708943,❇️ THANKS TO KHULU MASIYE TRADITIONAL HEALER rondebosch, Macassar, Melkbosstrand+☎️+++27697708943,❇️ in ⎞⎞,THANKS TO KHULU MASIYE TRADITIONAL HEALER Mfuleni, Milnerton, Mitchell's Plain, ++27697708943,❇️ Noordhoek, Nyanga, Observatory, Parow,++27697708943,❇️ Simon's Town, Somerset West, StrandTHANKS TO KHULU MASIYE TRADITIONAL
Woodstock, +27697708943❇️THANKS TO KHULU MASIYE TRADITIONAL HEALER Sea Point, Green Point,+☎️++ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Clifton +♻️++27697708943,❇️ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Camps Bay, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, +♻️++27697708943,❇️,❇️ MuizenbergTHANKS TO KHULU MASIYE TRADITIONAL HEALER , Kalk Bay, Cape Town,THANKS TO KHULU MASIYE TRADITIONAL HEALER Atlantis, Bellville, Blue Downs, Brackenfell, Crossroads, Ceres, Paarl, Durbanville,THANKS TO KHULU MASIYE TRADITIONAL HEALER ++27697708943,❇️ Eerste River, THANKS TO KHULU MASIYE TRADITIONAL HEALER Elsie's River, Fish Hoek,+♻️++27697708943,❇️ Goodwood, Gordon's Bay, +27697708943 Worcester,+☎️+++27697708943,❇️ in ⎞⎞ Guguletu, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, Khayelitsha, ++27697708943,❇️ Kraaifontein, Kuils River, Langa, +27697708943 Malmesbury,++27697708943,❇️ THANKS TO KHULU MASIYE TRADITIONAL HEALER rondebosch, Macassar, Melkbosstrand+☎️+++27697708943,❇️ in ⎞⎞,THANKS TO KHULU MASIYE TRADITIONAL HEALER Mfuleni, Milnerton, Mitchell's Plain, ++27697708943,❇️ Noordhoek, Nyanga, Observatory, Parow,++27697708943,❇️ Simon's Town, Somerset West, StrandTHANKS TO KHULU MASIYE TRADITIONAL
GUARANTEED +♻️++27658690316,❇️ TRADITIONAL HEALER CALL NOW ☎️+++27697708943,❇️ in ⎞⎞ BOOK THE APPOINTMENT THANKS TO KHULU MASIYE TRADITIONAL HEALER
TESTIMONY @@@++27697708943,❇️~~~FOR KHULU MASIYE ALL THANKS TO KHULU MASIYE TRADITIONAL HEALER FOR A GOOD JOB THAT HE DID FOR ME.MY NAME IS LERATO FROM MPUMALANGA MY NUMBER IS ><>:{++☎️+++27697708943,❇️ in ⎞⎞} I HAVE BEEN MEETING WITH THE WRONG
THEY WERE TELLING ME STORIES AND I WAS KEEPING EVERYTHING AS A SECRET BUT++27697708943,❇️ @@@@ ONE DAY I TRIED TALKING WITH MY COLLEAGUE ++27697708943,❇️ TELL HER ABOUT MY LIFE AND SHE TOLD ME ABOUT KHULU MASIYE THAT HE HELPED HER TO GET MONEY IN HER HOUSE IT WAS 3 MILLION AND SHE PAID 20% FROM THAT MONEY. I THEN TRIED CALLING HIM ♻️++27697708943,❇️ HE TOLD ME ABOUT SHORT BOYS TO PUT MONEY IN MY ACCOUNT, ☎️+++27697708943,❇️ in ⎞⎞ MY HOUSE, BUT I CHOOSE SHORT BOYS TO PUT MONEY IN MY ACCOUNT SO I ASKED HIM HOW MUCH MUST I PAY WHEN I WANT 2 MILLION HE SAID I WILL PAY AFTER THE JOB IS DONE BUT I HAVE TO SEND HIM SOME LITTLE MONEY FIRST TO BUY FOOD OF SHORT BOY'S WHO'S GOING TO DEPOSIT THE MONEY IN MY ACCOUNT, I DID ♻️++27697708943,❇️ HE THEN TOLD ME TO SEND MY BANKING DETAILS AND WAIT FOR 1 HOUR AND 30 MINUTES I WILL GET A MESSAGE FROM THE BANK, I GOT A MESSAGE FROM THE BANK AND I ALSO WENT TO WITHDRAW 15% AND WENT TO GIVE HIM HIS MONEY IN HIS OFFICE. SO I THANK MY FRIEND FOR INTRODUCING ME TO KHULU MASIYE.☎️+++27697708943,❇️ in ⎞⎞ FOR MORE INFORMATION CALL/WHATSAPP KHULU MASIYE ON: ,><>{+ } AND IS NOT LIKE HE DO HELP ONLY ABOUT MONEY ISSUES HE DO HELP MANY PROBLEMS NO MATTER HOW FAR YOU'RE OR HOW DIFFICULT IT MIGHT BE KHULU MASIYE HE WILL HELP YOU CALL/WHATSAPP HIM TODAY AND MAKE YOUR DREAMS COME TROUGH .<<>{++27697708943,❇️ \] SANGOMA HELPED ME +27658690316
Woodstock, +27697708943❇️THANKS TO KHULU MASIYE TRADITIONAL HEALER Sea Point, Green Point,+☎️++ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Clifton +♻️++27697708943,❇️ in THANKS TO KHULU MASIYE TRADITIONAL HEALER ⎞⎞ Camps Bay, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, +♻️++27697708943,❇️,❇️ MuizenbergTHANKS TO KHULU MASIYE TRADITIONAL HEALER , Kalk Bay, Cape Town,THANKS TO KHULU MASIYE TRADITIONAL HEALER Atlantis, Bellville, Blue Downs, Brackenfell, Crossroads, Ceres, Paarl, Durbanville,THANKS TO KHULU MASIYE TRADITIONAL HEALER ++27697708943,❇️ Eerste River, THANKS TO KHULU MASIYE TRADITIONAL HEALER Elsie's River, Fish Hoek,+♻️++27697708943,❇️ Goodwood, Gordon's Bay, +27697708943 Worcester,+☎️+++27697708943,❇️ in ⎞⎞ Guguletu, THANKS TO KHULU MASIYE TRADITIONAL HEALER Hout Bay, Khayelitsha, ++27697708943,❇️ Kraaifontein, Kuils River, Langa, +27697708943 Malmesbury,++27697708943,❇️ THANKS TO KHULU MASIYE TRADITIONAL HEALER rondebosch, Macassar, Melkbosstrand+☎️+++27697708943,❇️ in ⎞⎞,THANKS TO KHULU MASIYE TRADITIONAL HEALER Mfuleni, Milnerton, Mitchell's Plain, ++27697708943,❇️ Noordhoek, Nyanga, Observatory, Parow,++27697708943,❇️ Simon's Town, Somerset West, StrandTHANKS TO KHULU MASIYE TRADITIONAL
Gifted Lost love spells +27697708943,❇️ Don’t be discouraged Come see Me, I am a Gifted Drwava Reader and Adviser or Call for a phone Session. I Specialise in :-
•Lost Love Spells
•Relationship problems
•Bad luck removal
•Spirit protection & cleansing
•Binding Love Spells
•Gay Love Spells Pay after job is done / results after pay +27697708943,❇️
+++27658690316 💊 Abortion Pills in DUBAI | Abu Dhabi ++27658690316 💊 | Sharjah | satwa | Price of Cytotec, Misoprostol, Mifepristone, Miso Cytotec 💊👉 pill clear, Mifegest-kit, Emergency contraceptive pills, Morning after sex pills, ipills, in Dubai | Qatar | + KuwaitGet your discreet 100% safe*++27658690316 💊 *❇️❇️MUSCAT RUWI +27658690316 💊*effective abortion pills in Dubai, We have mifepristone and misoprostol kit, Cytotec, Ma-Kare Kit For sale in Dubai,Abu Dhabi,+27658690316 💊,❇️Sharjah ,Ajman ++27658690316 💊, Alain, Fujairah, UAE. BUY++27658690316 💊 ❇️ Mifepristone and Misoprostol (Cytotec), Mtp Kit In UAE. Abortion pills available in UAE (United Arab Emirates), + +27658690316 💊, Oman ++27658690316 💊 Muscat ruwi❇️ Bahrain and Qatar.++27658690316 💊 ❇️ Contact us today.( +++27658690316 💊 -The UAE's leading abortion care service in Dubai. Abortion++27658690316 💊 ❇️ Treatment. Medical Abortion. Surgical Abortion. Find A Clinic like Dr Maria Abortion clinic in Dubai We have Abortion Pills / Cytotec Tablets Available in Dubai,AbuDhabi , ❇️++27658690316 💊 R, BAHRAIN, DOHA,SALMIYA,Sharjah, Ajman, Alain, Fujairah, ++27658690316 💊, UAE., buy cytotec in Dubai abortion Pills Cytotec ++27658690316 💊 also❇️❇️❇️ available ++27658690316 💊 Abortion Pills For Sale In Al Dair +(concealed information)Abortion Pills For Sale In Zinj +(concealed information)Northern Governorate +27658690316 💊👉+(conceal