* [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
@ 2025-03-19 12:42 Leon Romanovsky
2025-03-19 17:23 ` Jason Gunthorpe
2025-04-09 18:32 ` Leon Romanovsky
0 siblings, 2 replies; 8+ messages in thread
From: Leon Romanovsky @ 2025-03-19 12:42 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Shay Drory, linux-rdma
From: Shay Drory <shayd@nvidia.com>
syzkaller triggered an oversized kvmalloc() warning.
Silence it by adding __GFP_NOWARN.
syzkaller log:
WARNING: CPU: 7 PID: 518 at mm/util.c:665 __kvmalloc_node_noprof+0x175/0x180
CPU: 7 UID: 0 PID: 518 Comm: c_repro Not tainted 6.11.0-rc6+ #6
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
RIP: 0010:__kvmalloc_node_noprof+0x175/0x180
RSP: 0018:ffffc90001e67c10 EFLAGS: 00010246
RAX: 0000000000000100 RBX: 0000000000000400 RCX: ffffffff8149d46b
RDX: 0000000000000000 RSI: ffff8881030fae80 RDI: 0000000000000002
RBP: 000000712c800000 R08: 0000000000000100 R09: 0000000000000000
R10: ffffc90001e67c10 R11: 0030ae0601000000 R12: 0000000000000000
R13: 0000000000000000 R14: 00000000ffffffff R15: 0000000000000000
FS: 00007fde79159740(0000) GS:ffff88813bdc0000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000180 CR3: 0000000105eb4005 CR4: 00000000003706b0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
<TASK>
ib_umem_odp_get+0x1f6/0x390
mlx5_ib_reg_user_mr+0x1e8/0x450
ib_uverbs_reg_mr+0x28b/0x440
ib_uverbs_write+0x7d3/0xa30
vfs_write+0x1ac/0x6c0
ksys_write+0x134/0x170
? __sanitizer_cov_trace_pc+0x1c/0x50
do_syscall_64+0x50/0x110
entry_SYSCALL_64_after_hwframe+0x76/0x7e
Fixes: 37824952dc8f ("RDMA/odp: Use kvcalloc for the dma_list and page_list")
Signed-off-by: Shay Drory <shayd@nvidia.com>
Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
---
drivers/infiniband/core/umem_odp.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c
index e9fa22d31c23..c48ef6083020 100644
--- a/drivers/infiniband/core/umem_odp.c
+++ b/drivers/infiniband/core/umem_odp.c
@@ -76,12 +76,14 @@ static inline int ib_init_umem_odp(struct ib_umem_odp *umem_odp,
npfns = (end - start) >> PAGE_SHIFT;
umem_odp->pfn_list = kvcalloc(
- npfns, sizeof(*umem_odp->pfn_list), GFP_KERNEL);
+ npfns, sizeof(*umem_odp->pfn_list),
+ GFP_KERNEL | __GFP_NOWARN);
if (!umem_odp->pfn_list)
return -ENOMEM;
umem_odp->dma_list = kvcalloc(
- ndmas, sizeof(*umem_odp->dma_list), GFP_KERNEL);
+ ndmas, sizeof(*umem_odp->dma_list),
+ GFP_KERNEL | __GFP_NOWARN);
if (!umem_odp->dma_list) {
ret = -ENOMEM;
goto out_pfn_list;
--
2.48.1
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-19 12:42 [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning Leon Romanovsky
@ 2025-03-19 17:23 ` Jason Gunthorpe
2025-03-26 10:58 ` Leon Romanovsky
2025-04-09 18:32 ` Leon Romanovsky
1 sibling, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2025-03-19 17:23 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Shay Drory, linux-rdma
On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
> From: Shay Drory <shayd@nvidia.com>
>
> syzkaller triggered an oversized kvmalloc() warning.
> Silence it by adding __GFP_NOWARN.
I don't think GFP_NOWARN is the right thing..
We've hit this before and I think we ended up adding a size limit
check prior to the kvmalloc to prevent the overflow triggered warning.
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-19 17:23 ` Jason Gunthorpe
@ 2025-03-26 10:58 ` Leon Romanovsky
2025-03-31 17:45 ` Jason Gunthorpe
0 siblings, 1 reply; 8+ messages in thread
From: Leon Romanovsky @ 2025-03-26 10:58 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Shay Drory, linux-rdma
On Wed, Mar 19, 2025 at 02:23:49PM -0300, Jason Gunthorpe wrote:
> On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
> > From: Shay Drory <shayd@nvidia.com>
> >
> > syzkaller triggered an oversized kvmalloc() warning.
> > Silence it by adding __GFP_NOWARN.
>
> I don't think GFP_NOWARN is the right thing..
>
> We've hit this before and I think we ended up adding a size limit
> check prior to the kvmalloc to prevent the overflow triggered warning.
The size check was needed before this commit was merged:
0708a0afe291 ("mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls")
From that point, the correct solution is simply provide __GFP_NOWARN flag.
Thanks
>
> Jason
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-26 10:58 ` Leon Romanovsky
@ 2025-03-31 17:45 ` Jason Gunthorpe
2025-03-31 19:04 ` Leon Romanovsky
0 siblings, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2025-03-31 17:45 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Shay Drory, linux-rdma
On Wed, Mar 26, 2025 at 12:58:54PM +0200, Leon Romanovsky wrote:
> On Wed, Mar 19, 2025 at 02:23:49PM -0300, Jason Gunthorpe wrote:
> > On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
> > > From: Shay Drory <shayd@nvidia.com>
> > >
> > > syzkaller triggered an oversized kvmalloc() warning.
> > > Silence it by adding __GFP_NOWARN.
> >
> > I don't think GFP_NOWARN is the right thing..
> >
> > We've hit this before and I think we ended up adding a size limit
> > check prior to the kvmalloc to prevent the overflow triggered warning.
>
> The size check was needed before this commit was merged:
> 0708a0afe291 ("mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls")
>
> From that point, the correct solution is simply provide __GFP_NOWARN flag.
I'm not sure, NOWARN removes all warnings, even normal OOM warnings
from regually sized allocations which we don't want to remove.
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-31 17:45 ` Jason Gunthorpe
@ 2025-03-31 19:04 ` Leon Romanovsky
2025-04-01 16:35 ` Jason Gunthorpe
0 siblings, 1 reply; 8+ messages in thread
From: Leon Romanovsky @ 2025-03-31 19:04 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Shay Drory, linux-rdma
On Mon, Mar 31, 2025, at 20:45, Jason Gunthorpe wrote:
> On Wed, Mar 26, 2025 at 12:58:54PM +0200, Leon Romanovsky wrote:
>> On Wed, Mar 19, 2025 at 02:23:49PM -0300, Jason Gunthorpe wrote:
>> > On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
>> > > From: Shay Drory <shayd@nvidia.com>
>> > >
>> > > syzkaller triggered an oversized kvmalloc() warning.
>> > > Silence it by adding __GFP_NOWARN.
>> >
>> > I don't think GFP_NOWARN is the right thing..
>> >
>> > We've hit this before and I think we ended up adding a size limit
>> > check prior to the kvmalloc to prevent the overflow triggered warning.
>>
>> The size check was needed before this commit was merged:
>> 0708a0afe291 ("mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls")
>>
>> From that point, the correct solution is simply provide __GFP_NOWARN flag.
>
> I'm not sure, NOWARN removes all warnings, even normal OOM warnings
> from regually sized allocations which we don't want to remove.
I disagree, this allocation is called from user space. We can safely skip OOM messages and error here will be enough.
Thanks
>
> Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-31 19:04 ` Leon Romanovsky
@ 2025-04-01 16:35 ` Jason Gunthorpe
2025-04-03 10:30 ` Leon Romanovsky
0 siblings, 1 reply; 8+ messages in thread
From: Jason Gunthorpe @ 2025-04-01 16:35 UTC (permalink / raw)
To: Leon Romanovsky; +Cc: Shay Drory, linux-rdma
On Mon, Mar 31, 2025 at 10:04:05PM +0300, Leon Romanovsky wrote:
>
>
> On Mon, Mar 31, 2025, at 20:45, Jason Gunthorpe wrote:
> > On Wed, Mar 26, 2025 at 12:58:54PM +0200, Leon Romanovsky wrote:
> >> On Wed, Mar 19, 2025 at 02:23:49PM -0300, Jason Gunthorpe wrote:
> >> > On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
> >> > > From: Shay Drory <shayd@nvidia.com>
> >> > >
> >> > > syzkaller triggered an oversized kvmalloc() warning.
> >> > > Silence it by adding __GFP_NOWARN.
> >> >
> >> > I don't think GFP_NOWARN is the right thing..
> >> >
> >> > We've hit this before and I think we ended up adding a size limit
> >> > check prior to the kvmalloc to prevent the overflow triggered warning.
> >>
> >> The size check was needed before this commit was merged:
> >> 0708a0afe291 ("mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls")
> >>
> >> From that point, the correct solution is simply provide __GFP_NOWARN flag.
> >
> > I'm not sure, NOWARN removes all warnings, even normal OOM warnings
> > from regually sized allocations which we don't want to remove.
>
> I disagree, this allocation is called from user space. We can safely
> skip OOM messages and error here will be enough.
That is not the standard, we OOM splat on all userspace allocations
too.
GFP_NOWARN is supposed to be used in cases where the OOM has a
recovery and nothing will fail.
I think the right thing here is to limit the size, though I'm not
really sure what the limit should be.
Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-04-01 16:35 ` Jason Gunthorpe
@ 2025-04-03 10:30 ` Leon Romanovsky
0 siblings, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2025-04-03 10:30 UTC (permalink / raw)
To: Jason Gunthorpe; +Cc: Shay Drory, linux-rdma
On Tue, Apr 01, 2025 at 01:35:04PM -0300, Jason Gunthorpe wrote:
> On Mon, Mar 31, 2025 at 10:04:05PM +0300, Leon Romanovsky wrote:
> >
> >
> > On Mon, Mar 31, 2025, at 20:45, Jason Gunthorpe wrote:
> > > On Wed, Mar 26, 2025 at 12:58:54PM +0200, Leon Romanovsky wrote:
> > >> On Wed, Mar 19, 2025 at 02:23:49PM -0300, Jason Gunthorpe wrote:
> > >> > On Wed, Mar 19, 2025 at 02:42:21PM +0200, Leon Romanovsky wrote:
> > >> > > From: Shay Drory <shayd@nvidia.com>
> > >> > >
> > >> > > syzkaller triggered an oversized kvmalloc() warning.
> > >> > > Silence it by adding __GFP_NOWARN.
> > >> >
> > >> > I don't think GFP_NOWARN is the right thing..
> > >> >
> > >> > We've hit this before and I think we ended up adding a size limit
> > >> > check prior to the kvmalloc to prevent the overflow triggered warning.
> > >>
> > >> The size check was needed before this commit was merged:
> > >> 0708a0afe291 ("mm: Consider __GFP_NOWARN flag for oversized kvmalloc() calls")
> > >>
> > >> From that point, the correct solution is simply provide __GFP_NOWARN flag.
> > >
> > > I'm not sure, NOWARN removes all warnings, even normal OOM warnings
> > > from regually sized allocations which we don't want to remove.
> >
> > I disagree, this allocation is called from user space. We can safely
> > skip OOM messages and error here will be enough.
>
> That is not the standard, we OOM splat on all userspace allocations
> too.
>
> GFP_NOWARN is supposed to be used in cases where the OOM has a
> recovery and nothing will fail.
NULL returned back to the user is best way to recover.
>
> I think the right thing here is to limit the size, though I'm not
> really sure what the limit should be.
And I still think that NOWARN is the best solution here.
Thanks
>
> Jason
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning
2025-03-19 12:42 [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning Leon Romanovsky
2025-03-19 17:23 ` Jason Gunthorpe
@ 2025-04-09 18:32 ` Leon Romanovsky
1 sibling, 0 replies; 8+ messages in thread
From: Leon Romanovsky @ 2025-04-09 18:32 UTC (permalink / raw)
To: Jason Gunthorpe, Leon Romanovsky; +Cc: Shay Drory, linux-rdma
On Wed, 19 Mar 2025 14:42:21 +0200, Leon Romanovsky wrote:
> syzkaller triggered an oversized kvmalloc() warning.
> Silence it by adding __GFP_NOWARN.
>
> syzkaller log:
> WARNING: CPU: 7 PID: 518 at mm/util.c:665 __kvmalloc_node_noprof+0x175/0x180
> CPU: 7 UID: 0 PID: 518 Comm: c_repro Not tainted 6.11.0-rc6+ #6
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.13.0-0-gf21b5a4aeb02-prebuilt.qemu.org 04/01/2014
> RIP: 0010:__kvmalloc_node_noprof+0x175/0x180
> RSP: 0018:ffffc90001e67c10 EFLAGS: 00010246
> RAX: 0000000000000100 RBX: 0000000000000400 RCX: ffffffff8149d46b
> RDX: 0000000000000000 RSI: ffff8881030fae80 RDI: 0000000000000002
> RBP: 000000712c800000 R08: 0000000000000100 R09: 0000000000000000
> R10: ffffc90001e67c10 R11: 0030ae0601000000 R12: 0000000000000000
> R13: 0000000000000000 R14: 00000000ffffffff R15: 0000000000000000
> FS: 00007fde79159740(0000) GS:ffff88813bdc0000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 0000000020000180 CR3: 0000000105eb4005 CR4: 00000000003706b0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> ib_umem_odp_get+0x1f6/0x390
> mlx5_ib_reg_user_mr+0x1e8/0x450
> ib_uverbs_reg_mr+0x28b/0x440
> ib_uverbs_write+0x7d3/0xa30
> vfs_write+0x1ac/0x6c0
> ksys_write+0x134/0x170
> ? __sanitizer_cov_trace_pc+0x1c/0x50
> do_syscall_64+0x50/0x110
> entry_SYSCALL_64_after_hwframe+0x76/0x7e
>
> [...]
Applied, thanks!
[1/1] RDMA/core: Silence oversized kvmalloc() warning
https://git.kernel.org/rdma/rdma/c/9a0e6f15029e1a
Best regards,
--
Leon Romanovsky <leon@kernel.org>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2025-04-09 18:32 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-19 12:42 [PATCH rdma-next] RDMA/core: Silence oversized kvmalloc() warning Leon Romanovsky
2025-03-19 17:23 ` Jason Gunthorpe
2025-03-26 10:58 ` Leon Romanovsky
2025-03-31 17:45 ` Jason Gunthorpe
2025-03-31 19:04 ` Leon Romanovsky
2025-04-01 16:35 ` Jason Gunthorpe
2025-04-03 10:30 ` Leon Romanovsky
2025-04-09 18:32 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox