Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp224913pxb; Wed, 20 Oct 2021 20:47:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzFxKUgYalghewn+G0DFsFutpxs383j+cvM+t+UkwW4vdc9ydRqoz+HuFBQtMKSpmH0T24Y X-Received: by 2002:a62:7b43:0:b0:44c:6d72:ac4d with SMTP id w64-20020a627b43000000b0044c6d72ac4dmr2958392pfc.73.1634788020308; Wed, 20 Oct 2021 20:47:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634788020; cv=none; d=google.com; s=arc-20160816; b=cIiIFj3KOPTGFmSefuFzADS5dYluPG7BWdfNVsD7CFUBE4xY62nasgpneMHz3u9i6c 6bJdr/YLv5Ohc5rmPC31KnFA9FvMxaDhow0zQLK1pluT1y3DMov8T3KFMJ+xn5So7wXp llHYrjTZDl1eZ0AQ1utc6iyfliEjd7PI1JfPIIaYjMe52yavjzAMGuFNS4718lE8hh/X vgk2FADXmYjEa6mOyRWsnzFRUuZmMMtiNVWxYctDjXgo/UqNLIsetfDo1WeFh4pgwI6a UeIOi3auHd3yFFzJq+Fgqyq8SBqgYLvQAKJhvAf1NBGf/Clul8C68LIVUvEY8hwkRyPJ iv3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=28QPdPbMM0S7NoiSQs1dCJ5bnkQ4h4CQgKgI92E1QJM=; b=Udxq59FkSvCrQfPq4h7HFR0WXNTTGs5GuguCOrpXTnWEtSKc9B0wMCed4j4zZIX8Yo /0DieBQgsbH4BhJQSlguZ18bBs48HtwdwizcIKeWQxg1ZgRi0cBob7OloNXfvaLnXd3E XFG1NUIUWhWPYutRTqcpK0FkreOrJMCvFNm3zzEkYzPS6lw66+cqr3im2vfdy5Yv0HTL l3ju67xDarTAdp1lBOhRdBLc9NF3WqS6E/Aqgo53i0hr20bsI6cSfzYda2FC0VKBsi4e EtztY7PGhIPLsirOR4f9DuFsJoz6O2EZeqdrzOYvWuNg8qxwwX9GWBKggFsBi45xPMRQ 3H4A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qOz60AwT; 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 j62si5372300pgd.75.2021.10.20.20.46.46; Wed, 20 Oct 2021 20:47:00 -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=qOz60AwT; 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 S231357AbhJUDrm (ORCPT + 99 others); Wed, 20 Oct 2021 23:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231281AbhJUDrk (ORCPT ); Wed, 20 Oct 2021 23:47:40 -0400 Received: from mail-pj1-x1033.google.com (mail-pj1-x1033.google.com [IPv6:2607:f8b0:4864:20::1033]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C0D83C06161C; Wed, 20 Oct 2021 20:45:24 -0700 (PDT) Received: by mail-pj1-x1033.google.com with SMTP id n8-20020a17090a2bc800b00196286963b9so2104931pje.3; Wed, 20 Oct 2021 20:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=28QPdPbMM0S7NoiSQs1dCJ5bnkQ4h4CQgKgI92E1QJM=; b=qOz60AwTnCiKiUWe4HE41jrZ+BKODIChNBbP9NvsAV5cyHgsYNeZ+IfsChK6Do8ElD aJQEumMUjDSqyb/VMuMPAGxAsDORyieDVTA2f1x4Cpi8yvzQwAceSSXQYGOpV3LZObsk yDVtGeRN/boWfT5viVGTXpHOJo60nDwzDo/qD5timMFe1mm696m+TC2XRzcW3+7aHU4e VGqj+5fl9K8WcRyoL+0IdtJu8U1uKxMUoAwn7rc7k/L4FwB2Lmxb64g51H2Xr2BLMbF0 WHxfe8my6XLrEDSCgP0IMBusVbEY1qR1jOd29A3HgzMtaszsKT1vbLlUd7d6rV+8EK41 lUUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=28QPdPbMM0S7NoiSQs1dCJ5bnkQ4h4CQgKgI92E1QJM=; b=GXCrgBEoLtytDMaew5ipf3pujJOKZ+JvmgJF62t40wMOrKB0mUPYY57h2kXKNvzJM0 k4X/p1ajI85M5OO/jsPt5K6hG5VgwXiF1WYdGugpdwes+Ol3w29iuFWcDVcpJhZcVUXY 6gtuWEXkNiQihzeblGzpuF74TSyLWK5CdcTjXb7zyciK/GAJdQv3cSe8vOM//w4QyUMC tSOiEwKaTQSgW4dYccIyQ4wYnMTycVmlC8+2eGWl1MhiTwxAitslZgCUuICjgxZRRHvc u95zWKazL9aRpNFZO4QSMYxqajMZV22oLu9zoVe+Ko6uUtaT9lMLOpTFYMb/MDd5ZR68 zrQQ== X-Gm-Message-State: AOAM530B/4uq63R9jQTWLWlSr44llvm4TGp6FceS/E2A6Lcr1u41IfM9 ISuBXfGpaBp5mcze6NU7nYA= X-Received: by 2002:a17:902:f703:b029:12c:982:c9ae with SMTP id h3-20020a170902f703b029012c0982c9aemr3018202plo.20.1634787924373; Wed, 20 Oct 2021 20:45:24 -0700 (PDT) Received: from localhost.localdomain ([140.82.17.67]) by smtp.gmail.com with ESMTPSA id bp19sm3651077pjb.46.2021.10.20.20.45.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Oct 2021 20:45:24 -0700 (PDT) From: Yafang Shao To: keescook@chromium.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, pmladek@suse.com, peterz@infradead.org, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, valentin.schneider@arm.com, qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, dietmar.eggemann@arm.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org Cc: netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Yafang Shao Subject: [PATCH v5 01/15] fs/exec: make __set_task_comm always set a nul ternimated string Date: Thu, 21 Oct 2021 03:45:08 +0000 Message-Id: <20211021034516.4400-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211021034516.4400-1-laoar.shao@gmail.com> References: <20211021034516.4400-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Make sure the string set to task comm is always nul ternimated. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Peter Zijlstra Cc: Steven Rostedt Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- fs/exec.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/exec.c b/fs/exec.c index a098c133d8d7..404156b5b314 100644 --- a/fs/exec.c +++ b/fs/exec.c @@ -1224,7 +1224,7 @@ void __set_task_comm(struct task_struct *tsk, const char *buf, bool exec) { task_lock(tsk); trace_task_rename(tsk, buf); - strlcpy(tsk->comm, buf, sizeof(tsk->comm)); + strscpy_pad(tsk->comm, buf, sizeof(tsk->comm)); task_unlock(tsk); perf_event_comm(tsk, exec); } -- 2.17.1