This patchset mainly fixed the cifs_write_from_iter function, it execution failure caused pagevec kmemleak problem, the previous round of the mainline patch automatically adapted the error, adjusted the fixcode position.
Zhang Xiaoxu (1): cifs: Fix pages leak when writedata alloc failed in cifs_write_from_iter()
Zizhi Wo (1): Revert "[Backport] cifs: Fix pages leak when writedata alloc failed in cifs_write_from_iter()"
Offering: HULK hulk inclusion category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAO0ER
--------------------------------
This reverts commit 9f14fd51e077 ("cifs: Fix pages leak when writedata alloc failed in cifs_write_from_iter()").
In cifs_write_from_iter(), pagevec should not be released when it is not initialized. The release should occur only after the pagevec has been properly initialized. Rolled back the improperly adapted patch first.
Fixes: 9f14fd51e077 ("cifs: Fix pages leak when writedata alloc failed in cifs_write_from_iter()") Signed-off-by: Zizhi Wo wozizhi@huawei.com --- fs/cifs/file.c | 3 --- 1 file changed, 3 deletions(-)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index dc7175b75c26..d908eba024f0 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2988,9 +2988,6 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, cifs_uncached_writev_complete); if (!wdata) { rc = -ENOMEM; - for (i = 0; i < nr_pages; i++) - put_page(pagevec[i]); - kvfree(pagevec); add_credits_and_wake_if(server, credits, 0); break; }
From: Zhang Xiaoxu zhangxiaoxu5@huawei.com
mainline inclusion from mainline-v6.1-rc3 commit f950c85e782f90702468bba8243cc97a8d0d04b0 category: bugfix bugzilla: https://gitee.com/openeuler/kernel/issues/IAO0ER
Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?i...
--------------------------------
There is a kmemleak when writedata alloc failed:
unreferenced object 0xffff888175ae4000 (size 4096): comm "dd", pid 19419, jiffies 4296028749 (age 739.396s) hex dump (first 32 bytes): 80 02 b0 04 00 ea ff ff c0 02 b0 04 00 ea ff ff ................ 80 22 4c 04 00 ea ff ff c0 22 4c 04 00 ea ff ff ."L......"L..... backtrace: [<0000000072fdbb86>] __kmalloc_node+0x50/0x150 [<0000000039faf56f>] __iov_iter_get_pages_alloc+0x605/0xdd0 [<00000000f862a9d4>] iov_iter_get_pages_alloc2+0x3b/0x80 [<000000008f226067>] cifs_write_from_iter+0x2ae/0xe40 [<000000001f78f2f1>] __cifs_writev+0x337/0x5c0 [<00000000257fcef5>] vfs_write+0x503/0x690 [<000000008778a238>] ksys_write+0xb9/0x150 [<00000000ed82047c>] do_syscall_64+0x35/0x80 [<000000003365551d>] entry_SYSCALL_64_after_hwframe+0x46/0xb0
__iov_iter_get_pages_alloc+0x605/0xdd0 is: want_pages_array at lib/iov_iter.c:1304 (inlined by) __iov_iter_get_pages_alloc at lib/iov_iter.c:1457
If writedata allocate failed, the pages and pagevec should be cleanup.
Fixes: 8c5f9c1ab7cb ("CIFS: Add support for direct I/O write") Reviewed-by: Paulo Alcantara (SUSE) pc@cjr.nz Signed-off-by: Zhang Xiaoxu zhangxiaoxu5@huawei.com Signed-off-by: Steve French stfrench@microsoft.com Signed-off-by: Zizhi Wo wozizhi@huawei.com --- fs/cifs/file.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index d908eba024f0..dc7175b75c26 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -2988,6 +2988,9 @@ cifs_write_from_iter(loff_t offset, size_t len, struct iov_iter *from, cifs_uncached_writev_complete); if (!wdata) { rc = -ENOMEM; + for (i = 0; i < nr_pages; i++) + put_page(pagevec[i]); + kvfree(pagevec); add_credits_and_wake_if(server, credits, 0); break; }
反馈: 您发送到kernel@openeuler.org的补丁/补丁集,已成功转换为PR! PR链接地址: https://gitee.com/openeuler/kernel/pulls/11307 邮件列表地址:https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...
FeedBack: The patch(es) which you have sent to kernel@openeuler.org mailing list has been converted to a pull request successfully! Pull request link: https://gitee.com/openeuler/kernel/pulls/11307 Mailing list address: https://mailweb.openeuler.org/hyperkitty/list/kernel@openeuler.org/message/D...