Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1630227 > unrolled thread
| Started by | Heloise <os@iscas.ac.cn> |
|---|---|
| First post | 2017-04-25 09:00 +0200 |
| Last post | 2017-04-25 09:10 +0200 |
| Articles | 2 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference Heloise <os@iscas.ac.cn> - 2017-04-25 09:00 +0200
Re: [PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference Lars Ellenberg <lars.ellenberg@linbit.com> - 2017-04-25 09:10 +0200
| From | Heloise <os@iscas.ac.cn> |
|---|---|
| Date | 2017-04-25 09:00 +0200 |
| Subject | [PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference |
| Message-ID | <tA2C6-1bC-11@gated-at.bofh.it> |
Signed-off-by: Heloise <os@iscas.ac.cn> In is_valid_state(), there is NULL validation for the variable nc "if (nc)". However,the code will continue to execute when nc is NULL. nc->verify_alg[0] is used in subsequent code, which may cause null-pointer dereference, fix it. --- drivers/block/drbd/drbd_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c index eea0c4a..1963b83 100644 --- a/drivers/block/drbd/drbd_state.c +++ b/drivers/block/drbd/drbd_state.c @@ -845,7 +845,7 @@ is_valid_state(struct drbd_device *device, union drbd_state ns) rv = SS_CONNECTED_OUTDATES; else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && - (nc->verify_alg[0] == 0)) + (nc != NULL && nc->verify_alg[0] == 0)) rv = SS_NO_VERIFY_ALG; else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) && -- 2.1.0
[toc] | [next] | [standalone]
| From | Lars Ellenberg <lars.ellenberg@linbit.com> |
|---|---|
| Date | 2017-04-25 09:10 +0200 |
| Subject | Re: [PATCH] drivers:block:drbd:drbd_state:fix null-pointer dereference |
| Message-ID | <tA2LM-1un-13@gated-at.bofh.it> |
| In reply to | #1630227 |
On Mon, Apr 24, 2017 at 11:35:18PM -0700, Heloise wrote:
> Signed-off-by: Heloise <os@iscas.ac.cn>
>
> In is_valid_state(), there is NULL validation for the variable nc
> "if (nc)". However,the code will continue to execute when nc is NULL.
> nc->verify_alg[0] is used in subsequent code, which may cause
> null-pointer dereference, fix it.
> ---
> drivers/block/drbd/drbd_state.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/block/drbd/drbd_state.c b/drivers/block/drbd/drbd_state.c
> index eea0c4a..1963b83 100644
> --- a/drivers/block/drbd/drbd_state.c
> +++ b/drivers/block/drbd/drbd_state.c
> @@ -845,7 +845,7 @@ is_valid_state(struct drbd_device *device, union drbd_state ns)
> rv = SS_CONNECTED_OUTDATES;
>
> else if ((ns.conn == C_VERIFY_S || ns.conn == C_VERIFY_T) &&
> - (nc->verify_alg[0] == 0))
> + (nc != NULL && nc->verify_alg[0] == 0))
What the static checker cannot know:
ns.conn != C_STANDALONE implies nc != NULL.
But if you feel like it, the additional check won't hurt.
Thanks,
Lars
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web