* [PATCH] libceph: Avoid a NULL pointer dereference
@ 2019-03-14 21:17 Aditya Pakki
2019-03-15 11:24 ` Luis Henriques
0 siblings, 1 reply; 3+ messages in thread
From: Aditya Pakki @ 2019-03-14 21:17 UTC (permalink / raw)
To: pakki001
Cc: kjlu, Ilya Dryomov, Yan, Zheng, Sage Weil, David S. Miller,
ceph-devel, netdev, linux-kernel
kmalloc allocates memory for dest->name and attempts to call
memcpy without a check for failure. This patch avoids such a scenario.
Signed-off-by: Aditya Pakki <pakki001@umn.edu>
---
net/ceph/osdmap.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
index 48a31dc9161c..c76a7c7e6a77 100644
--- a/net/ceph/osdmap.c
+++ b/net/ceph/osdmap.c
@@ -1901,6 +1901,8 @@ void ceph_oid_copy(struct ceph_object_id *dest,
} else {
dest->name = dest->inline_name;
}
+ if (!dest->name)
+ return;
memcpy(dest->name, src->name, src->name_len + 1);
dest->name_len = src->name_len;
}
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libceph: Avoid a NULL pointer dereference
2019-03-14 21:17 [PATCH] libceph: Avoid a NULL pointer dereference Aditya Pakki
@ 2019-03-15 11:24 ` Luis Henriques
0 siblings, 0 replies; 3+ messages in thread
From: Luis Henriques @ 2019-03-15 11:24 UTC (permalink / raw)
To: Aditya Pakki
Cc: kjlu, Ilya Dryomov, Yan, Zheng, Sage Weil, David S. Miller,
ceph-devel, netdev, linux-kernel
Aditya Pakki <pakki001@umn.edu> writes:
> kmalloc allocates memory for dest->name and attempts to call
> memcpy without a check for failure. This patch avoids such a scenario.
Since kmalloc is being invoked with the __GFP_NOFAIL flag, it will never
fail. Thus, there's no point in checking for NULL in this case.
Cheers,
--
Luis
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> net/ceph/osdmap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
> index 48a31dc9161c..c76a7c7e6a77 100644
> --- a/net/ceph/osdmap.c
> +++ b/net/ceph/osdmap.c
> @@ -1901,6 +1901,8 @@ void ceph_oid_copy(struct ceph_object_id *dest,
> } else {
> dest->name = dest->inline_name;
> }
> + if (!dest->name)
> + return;
> memcpy(dest->name, src->name, src->name_len + 1);
> dest->name_len = src->name_len;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libceph: Avoid a NULL pointer dereference
@ 2019-03-15 11:24 ` Luis Henriques
0 siblings, 0 replies; 3+ messages in thread
From: Luis Henriques @ 2019-03-15 11:24 UTC (permalink / raw)
To: Aditya Pakki
Cc: kjlu, Ilya Dryomov, Yan, Zheng, Sage Weil, David S. Miller,
ceph-devel, netdev, linux-kernel
Aditya Pakki <pakki001@umn.edu> writes:
> kmalloc allocates memory for dest->name and attempts to call
> memcpy without a check for failure. This patch avoids such a scenario.
Since kmalloc is being invoked with the __GFP_NOFAIL flag, it will never
fail. Thus, there's no point in checking for NULL in this case.
Cheers,
--
Luis
>
> Signed-off-by: Aditya Pakki <pakki001@umn.edu>
> ---
> net/ceph/osdmap.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c
> index 48a31dc9161c..c76a7c7e6a77 100644
> --- a/net/ceph/osdmap.c
> +++ b/net/ceph/osdmap.c
> @@ -1901,6 +1901,8 @@ void ceph_oid_copy(struct ceph_object_id *dest,
> } else {
> dest->name = dest->inline_name;
> }
> + if (!dest->name)
> + return;
> memcpy(dest->name, src->name, src->name_len + 1);
> dest->name_len = src->name_len;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-03-15 11:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-14 21:17 [PATCH] libceph: Avoid a NULL pointer dereference Aditya Pakki
2019-03-15 11:24 ` Luis Henriques
2019-03-15 11:24 ` Luis Henriques
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.