lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <202109291111.31671B6A6@keescook>
Date:   Wed, 29 Sep 2021 11:12:22 -0700
From:   Kees Cook <keescook@...omium.org>
To:     Yafang Shao <laoar.shao@...il.com>
Cc:     akpm@...ux-foundation.org, pmladek@...e.com, peterz@...radead.org,
        valentin.schneider@....com, mathieu.desnoyers@...icios.com,
        qiang.zhang@...driver.com, robdclark@...omium.org,
        viro@...iv.linux.org.uk, christian@...uner.io,
        dietmar.eggemann@....com, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 3/5] kernel/sched: improve the BUILD_BUG_ON() in
 get_task_comm()

On Wed, Sep 29, 2021 at 11:50:34AM +0000, Yafang Shao wrote:
> What we really want to guarantee is that the buf size can't be less than
> TASK_COMM_LEN. While the size be greater than TASK_COMM_LEN is
> acceptable.

This makes sense when task_struct::comm is a pointer. (But I think it's
not a good idea to do that.)

-Kees

> 
> Signed-off-by: Yafang Shao <laoar.shao@...il.com>
> ---
>  include/linux/sched.h | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/include/linux/sched.h b/include/linux/sched.h
> index b387b5943db4..959eaef248fc 100644
> --- a/include/linux/sched.h
> +++ b/include/linux/sched.h
> @@ -1931,7 +1931,7 @@ static inline void set_task_comm(struct task_struct *tsk, const char *from)
>  
>  extern char *__get_task_comm(char *to, size_t len, struct task_struct *tsk);
>  #define get_task_comm(buf, tsk) ({			\
> -	BUILD_BUG_ON(sizeof(buf) != TASK_COMM_LEN);	\
> +	BUILD_BUG_ON(sizeof(buf) < TASK_COMM_LEN);	\
>  	__get_task_comm(buf, sizeof(buf), tsk);		\
>  })
>  
> -- 
> 2.17.1
> 

-- 
Kees Cook

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ