From: Suman Anna <hidden> Date: 2020-02-24 21:26:56
The functions vring_new_virtqueue() and __vring_new_virtqueue() are used
with split rings, and any allocations within these functions are managed
outside of the .we_own_ring flag. The commit cbeedb72b97a ("virtio_ring:
allocate desc state for split ring separately") allocates the desc state
within the __vring_new_virtqueue() but frees it only when the .we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring separately")
Signed-off-by: Suman Anna <redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
From: Jason Wang <hidden> Date: 2020-02-25 05:40:06
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted hunk
The functions vring_new_virtqueue() and __vring_new_virtqueue() are used
with split rings, and any allocations within these functions are managed
outside of the .we_own_ring flag. The commit cbeedb72b97a ("virtio_ring:
allocate desc state for split ring separately") allocates the desc state
within the __vring_new_virtqueue() but frees it only when the .we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring separately")
Signed-off-by: Suman Anna <redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
Anyway desc_state will be allocated by use even if !we_own_ring.
Thanks
From: Suman Anna <hidden> Date: 2020-02-25 19:51:38
Hi Jason,
On 2/24/20 11:39 PM, Jason Wang wrote:
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted
The functions vring_new_virtqueue() and __vring_new_virtqueue() are used
with split rings, and any allocations within these functions are managed
outside of the .we_own_ring flag. The commit cbeedb72b97a ("virtio_ring:
allocate desc state for split ring separately") allocates the desc state
within the __vring_new_virtqueue() but frees it only when the
.we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring
separately")
Signed-off-by: Suman Anna <redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
OK, are you sure you want that to be folded into this patch? It looks to
me a separate cleanup/consolidation patch, and packed desc_state does
not suffer this memleak, and need not be backported into stable kernels.
regards
Suman
Anyway desc_state will be allocated by use even if !we_own_ring.
Thanks
From: Jason Wang <hidden> Date: 2020-02-26 03:14:20
On 2020/2/26 上午12:51, Suman Anna wrote:
Hi Jason,
On 2/24/20 11:39 PM, Jason Wang wrote:
quoted
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted
The functions vring_new_virtqueue() and __vring_new_virtqueue() are used
with split rings, and any allocations within these functions are managed
outside of the .we_own_ring flag. The commit cbeedb72b97a ("virtio_ring:
allocate desc state for split ring separately") allocates the desc state
within the __vring_new_virtqueue() but frees it only when the
.we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring
separately")
Signed-off-by: Suman Anna<redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
OK, are you sure you want that to be folded into this patch? It looks to
me a separate cleanup/consolidation patch, and packed desc_state does
not suffer this memleak, and need not be backported into stable kernels.
regards
Suman
Though it's just a small tweak, I'm fine for leaving it for future.
So
Acked-by: Jason Wang <redacted>
Thanks
From: Suman Anna <hidden> Date: 2020-02-26 17:01:55
On 2/25/20 9:13 PM, Jason Wang wrote:
On 2020/2/26 上午12:51, Suman Anna wrote:
quoted
Hi Jason,
On 2/24/20 11:39 PM, Jason Wang wrote:
quoted
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted
The functions vring_new_virtqueue() and __vring_new_virtqueue() are
used
with split rings, and any allocations within these functions are
managed
outside of the .we_own_ring flag. The commit cbeedb72b97a
("virtio_ring:
allocate desc state for split ring separately") allocates the desc
state
within the __vring_new_virtqueue() but frees it only when the
.we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring
separately")
Signed-off-by: Suman Anna<redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c
b/drivers/virtio/virtio_ring.c
index 867c7ebd3f10..58b96baa8d48 100644
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
OK, are you sure you want that to be folded into this patch? It looks to
me a separate cleanup/consolidation patch, and packed desc_state does
not suffer this memleak, and need not be backported into stable kernels.
regards
Suman
Though it's just a small tweak, I'm fine for leaving it for future.
So
Acked-by: Jason Wang <redacted>
Thanks Jason, will post a patch for the same once this is merged.
regards
Suman
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
From: Suman Anna <hidden> Date: 2020-03-06 00:28:07
On 2/25/20 9:13 PM, Jason Wang wrote:
On 2020/2/26 上午12:51, Suman Anna wrote:
quoted
Hi Jason,
On 2/24/20 11:39 PM, Jason Wang wrote:
quoted
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted
The functions vring_new_virtqueue() and __vring_new_virtqueue() are
used
with split rings, and any allocations within these functions are
managed
outside of the .we_own_ring flag. The commit cbeedb72b97a
("virtio_ring:
allocate desc state for split ring separately") allocates the desc
state
within the __vring_new_virtqueue() but frees it only when the
.we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring
separately")
Signed-off-by: Suman Anna<redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c
b/drivers/virtio/virtio_ring.c
index 867c7ebd3f10..58b96baa8d48 100644
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
OK, are you sure you want that to be folded into this patch? It looks to
me a separate cleanup/consolidation patch, and packed desc_state does
not suffer this memleak, and need not be backported into stable kernels.
regards
Suman
Though it's just a small tweak, I'm fine for leaving it for future.
So
Acked-by: Jason Wang <redacted>
Mike,
Ping on this. I don't see the patch in -next yet. Can we get this into
the current -rc please?
regards
Suman
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
From: "Michael S. Tsirkin" <mst@redhat.com> Date: 2020-03-08 07:58:24
On Thu, Mar 05, 2020 at 06:27:53PM -0600, Suman Anna wrote:
On 2/25/20 9:13 PM, Jason Wang wrote:
quoted
On 2020/2/26 上午12:51, Suman Anna wrote:
quoted
Hi Jason,
On 2/24/20 11:39 PM, Jason Wang wrote:
quoted
On 2020/2/25 上午5:26, Suman Anna wrote:
quoted
The functions vring_new_virtqueue() and __vring_new_virtqueue() are
used
with split rings, and any allocations within these functions are
managed
outside of the .we_own_ring flag. The commit cbeedb72b97a
("virtio_ring:
allocate desc state for split ring separately") allocates the desc
state
within the __vring_new_virtqueue() but frees it only when the
.we_own_ring
flag is set. This leads to a memory leak when freeing such allocated
virtqueues with the vring_del_virtqueue() function.
Fix this by moving the desc_state free code outside the flag and only
for split rings. Issue was discovered during testing with remoteproc
and virtio_rpmsg.
Fixes: cbeedb72b97a ("virtio_ring: allocate desc state for split ring
separately")
Signed-off-by: Suman Anna<redacted>
---
drivers/virtio/virtio_ring.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/virtio/virtio_ring.c
b/drivers/virtio/virtio_ring.c
index 867c7ebd3f10..58b96baa8d48 100644
Nitpick, it looks to me it would be more clear if we just free
desc_state unconditionally here (and remove the kfree for packed above).
OK, are you sure you want that to be folded into this patch? It looks to
me a separate cleanup/consolidation patch, and packed desc_state does
not suffer this memleak, and need not be backported into stable kernels.
regards
Suman
Though it's just a small tweak, I'm fine for leaving it for future.
So
Acked-by: Jason Wang <redacted>
Mike,
Ping on this. I don't see the patch in -next yet. Can we get this into
the current -rc please?
regards
Suman