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: <CAGXu5j+=7wAsJpUwAsPK_AMzhLduhBGpdQm9oqqbt3bzoQOMDQ@mail.gmail.com>
Date:   Tue, 5 Dec 2017 11:19:18 -0800
From:   Kees Cook <keescook@...omium.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Mark Fasheh <mfasheh@...sity.com>,
        Joel Becker <jlbec@...lplan.org>,
        Andrew Morton <akpm@...ux-foundation.org>,
        Ingo Molnar <mingo@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>,
        Joseph Qi <jiangqi903@...il.com>, piaojun <piaojun@...wei.com>,
        ocfs2-devel@....oracle.com, LKML <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH] ocfs2: use get_task_comm

On Tue, Dec 5, 2017 at 7:20 AM, Arnd Bergmann <arnd@...db.de> wrote:
> While reviewing all callers of get_task_comm(), I stumbled
> over this one that claimed it was not exported, when in fact
> it is. Accessing task->comm directly is not safe, so better
> convert this one to using get_task_comm as well.

Using get_task_comm() in cases like this is actually overkill (i.e.
using up stack space), since there's (currently) no benefit. Nothing
protects getting a "correct" view of task->comm (i.e. it could get
updated in the middle of a copy), but it _is_ always NULL terminated,
so it's safe to use with %s like this. While it does make me slightly
uncomfortable to _depend_ on this NULL termination, but there are lots
of open-coded %s users of task->comm. When we're trying to save a
_copy_ of task->comm, then we want get_task_comm(), just to make sure
we're doing it right.

So, while I don't oppose this patch, it might be seen as a wasteful
use of stack space.

-Kees

>
> Signed-off-by: Arnd Bergmann <arnd@...db.de>
> ---
>  fs/ocfs2/cluster/netdebug.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/fs/ocfs2/cluster/netdebug.c b/fs/ocfs2/cluster/netdebug.c
> index 74a21f6695c8..a51d001b89b1 100644
> --- a/fs/ocfs2/cluster/netdebug.c
> +++ b/fs/ocfs2/cluster/netdebug.c
> @@ -130,6 +130,7 @@ static void *nst_seq_next(struct seq_file *seq, void *v, loff_t *pos)
>  static int nst_seq_show(struct seq_file *seq, void *v)
>  {
>         struct o2net_send_tracking *nst, *dummy_nst = seq->private;
> +       char comm[TASK_COMM_LEN];
>         ktime_t now;
>         s64 sock, send, status;
>
> @@ -142,8 +143,8 @@ static int nst_seq_show(struct seq_file *seq, void *v)
>         sock = ktime_to_us(ktime_sub(now, nst->st_sock_time));
>         send = ktime_to_us(ktime_sub(now, nst->st_send_time));
>         status = ktime_to_us(ktime_sub(now, nst->st_status_time));
> +       get_task_comm(comm, nst->st_task);
>
> -       /* get_task_comm isn't exported.  oh well. */
>         seq_printf(seq, "%p:\n"
>                    "  pid:          %lu\n"
>                    "  tgid:         %lu\n"
> @@ -158,7 +159,7 @@ static int nst_seq_show(struct seq_file *seq, void *v)
>                    "  wait start:   %lld usecs ago\n",
>                    nst, (unsigned long)task_pid_nr(nst->st_task),
>                    (unsigned long)nst->st_task->tgid,
> -                  nst->st_task->comm, nst->st_node,
> +                  comm, nst->st_node,
>                    nst->st_sc, nst->st_id, nst->st_msg_type,
>                    nst->st_msg_key,
>                    (long long)sock,
> --
> 2.9.0
>



-- 
Kees Cook
Pixel Security

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ