Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] The command-line parser fails to reject `rx_buf_size` values greater 
than 2 MB, contradicting the commit message.
--

commit 912f8a02a43d25bdd0747aae62f81533304811cd
Author: Bobby Eshleman <[email protected]>

selftests/net: ncdevmem: add -b option to set rx-buf-size on bind

This commit adds a -b option to ncdevmem to set a non-default rx-buf-size.
When the requested size exceeds PAGE_SIZE, it switches to an MFD_HUGETLB
backed memfd.

>     Reject values > 2 MB up front: MFD_HUGETLB + udmabuf can only guarantee
>     2 MB per sg entry (one hugepage), so a larger rx_buf_size would fail the
>     per-sg length/alignment check.

[ ... ]

> diff --git a/tools/testing/selftests/drivers/net/hw/ncdevmem.c 
> b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> --- a/tools/testing/selftests/drivers/net/hw/ncdevmem.c
> +++ b/tools/testing/selftests/drivers/net/hw/ncdevmem.c
[ ... ]
> @@ -1446,6 +1463,19 @@ int main(int argc, char *argv[])
>               case 'n':
>                       skip_config = 1;
>                       break;
> +             case 'b': {
> +                     unsigned long val;
> +
> +                     errno = 0;
> +                     val = strtoul(optarg, NULL, 0);
> +                     if ((val == ULONG_MAX && errno == ERANGE) ||
> +                         val > UINT32_MAX) {

[Severity: Medium]
The commit message mentions that values greater than 2 MB are rejected up
front, but does this parser block actually enforce that limit? 

Looking at the validation condition here in main(), it appears to only
reject values greater than UINT32_MAX. Should this include a check against
MB(2) to prevent the per-sg length and alignment failures described in the
commit message?

> +                             pr_err("invalid rx_buf_size: %s", optarg);
> +                             return 1;
> +                     }
> +                     rx_buf_size = val;
> +                     break;
> +             }

-- 
Sashiko AI review · 
https://sashiko.dev/#/patchset/[email protected]?part=3

Reply via email to