Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4312674pxb; Mon, 25 Oct 2021 01:37:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJww0IzTJDkiOkvVUy9SWngUdP4T4LVMC1/wgvIx+9KeK8Lf5W9JrN871wUTWGbVl9FAHjfy X-Received: by 2002:a65:6499:: with SMTP id e25mr12410161pgv.146.1635151047678; Mon, 25 Oct 2021 01:37:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635151047; cv=none; d=google.com; s=arc-20160816; b=W1e9+PWFPs8JSp05rx+QiJAGzoM/atzXeEFTy5UU7BiHGy9gtwNVpcuYFN0WosRGx0 VEl/Asjh9GcegmFOsGD4Xc+aKFhsD+1kPR9LPOq4oiSkz2LefmU4g4aFR8hK3lq08SWz tt1D85Ihd3Wc9gtiXLhQyct9LNSQG+hCmX4PEniRCRGuk9VJoC495OyBHadUFsOGF0Kf 4vn587CB2atdiyLnNpatInV62Lw8vTJXKovsqTakTQmw53xY9cri5bBTCLkHxOZUfqKy E2maBlP0rJNSR7sWMZB7XdWiqXUqhpU9xI00GXXhYDEVOVKWdmFdlM/B4DKvhdqLGHYp 2HjA== 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=rF1WxMESVJWbA0KjHUw1EAC/hqp6WgyH56B9+/ool+Y=; b=hC9qEBdj+UdCx/+yR0IS4JF+2qrCMccLhO7miYc8i0lXTmUhwqw+8g0YYK/R8k6PCs 9xbADSsSMWF90dEE63OiF0EBDHI4HvzmwTAAp2PI+xS0uw/ewJqOesX8pWT03eCjSaK4 nZ7xknyyBH3rtlK6VLf41lYUYA/zRO1OO+bIQ4W8mDtjfDAKiH0qVC6aRBN7lzOxVGgR 7wYKzmGXKUMW2sOS6+djabkISmwrisq31eHtP5TSVtwg1fMtKEKU7eEv4ZHdhiickDo/ Aq4/yq2LVJP1H9k/MEHpRpJ7UH40f21083o0xTsyhMaobXkhXtwF4u6bm8c3+FxL7iPy UxGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=csPDI4HJ; 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 y127si22847124pfc.157.2021.10.25.01.37.13; Mon, 25 Oct 2021 01:37:27 -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=csPDI4HJ; 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 S232344AbhJYIgT (ORCPT + 99 others); Mon, 25 Oct 2021 04:36:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232172AbhJYIgL (ORCPT ); Mon, 25 Oct 2021 04:36:11 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B3012C061764; Mon, 25 Oct 2021 01:33:49 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id m21so10178681pgu.13; Mon, 25 Oct 2021 01:33:49 -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=1gRDNdSvV0YdmoredQpeq3yrhZJlgpYG1o8iCs1bXm62nbsMq2jJA48l8tH4suDH0G D9b3iVgY7W5OUyt7NiITry5Yj769xBNyxTw075WlqIArqS1jKfFvkHz3tl96lHMm0oNQ aUhTJS79krY3i9PDUJ2l+Q6Nuzx3/p4BllWmjXyNqIQZrWV7uhw4k6RgZN/R879QDd9W D2yWYIXViRr75pT16UGrxiNzslaeQ9G5Z2QVvX82ou1ix11YbWJIOVlpWx4FJdexC0s2 R6CyLu5FhMxjuohsR46ZgllYYo6RRY/zd27EY3H9XNWrUdm2ho+gDDzLEFRps5t6XRzO 5F8A== X-Gm-Message-State: AOAM533NDU6wBCSMPmGcqjjmzWlAR8H8GHQiNF/PoeNhIWuoZ4ubNQxv Sbjkci9zjoDut4nrmBdc3c0= 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 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 */ -- 2.17.1