From patchwork Mon Oct 25 08:33:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yafang Shao X-Patchwork-Id: 12581033 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 E0581C433EF for ; Mon, 25 Oct 2021 08:33:51 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 8141960F46 for ; Mon, 25 Oct 2021 08:33:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8141960F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 2421B6B0075; Mon, 25 Oct 2021 04:33:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1F3B56B0078; Mon, 25 Oct 2021 04:33:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 06BC06B007B; Mon, 25 Oct 2021 04:33:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0110.hostedemail.com [216.40.44.110]) by kanga.kvack.org (Postfix) with ESMTP id EDF2C6B0075 for ; Mon, 25 Oct 2021 04:33:50 -0400 (EDT) Received: from smtpin13.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id ABE422DD80 for ; Mon, 25 Oct 2021 08:33:50 +0000 (UTC) X-FDA: 78734296620.13.AFC044E Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) by imf24.hostedemail.com (Postfix) with ESMTP id 59ED2B00009D for ; Mon, 25 Oct 2021 08:33:50 +0000 (UTC) Received: by mail-pg1-f180.google.com with SMTP id r28so5866706pga.0 for ; Mon, 25 Oct 2021 01:33:50 -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=rF1WxMESVJWbA0KjHUw1EAC/hqp6WgyH56B9+/ool+Y=; b=csPDI4HJ67TdymQQcsFexEUPoDgg26NWwNi/rwWaHt/rnz379QkpJRSIHuq8TVEgYg ZhbZz64XqUIshqzzWpYvuq3gi3XxxDhHFGfddtvJpFHmPX4Ut0V3sSa/Q8tOv+R7Q/pp +iHi5bc3UQLFoHCxJWLvyS2xNk9NzBIV0OY66qa2bm4wUd2q2xY8k4OtVhtaks7dMIO8 KipeoYrJONCg77Yq+PAf7OmcVgY+dj6VBfnQMPDFXd9jjOWbgVTwxjQHhPU0in18pnyS 1LQLX3U+daG5LZVaEJyKTVgal4lNpD8KR1aG2Jy0XkNCJs+RLlFcIaBscjzcwQwCX8Ql KcXA== 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=rF1WxMESVJWbA0KjHUw1EAC/hqp6WgyH56B9+/ool+Y=; b=vnFqHEk16v8ejIc87CDAy6l+4k3SZiUEM3Vawn7DMcqu6nuLU3WUpfjUR79u4JrxJ4 wLwfHduKvnhuWcqj77EKQykf2UL0jQuFSFkMZcq2z2oiX200UFw+KIGeHWG8upnUw2Hi 6MuDFY/8Voj/zhPntVm2M8fMZ79maSZRRh+Y2kBIl66qhPFchqu5HbEM4/RTUPn+nIOI LrccQmuGUnPUIXJtUplM0lk/tady4exFcZLNnXEIFlRGqovGbDrQp6N+CfsezAIv35TP y1GOp3jTvxsDau1cl0atC4ym+g9dst7CdnZIhgVfpOxvZ65FLYOzntedlyJ64K7qxdeF Lv6w== X-Gm-Message-State: AOAM532gTaJ69MZNM5VI/5vvqmhbflXJMMk05gIGNOs+XFsFUq9PEm1F Vdhdpexrnz3J9R8N1uCs6m4= X-Google-Smtp-Source: ABdhPJzmR7B3F/oDzpPz7UArNu9RJcw2YYz6E4xdldXe9GqTF0sfz89yReHIXFFjXn32SUShtQ07fg== X-Received: by 2002:a63:1a0e:: with SMTP id a14mr12821120pga.195.1635150829344; Mon, 25 Oct 2021 01:33:49 -0700 (PDT) Received: from localhost.localdomain ([140.82.17.67]) by smtp.gmail.com with ESMTPSA id p13sm2495694pfo.102.2021.10.25.01.33.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 01:33:48 -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 , Vladimir Zapolskiy , David Howells Subject: [PATCH v6 03/12] drivers/connector: make connector comm always nul ternimated Date: Mon, 25 Oct 2021 08:33:06 +0000 Message-Id: <20211025083315.4752-4-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 X-Stat-Signature: pq9pse17irbeqx9jdwejxutgrijgwgfd X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 59ED2B00009D Authentication-Results: imf24.hostedemail.com; dkim=pass header.d=gmail.com header.s=20210112 header.b=csPDI4HJ; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf24.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.180 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com X-HE-Tag: 1635150830-749344 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: connector comm was introduced in commit f786ecba4158 ("connector: add comm change event report to proc connector"). struct comm_proc_event was defined in include/linux/cn_proc.h first and then been moved into file include/uapi/linux/cn_proc.h in commit 607ca46e97a1 ("UAPI: (Scripted) Disintegrate include/linux"). As this is the UAPI code, we can't change it without potentially breaking things (i.e. userspace binaries have this size built in, so we can't just change the size). To prepare for the followup change - extending task comm, we have to use __get_task_comm() to avoid the BUILD_BUG_ON() in proc_comm_connector(). __get_task_comm() always get a nul terminated string, so we don't worry about whether it is truncated or not. Signed-off-by: Yafang Shao Cc: Mathieu Desnoyers Cc: Arnaldo Carvalho de Melo Cc: Andrii Nakryiko Cc: Vladimir Zapolskiy Cc: Peter Zijlstra Cc: Steven Rostedt Cc: David Howells Cc: Al Viro Cc: Kees Cook Cc: Petr Mladek --- drivers/connector/cn_proc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 646ad385e490..c88ba2dc1eae 100644 --- 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 */