unix: Fix nil dereference in find_queuer_for

Submitted by Cyrill Gorcunov on March 22, 2018, 1:39 p.m.

Details

Message ID 20180322133934.26441-1-gorcunov@virtuozzo.com
State Accepted
Series "unix: Fix nil dereference in find_queuer_for"
Commit 9fda2acb8f9d1e56447841fce27226e9689121ea
Headers show

Commit Message

Cyrill Gorcunov March 22, 2018, 1:39 p.m.
When walking over unix sockets make sure the
queuer is present before accessing it.

https://jira.sw.ru/browse/PSBM-82796

Reported-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
---
 criu/sk-unix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/criu/sk-unix.c b/criu/sk-unix.c
index 7f743a9b1..4d1f296f9 100644
--- a/criu/sk-unix.c
+++ b/criu/sk-unix.c
@@ -958,7 +958,7 @@  static struct unix_sk_info *find_queuer_for(int id)
 	struct unix_sk_info *ui;
 
 	list_for_each_entry(ui, &unix_sockets, list) {
-		if (ui->queuer->ue->id == id)
+		if (ui->queuer && ui->queuer->ue->id == id)
 			return ui;
 	}
 

Comments

Kirill Tkhai March 22, 2018, 1:52 p.m.
On 22.03.2018 16:39, Cyrill Gorcunov wrote:
> When walking over unix sockets make sure the
> queuer is present before accessing it.
> 
> https://jira.sw.ru/browse/PSBM-82796
> 
> Reported-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>

Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>

> ---
>  criu/sk-unix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 7f743a9b1..4d1f296f9 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -958,7 +958,7 @@ static struct unix_sk_info *find_queuer_for(int id)
>  	struct unix_sk_info *ui;
>  
>  	list_for_each_entry(ui, &unix_sockets, list) {
> -		if (ui->queuer->ue->id == id)
> +		if (ui->queuer && ui->queuer->ue->id == id)
>  			return ui;
>  	}
>  
>
Andrey Vagin March 22, 2018, 9:48 p.m.
Applied, thanks

On Thu, Mar 22, 2018 at 04:39:34PM +0300, Cyrill Gorcunov wrote:
> When walking over unix sockets make sure the
> queuer is present before accessing it.
> 
> https://jira.sw.ru/browse/PSBM-82796
> 
> Reported-by: Vitaly Ostrosablin <vostrosablin@virtuozzo.com>
> Signed-off-by: Cyrill Gorcunov <gorcunov@virtuozzo.com>
> ---
>  criu/sk-unix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/criu/sk-unix.c b/criu/sk-unix.c
> index 7f743a9b1..4d1f296f9 100644
> --- a/criu/sk-unix.c
> +++ b/criu/sk-unix.c
> @@ -958,7 +958,7 @@ static struct unix_sk_info *find_queuer_for(int id)
>  	struct unix_sk_info *ui;
>  
>  	list_for_each_entry(ui, &unix_sockets, list) {
> -		if (ui->queuer->ue->id == id)
> +		if (ui->queuer && ui->queuer->ue->id == id)
>  			return ui;
>  	}
>  
> -- 
> 2.14.3
>