Re: [PATCH bpf-next] samples/bpf: Don't use uninitialized cg2 variable

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jul 20, 2022 at 08:53:36PM +0000, Daniel Müller wrote:
> When the setup_cgroup_environment function returns false, we enter a
> cleanup path that uses the cg2 variable, which, at this point, is not
> initialized.
> This change fixes the issue by introducing a new error label that does
> not perform the close operation which uses said variable on this path.
> 
> Signed-off-by: Daniel Müller <deso@xxxxxxxxxx>
> ---
>  samples/bpf/test_current_task_under_cgroup_user.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/samples/bpf/test_current_task_under_cgroup_user.c b/samples/bpf/test_current_task_under_cgroup_user.c
> index ac251a..04a37f 100644
> --- a/samples/bpf/test_current_task_under_cgroup_user.c
> +++ b/samples/bpf/test_current_task_under_cgroup_user.c
> @@ -55,7 +55,7 @@ int main(int argc, char **argv)
>  	}
>  
>  	if (setup_cgroup_environment())
> -		goto err;
> +		goto err_cgroup;
>  
>  	cg2 = create_and_get_cgroup(CGROUP_PATH);
>  
> @@ -104,6 +104,7 @@ int main(int argc, char **argv)
>  
>  err:
>  	close(cg2);
> +err_cgroup:
>  	cleanup_cgroup_environment();
>  
>  cleanup:
> -- 
> 2.30.2
> 

I see that I may have jumped the gun here. We probably shouldn't be cleaning up
the cgroup environment when the setup failed. Will update the patch.

Thanks,
Daniel



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux