From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87978C433F5 for ; Thu, 11 Nov 2021 09:58:21 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 211F361104 for ; Thu, 11 Nov 2021 09:58:21 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 211F361104 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 9811D6B0096; Thu, 11 Nov 2021 04:58:20 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 930F96B0098; Thu, 11 Nov 2021 04:58:20 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 820D06B009A; Thu, 11 Nov 2021 04:58:20 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0181.hostedemail.com [216.40.44.181]) by kanga.kvack.org (Postfix) with ESMTP id 739176B0096 for ; Thu, 11 Nov 2021 04:58:20 -0500 (EST) Received: from smtpin16.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay03.hostedemail.com (Postfix) with ESMTP id 3B9B980BFA4D for ; Thu, 11 Nov 2021 09:58:20 +0000 (UTC) X-FDA: 78796199160.16.0C65AC9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf31.hostedemail.com (Postfix) with ESMTP id 5BC6D104D41B for ; Thu, 11 Nov 2021 09:58:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1636624699; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=2WfCXGbrfuPcyNxfHFWFibzfvtpe2j1zKl+DzGNBc4s=; b=QnDNdW6jCCzQIen6sSPrgzpBzvhC+KMIedutBz+GjUqMHbg31QNJj5NVtOKrlFE1vfwVUz KOe2TPd5mJC4Ki78FmR3/J7woMtkFQlMuHY2B3QGrdFtX/IMC3n1POUCYNJCP4eSXJIC0k HfxuwtewTNoZzcOHOjhF5Vk7pNH+3Rc= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-226-DRdXuiboMIKcNZ6zxoChvQ-1; Thu, 11 Nov 2021 04:58:16 -0500 X-MC-Unique: DRdXuiboMIKcNZ6zxoChvQ-1 Received: by mail-wr1-f72.google.com with SMTP id w14-20020adfbace000000b001884bf6e902so923669wrg.3 for ; Thu, 11 Nov 2021 01:58:16 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:organization:in-reply-to :content-transfer-encoding; bh=2WfCXGbrfuPcyNxfHFWFibzfvtpe2j1zKl+DzGNBc4s=; b=vz8EYiqM5Ad65jlKwlQsLR2WhXVYClQpB3C3PmqY2zRJQ6zsK7ndOtG4yiB1ElkbLD +WDKaapMBsDh5QPDKvfYw/f0xyKJBaRud7ISt5ZrA5FzaKAsDkHiJjtpPzRCLi1F4BYT NwUrGPbGm6yKppNF60X0pEL9i6e+VUe0VPXkF8ijefHOzSaImLL9MpFcbmf7a9bJmpYy mqVrbahdMhLwb4Whi6AwdbFpQDT270COrs4VHIPaoemmXr20Vz4/T2+TiukdcoXXu/Su xBk+HeH9FQibvvkqmyKcoHQOw/CwJU2/F5pghxE6mZZBYk2IOXINoE6VLvQl6yrkLudu q4fw== X-Gm-Message-State: AOAM531UfspQTbqAyBKOWZLwA7JtqN333AUXjJHleREwq3d9bfiylhkq c6xEu8AkLd1QXh9nDtc7KaHjJJPEEqq1O/nbxxXqSENU3+84Ri+ZJrXg0eykus4r3FNGwIoJ/uC tMQ4fcY8rZTc= X-Received: by 2002:a1c:23d2:: with SMTP id j201mr2503852wmj.76.1636624695802; Thu, 11 Nov 2021 01:58:15 -0800 (PST) X-Google-Smtp-Source: ABdhPJzrulQBQPuRy6L+qz74whcjWLY8u+rgH1OO6eX2oTETTCSbO+kpZ6/tGPnb1PaeF7ZEn/lzpw== X-Received: by 2002:a1c:23d2:: with SMTP id j201mr2503832wmj.76.1636624695641; Thu, 11 Nov 2021 01:58:15 -0800 (PST) Received: from [192.168.3.132] (p4ff23ee8.dip0.t-ipconnect.de. [79.242.62.232]) by smtp.gmail.com with ESMTPSA id 4sm3186059wrz.90.2021.11.11.01.58.13 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 11 Nov 2021 01:58:15 -0800 (PST) Message-ID: <3526ab88-afa3-e87b-d773-72807a27a88d@redhat.com> Date: Thu, 11 Nov 2021 10:58:13 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.2.0 Subject: Re: [PATCH 1/7] fs/exec: make __set_task_comm always set a nul terminated string To: Yafang Shao Cc: Andrew Morton , netdev , bpf , "linux-perf-use." , linux-fsdevel@vger.kernel.org, Linux MM , LKML , kernel test robot , kbuild test robot , Kees Cook , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Alexei Starovoitov , Andrii Nakryiko , Michal Miroslaw , Peter Zijlstra , Steven Rostedt , Matthew Wilcox , Al Viro , Petr Mladek References: <20211108083840.4627-1-laoar.shao@gmail.com> <20211108083840.4627-2-laoar.shao@gmail.com> From: David Hildenbrand Organization: Red Hat In-Reply-To: X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Authentication-Results: imf31.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QnDNdW6j; spf=none (imf31.hostedemail.com: domain of david@redhat.com has no SPF policy when checking 170.10.133.124) smtp.mailfrom=david@redhat.com; dmarc=pass (policy=none) header.from=redhat.com X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: 5BC6D104D41B X-Stat-Signature: hnugk6bsb87kzyckp34q4t6cs6c31sdf X-HE-Tag: 1636624686-465393 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On 10.11.21 10:05, Yafang Shao wrote: > On Wed, Nov 10, 2021 at 4:28 PM David Hildenbrand wrote: >> >> On 08.11.21 09:38, Yafang Shao wrote: >>> Make sure the string set to task comm is always nul terminated. >>> >> >> strlcpy: "the result is always a valid NUL-terminated string that fits >> in the buffer" >> >> The only difference seems to be that strscpy_pad() pads the remainder >> with zeroes. >> >> Is this description correct and I am missing something important? >> > > In a earlier version [1], the checkpatch.py found a warning: > WARNING: Prefer strscpy over strlcpy - see: > https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/ > So I replaced strlcpy() with strscpy() to fix this warning. > And then in v5[2], the strscpy() was replaced with strscpy_pad() to > make sure there's no garbade data and also make get_task_comm() be > consistent with get_task_comm(). > > This commit log didn't clearly describe the historical changes. So I > think we can update the commit log and subject with: > > Subject: use strscpy_pad with strlcpy in __set_task_comm > Commit log: > strlcpy is not suggested to use by the checkpatch.pl, so we'd better > recplace it with strscpy. > To avoid leaving garbage data and be consistent with the usage in > __get_task_comm(), the strscpy_pad is used here. > > WDYT? Yes, that makes it clearer what this patch actually does :) With the subject+description changed Reviewed-by: David Hildenbrand Thanks! -- Thanks, David / dhildenb