* [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem
@ 2020-11-10 6:32 Haotian Li
2020-11-10 6:35 ` [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func Haotian Li
` (2 more replies)
0 siblings, 3 replies; 6+ messages in thread
From: Haotian Li @ 2020-11-10 6:32 UTC (permalink / raw)
To: qemu-devel, virtio-fs; +Cc: linfeilong, liuzhiqiang26
Haotian Li (2):
tools/virtiofsd/buffer.c: check whether buf is NULL in
fuse_bufvec_advance func
virtiofsd/passthrough_ll.c: check whether lo_map_reserve returns NULL
in main func
tools/virtiofsd/buffer.c | 4 ++++
tools/virtiofsd/passthrough_ll.c | 10 +++++++++-
2 files changed, 13 insertions(+), 1 deletion(-)
--
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func
2020-11-10 6:32 [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Haotian Li
@ 2020-11-10 6:35 ` Haotian Li
2020-11-10 6:37 ` [PATCH 2/2] virtiofsd: check whether lo_map_reserve returns NULL in main func Haotian Li
2020-11-10 11:45 ` [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Stefan Hajnoczi
2 siblings, 0 replies; 6+ messages in thread
From: Haotian Li @ 2020-11-10 6:35 UTC (permalink / raw)
To: qemu-devel, virtio-fs; +Cc: linfeilong, liuzhiqiang26
In fuse_bufvec_advance func, calling fuse_bufvec_current func
may return NULL, so we should check whether buf is NULL before
using it.
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
tools/virtiofsd/buffer.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/tools/virtiofsd/buffer.c b/tools/virtiofsd/buffer.c
index 27c1377f22..bdc608c221 100644
--- a/tools/virtiofsd/buffer.c
+++ b/tools/virtiofsd/buffer.c
@@ -246,6 +246,10 @@ static int fuse_bufvec_advance(struct fuse_bufvec *bufv, size_t len)
{
const struct fuse_buf *buf = fuse_bufvec_current(bufv);
+ if (!buf) {
+ return 0;
+ }
+
bufv->off += len;
assert(bufv->off <= buf->size);
if (bufv->off == buf->size) {
--
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [PATCH 2/2] virtiofsd: check whether lo_map_reserve returns NULL in main func
2020-11-10 6:32 [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Haotian Li
2020-11-10 6:35 ` [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func Haotian Li
@ 2020-11-10 6:37 ` Haotian Li
2020-11-10 11:45 ` [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Stefan Hajnoczi
2 siblings, 0 replies; 6+ messages in thread
From: Haotian Li @ 2020-11-10 6:37 UTC (permalink / raw)
To: qemu-devel, virtio-fs; +Cc: linfeilong, liuzhiqiang26
In main func, func lo_map_reserve is called without NULL check.
If reallocing new_elems fails in func lo_map_grow, the func
lo_map_reserve may return NULL. We should check whether
lo_map_reserve returns NULL before using it.
Signed-off-by: Haotian Li <lihaotian9@huawei.com>
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
---
tools/virtiofsd/passthrough_ll.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/tools/virtiofsd/passthrough_ll.c b/tools/virtiofsd/passthrough_ll.c
index ec1008bceb..0c279ff9fb 100644
--- a/tools/virtiofsd/passthrough_ll.c
+++ b/tools/virtiofsd/passthrough_ll.c
@@ -3433,6 +3433,7 @@ int main(int argc, char *argv[])
.proc_self_fd = -1,
};
struct lo_map_elem *root_elem;
+ struct lo_map_elem *reserve_elem;
int ret = -1;
/* Don't mask creation mode, kernel already did that */
@@ -3452,8 +3453,15 @@ int main(int argc, char *argv[])
* [1] Root inode
*/
lo_map_init(&lo.ino_map);
- lo_map_reserve(&lo.ino_map, 0)->in_use = false;
+ reserve_elem = lo_map_reserve(&lo.ino_map, 0);
+ if (!reserve_elem) {
+ goto err_out1;
+ }
+ reserve_elem->in_use = false;
root_elem = lo_map_reserve(&lo.ino_map, lo.root.fuse_ino);
+ if (!root_elem) {
+ goto err_out1;
+ }
root_elem->inode = &lo.root;
lo_map_init(&lo.dirp_map);
--
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem
2020-11-10 6:32 [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Haotian Li
2020-11-10 6:35 ` [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func Haotian Li
2020-11-10 6:37 ` [PATCH 2/2] virtiofsd: check whether lo_map_reserve returns NULL in main func Haotian Li
@ 2020-11-10 11:45 ` Stefan Hajnoczi
2020-11-10 13:06 ` Zhiqiang Liu
2020-11-10 13:10 ` Haotian Li
2 siblings, 2 replies; 6+ messages in thread
From: Stefan Hajnoczi @ 2020-11-10 11:45 UTC (permalink / raw)
To: Haotian Li; +Cc: virtio-fs, linfeilong, qemu-devel
[-- Attachment #1: Type: text/plain, Size: 599 bytes --]
On Tue, Nov 10, 2020 at 02:32:17PM +0800, Haotian Li wrote:
> Haotian Li (2):
> tools/virtiofsd/buffer.c: check whether buf is NULL in
> fuse_bufvec_advance func
> virtiofsd/passthrough_ll.c: check whether lo_map_reserve returns NULL
> in main func
>
> tools/virtiofsd/buffer.c | 4 ++++
> tools/virtiofsd/passthrough_ll.c | 10 +++++++++-
> 2 files changed, 13 insertions(+), 1 deletion(-)
Please consider printing an error message in Patch 2 so that users can
easily tell why the program refused to start.
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem
2020-11-10 11:45 ` [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Stefan Hajnoczi
@ 2020-11-10 13:06 ` Zhiqiang Liu
2020-11-10 13:10 ` Haotian Li
1 sibling, 0 replies; 6+ messages in thread
From: Zhiqiang Liu @ 2020-11-10 13:06 UTC (permalink / raw)
To: Stefan Hajnoczi, Haotian Li
Cc: virtio-fs, linfeilong, qemu-devel, liuzhiqiang26
On 2020/11/10 19:45, Stefan Hajnoczi wrote:
> On Tue, Nov 10, 2020 at 02:32:17PM +0800, Haotian Li wrote:
>> Haotian Li (2):
>> tools/virtiofsd/buffer.c: check whether buf is NULL in
>> fuse_bufvec_advance func
>> virtiofsd/passthrough_ll.c: check whether lo_map_reserve returns NULL
>> in main func
>>
>> tools/virtiofsd/buffer.c | 4 ++++
>> tools/virtiofsd/passthrough_ll.c | 10 +++++++++-
>> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> Please consider printing an error message in Patch 2 so that users can
> easily tell why the program refused to start.
>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>
Thanks for your review.
We will add error message in Patch2, and then send the v3-patch series.
Regards
Zhiqiang Liu.
>
> _______________________________________________
> Virtio-fs mailing list
> Virtio-fs@redhat.com
> https://www.redhat.com/mailman/listinfo/virtio-fs
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem
2020-11-10 11:45 ` [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Stefan Hajnoczi
2020-11-10 13:06 ` Zhiqiang Liu
@ 2020-11-10 13:10 ` Haotian Li
1 sibling, 0 replies; 6+ messages in thread
From: Haotian Li @ 2020-11-10 13:10 UTC (permalink / raw)
To: Stefan Hajnoczi; +Cc: virtio-fs, linfeilong, qemu-devel
Thanks for your suggestion. New patches will be resent.
> On Tue, Nov 10, 2020 at 02:32:17PM +0800, Haotian Li wrote:
>> Haotian Li (2):
>> tools/virtiofsd/buffer.c: check whether buf is NULL in
>> fuse_bufvec_advance func
>> virtiofsd/passthrough_ll.c: check whether lo_map_reserve returns NULL
>> in main func
>>
>> tools/virtiofsd/buffer.c | 4 ++++
>> tools/virtiofsd/passthrough_ll.c | 10 +++++++++-
>> 2 files changed, 13 insertions(+), 1 deletion(-)
>
> Please consider printing an error message in Patch 2 so that users can
> easily tell why the program refused to start.
>
> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-11-10 14:50 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-11-10 6:32 [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Haotian Li
2020-11-10 6:35 ` [PATCH 1/2] tools/virtiofsd/buffer.c: check whether buf is NULL in fuse_bufvec_advance func Haotian Li
2020-11-10 6:37 ` [PATCH 2/2] virtiofsd: check whether lo_map_reserve returns NULL in main func Haotian Li
2020-11-10 11:45 ` [Virtio-fs] [PATCH v2 0/2] virtiofsd: fix some accessing NULL pointer problem Stefan Hajnoczi
2020-11-10 13:06 ` Zhiqiang Liu
2020-11-10 13:10 ` Haotian Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).