Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3506847pxb; Wed, 13 Oct 2021 07:23:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyueWFN4sBVXjvLKqy4co5pp5LaAnoldGtKfTEecAn6GUE9YqkxHg3QeCS6nh4appmg/j29 X-Received: by 2002:a05:6402:d5a:: with SMTP id ec26mr10257208edb.364.1634135037640; Wed, 13 Oct 2021 07:23:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634135037; cv=none; d=google.com; s=arc-20160816; b=dwTDGpaPdAJXTb61BC76WRiqIScqFHOBk2F8yhphIEhvnyo0KvLQ0VaP0+Lne/Ykuw m2DZl692qU6E/iyMerhU54X7KihjjTWmaggYe/V6QCBxbot5G25+xap6Beb/IMy+jgHO Djc1HB+/PQ/23+EQq+LIaIGCio1p5BByc0VhbIqR4fqTR6tpa5KiuRn0fr4KhLgKR1wG q3Z3nxvtVh+ihvVX9MO+h+po89tqb/k2lrufAY618IICA5HfrDaMgbCmCaIwtNaOUvA0 FLxAE9Z2PHxLj0UdIavurMXosCV+714Wc/LTScEmlHV5EdnH68h0CiBv818f0P+9kaIF 6aIA== 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:subject:cc:to:from:date; bh=21t68jiF0RNcIPAUAKvaVrJ+t1CId3Hb/2gZne8o3eg=; b=YhSt69awOtqr9uJhyPxZKYqGyW7dphw2uYgUvIJtKVfBe5qu5W8IwIPYqVjtjMq9d1 RlUZPFCf+Li8gVZSQoeiD3Jf8C9J3tsH8YGbv04HLxJTb/z/411OxA68287bP0FUw8wj d+1F56KC4FZGFLDILaZbc6/Gl81/YUIIPLoYMTQwJH54BvNdoM0ExovbcGIlU+AuZuh4 wan/4l8ejMfeWye9wt0PV9IlSteJ1u8KhY8kioqy4KbBhabQMGMIxCNbBulZcdHL5Xep 4B8LSeV25rMUqF3JU+KSoJ9WHFR+5hh/L3SqaB6qQEuY32MTF11qGtk1tuie0YVBDyJR YlqQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q11si25539680edd.253.2021.10.13.07.23.34; Wed, 13 Oct 2021 07:23:57 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233918AbhJMOVa (ORCPT + 99 others); Wed, 13 Oct 2021 10:21:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:38370 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229562AbhJMOVa (ORCPT ); Wed, 13 Oct 2021 10:21:30 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A57E760ED4; Wed, 13 Oct 2021 14:19:24 +0000 (UTC) Date: Wed, 13 Oct 2021 10:19:21 -0400 From: Steven Rostedt To: Yafang Shao Cc: keescook@chromium.org, peterz@infradead.org, pmladek@suse.com, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, valentin.schneider@arm.com, mathieu.desnoyers@efficios.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, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, davem@davemloft.net, kuba@kernel.org, linux-kernel@vger.kernel.org, Vladimir Zapolskiy , David Howells Subject: Re: [PATCH v4 2/5] connector: use __get_task_comm in proc_comm_connector Message-ID: <20211013101921.0843aaf0@gandalf.local.home> In-Reply-To: <20211013102346.179642-3-laoar.shao@gmail.com> References: <20211013102346.179642-1-laoar.shao@gmail.com> <20211013102346.179642-3-laoar.shao@gmail.com> X-Mailer: Claws Mail 3.17.8 (GTK+ 2.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 13 Oct 2021 10:23:43 +0000 Yafang Shao wrote: > --- a/drivers/connector/cn_proc.c > +++ b/drivers/connector/cn_proc.c > @@ -230,7 +230,10 @@ void proc_comm_connector(struct task_struct *task) > ev->what = PROC_EVENT_COMM; > ev->event_data.comm.process_pid = task->pid; > ev->event_data.comm.process_tgid = task->tgid; > - get_task_comm(ev->event_data.comm.comm, task); > + > + /* This may get truncated. */ > + __get_task_comm(ev->event_data.comm.comm, > + sizeof(ev->event_data.comm.comm), task); > > memcpy(&msg->id, &cn_proc_event_id, sizeof(msg->id)); > msg->ack = 0; /* not used */ __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. -- Steve