Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp183682pxb; Mon, 25 Oct 2021 06:21:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwaYxAUx9D7GeUlamefCdkGR0xBrUzjNHhR2V/h1h9dlZ14S6zpY7Osi3q2mHdDwJPRs3bO X-Received: by 2002:a17:90b:4a8d:: with SMTP id lp13mr35789252pjb.240.1635168071571; Mon, 25 Oct 2021 06:21:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635168071; cv=none; d=google.com; s=arc-20160816; b=r0nMNVKDUwTpslVhzbeTu/oyFpsREX/dj39o/CKL4D9/I5iO6cE7MeheQKFpAgQLsa xFQcd4gTMGrDvoZzs3YOE9MNv680lu7HJLokqgqQwzNmVLSeJNTqbY2JyDIZmJJQYnxf aji+xBH1aAVb/aMRLe1Cpi/c0JyglutmqFDsPqN+2AH3dWvxUJ06NAmFBkMZAQuYbENL oRNNiRtcM7DtTdxX3fpen5J+UPc/qF1XXiAPj656vHGrn4axo4piEQDoY0MviVrvY4db pQ+eheHqbkX+3A8mgoZC06MWDmOlLEB6uYi+tC1qbv6D4Pt43Ls41Gc6WVRpDpMQTf88 0GlA== 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=tb2DLSHt7yEoDSj1xonLMAUM0KyNZsEaGyv5bBEUpu8=; b=mB8aHXEZXrEZRki+ppNOhFj1W/iiYJhxGuhFB5ImoETSvbeojPYSXn0D7PB6ed7Zkd HOJjVhmxOT6oBBsQsjHfjCw6is56jTEDiZvzXjX5GFLGgNPlQvJmpjvTi4c2UtGAeKpi Y09TdgHSFKhbC40YO8ii9Bw+X46+l8QXxdxcSFwIAcTVwQonmyOmry83h2SYbleGp63L mu3RMiR2fjKFsdVJc6X4q9GAdRAtSyRXwO0aEeJYUJUwheFtQqBa3lmGcJxmp17UHGVB F4Bad0K4W85KsrgqlyO4gOKNxdgEEcXktCGi1fg7j/s8ajwisZWiaqWOOcBBCnoPb2PV M1/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=oYlyi3lo; 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 h126si25013759pgc.276.2021.10.25.06.20.56; Mon, 25 Oct 2021 06:21:11 -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=oYlyi3lo; 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 S232229AbhJYIgL (ORCPT + 99 others); Mon, 25 Oct 2021 04:36:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231241AbhJYIgH (ORCPT ); Mon, 25 Oct 2021 04:36:07 -0400 Received: from mail-pf1-x42a.google.com (mail-pf1-x42a.google.com [IPv6:2607:f8b0:4864:20::42a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2D5B0C061745; Mon, 25 Oct 2021 01:33:45 -0700 (PDT) Received: by mail-pf1-x42a.google.com with SMTP id f11so10013309pfc.12; Mon, 25 Oct 2021 01:33:45 -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=tb2DLSHt7yEoDSj1xonLMAUM0KyNZsEaGyv5bBEUpu8=; b=oYlyi3lonUU6Fa8XZ2e7zj+Xij1FY4rsdKgLByteR1YoxJaXWn0b+9E04KwplgPwen Nsyc4c9ZtY3k38kLVKWr4UpYSbaABNZRdpSExH5nuGb3+YWWsIS4+YyBPSUGBFurjTCU E0r982qEh5Dd3WP8mqTWX1MQoiNzsPO0G0x9u8jvrqPNkmLCIxRNvLPQQZgXaoOfXaDN kaPzNZ1W1O5wHYsrZCyowbYAkbsOKKXpRCd6MsdvrN1ds01r0ejvZnHwygt9j9a35bCk Cf2hKPGffK2GWb7AtSjLShunf3C66hJNoQRYhRnelFTTOniybfDGnJeB/MIbgD338RDP Pnuw== 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=tb2DLSHt7yEoDSj1xonLMAUM0KyNZsEaGyv5bBEUpu8=; b=wqckCDcr1jjU34dQC58DeAXjOW9JF+zB9Reuxt3Q2vYidR1dBPL0nJQ9osXfXdY5c9 iKwS2vin+dPS/ku/5XtYJ7lkYgV5gn3dzrSK3u5+GENINVppXHxTj7T1nPheZ3s9rOgH KEQi4HfQhNYEvzkKrhbTTuvAe7vkIiSHU1BXufQBMypbcLIRCf/XSr4fqm1YKoJDZUEi TOr3ejRk+XVqDrQUWVRdki3fd8AoJFaRtoaxc63ip2KRuBm0QbX3vENqj7Z4AKTmnYNi rpW/a42dGAd9JpKh2tx5/6B0qbD5AAK2igUBcz+6jN2disaf7os0TEEOaRN23cFqByhF sbDA== X-Gm-Message-State: AOAM530tJ04N4Al+m67ayhw9Q8gSAABRKYuOXHlNidq2PMBn95pDN3cc f6GsyWfop0/4Ym2vziVrBSU= X-Received: by 2002:a05:6a00:23d3:b0:44c:a67f:49af with SMTP id g19-20020a056a0023d300b0044ca67f49afmr17110818pfc.50.1635150824679; Mon, 25 Oct 2021 01:33:44 -0700 (PDT) Received: from localhost.localdomain ([140.82.17.67]) by smtp.gmail.com with ESMTPSA id p13sm2495694pfo.102.2021.10.25.01.33.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 01:33:44 -0700 (PDT) From: Yafang Shao To: akpm@linux-foundation.org, 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, 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, dennis.dalessandro@cornelisnetworks.com, mike.marciniszyn@cornelisnetworks.com, dledford@redhat.com, jgg@ziepe.ca Cc: linux-rdma@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Yafang Shao , Andrii Nakryiko Subject: [PATCH v6 01/12] fs/exec: make __set_task_comm always set a nul ternimated string Date: Mon, 25 Oct 2021 08:33:04 +0000 Message-Id: <20211025083315.4752-2-laoar.shao@gmail.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211025083315.4752-1-laoar.shao@gmail.com> References: <20211025083315.4752-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: Arnaldo Carvalho de Melo Cc: Andrii Nakryiko 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