Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4056459pxb; Wed, 13 Oct 2021 19:45:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjNHZTvJx3E4BfprGMMfK8rekam2mpzFZ35eXtXPyTE7eSPBPnjs8EJaCGwLjggtU1w0ad X-Received: by 2002:a17:90a:bd18:: with SMTP id y24mr18300848pjr.83.1634179523388; Wed, 13 Oct 2021 19:45:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634179523; cv=none; d=google.com; s=arc-20160816; b=U/WATnE/Hk36WqLNbNv/Tlgo6L2YhrgZDmYOMG0921rZFOIAE+e30KWf3nk5tIs/f6 igyilTUEjFdyHKgbuZDLYQpy8y4T0VirDDIRFsvPpAI4UsaLmWnfaJdO5b4xHxL79SmT Xrm/65Dgo3NfWy964wF2q+1aWPzISqrlEhDc9KOIyNvH3RX7YXjteJkD13baKwisxqSi TIwpjzshlCI3sTRkSwT9BUlHu6HiTab3z6s1BekmBlWbXJrMzuU0dx34Th8j+yhkZlpz GO/xzmaHP+t+xPIxTUB7QmAbhdiixKQxIndt1LJHQpIdJJ2CezcZJahn7d4wb2XcKKxW Oz2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=g39CSEOp4O15FcdzhPLxqLxd3uXN3mN8W1vtWL8zuSY=; b=I8+9IR/WemFRnLNwbI+bgW7TYgumnJ1iuA+PySiZ7xTvcEmm/H96K5Ek1WfoT74MfG abyJc2m/S2pcyXA4Qv1efbuqDXCjxDPJyDqsWbIYimv/ZsxGdvmlBm2MwRXNjTxWmZLK GjTt3OZsJb0e8sdCoS6u+4qt5INvFiDUjb3yC+PAfR0xeP1aQOKNIxi/t8Upn0WbCYxv FtEF1IC5ybFL9x2CUL8yInQlkkjGm8+ZXFY0WmiJckNm4+tpRYoQbN6CXunDSP5SoT0m KgmFgcJ4qjGsR9ujqU+/NjfHbAvBkx8L103DpL+jtmngN62o2Q4YiiItThrW3N4MyVlk MnWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=I7wC3xQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t3si9268974pjg.163.2021.10.13.19.45.11; Wed, 13 Oct 2021 19:45:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=I7wC3xQz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229882AbhJNCpY (ORCPT + 99 others); Wed, 13 Oct 2021 22:45:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229879AbhJNCpX (ORCPT ); Wed, 13 Oct 2021 22:45:23 -0400 Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32794C061570 for ; Wed, 13 Oct 2021 19:43:19 -0700 (PDT) Received: by mail-il1-x136.google.com with SMTP id f15so1879105ilu.7 for ; Wed, 13 Oct 2021 19:43:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=g39CSEOp4O15FcdzhPLxqLxd3uXN3mN8W1vtWL8zuSY=; b=I7wC3xQzI7yXhGhBEU0olaeZP7qiE59PN9hxW2e7069TtAz84DqxLs6oPjEBi7tUXV MOlQTGlmfL5Vsjd9U7Aca7B88u0eEzxFl0tbnSbAP2KA0nqIz/rJCBN4ybvaN8ITju9f uMgmE7Mi/G6s4Sp91FPAJy8mnaz63LbI+3Xnq9+a0IbSQT9syaQtVnsd4dLdzUlGGlJg OOikfOrC5EEf2LsqEad0zMCX/lQZUkSvGNqhumHdQUWO9B9IHDfhT/RRGcUqCKnswJ+8 aeqD0ygIGjVxSKG2KabBiJbY3SD8s9h/Q24d/z6d3NFYYdDsj5aSCHaZDrcVd+/IakHT rP2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=g39CSEOp4O15FcdzhPLxqLxd3uXN3mN8W1vtWL8zuSY=; b=thoDeIzyvOow76mHbiBaH66EddKcwlGKtF0GbXFW7bNnepsbfmRunywDgonb806m4d RlWfZ8pAOdmKSNbTX2UYgWJ/Sv+dAkUVMMzUYsdLDqe07jLjZL82VZwMpJF4bhhvKLeo Ic9/hMXV5JIamxvC+/wD4h/0+5VkxaNXdc078VIGZ7TTm2G243YtP8BgvTc9TPEujdbw nB+SYsrNiUaur7gSM9HvhmPXcv+YKy3rlvt0+Vg39DOT98nh9UjFjidulQCvkUimM6Wx CnbQb9G4xPp+wURceTt4l+kJo3qHSGUB97KrRgUmf8kf95mye9vD14RFArk1wyMD3chA +xmw== X-Gm-Message-State: AOAM532rwrpkFqlpKbDQR+8EY9UGfrWyJxmbR9VJgRlhdl76SsOVpuqk q9/XCiTrM50dxZJw9C0ARMsdT4J4GIZFDrq0joY= X-Received: by 2002:a05:6e02:c11:: with SMTP id d17mr440044ile.25.1634179398676; Wed, 13 Oct 2021 19:43:18 -0700 (PDT) MIME-Version: 1.0 References: <20211013102346.179642-1-laoar.shao@gmail.com> <20211013102346.179642-3-laoar.shao@gmail.com> <20211013101921.0843aaf0@gandalf.local.home> <20211013222418.7ea9727d@oasis.local.home> In-Reply-To: <20211013222418.7ea9727d@oasis.local.home> From: Yafang Shao Date: Thu, 14 Oct 2021 10:42:42 +0800 Message-ID: Subject: Re: [PATCH v4 2/5] connector: use __get_task_comm in proc_comm_connector To: Steven Rostedt Cc: Kees Cook , Peter Zijlstra , Petr Mladek , Al Viro , Andrew Morton , Valentin Schneider , Mathieu Desnoyers , qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, Dietmar Eggemann , Ingo Molnar , Juri Lelli , Vincent Guittot , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , David Miller , kuba@kernel.org, LKML , Vladimir Zapolskiy , David Howells Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 14, 2021 at 10:24 AM Steven Rostedt wrote: > > On Thu, 14 Oct 2021 09:48:09 +0800 > Yafang Shao wrote: > > > > __get_task_comm() uses strncpy() which my understanding is, does not add > > > the nul terminating byte when truncating. Which changes the functionality > > > here. As all task comms have a terminating byte, the old method would copy > > > that and include it. This won't add the terminating byte if the buffer is > > > smaller than the comm, and that might cause issues. > > > > > > > Right, that is a problem. > > It seems that we should add a new helper get_task_comm_may_truncated(). > > Or simply change __get_task_comm() to: > > char *__get_task_comm(char *buf, size_t buf_size, struct task_struct *tsk) > { > task_lock(tsk); > strncpy(buf, tsk->comm, buf_size); > /* The copied value is always nul terminated */ > buf[buf_size - 1] = '\0'; > task_unlock(tsk); > return buf; > } > That is better! Thanks for the suggestion. > But that should probably be a separate patch. > Sure. -- Thanks Yafang