Message ID | 20241007144911.27693-5-laoar.shao@gmail.com (mailing list archive) |
---|---|
State | New |
Headers | show
Return-Path: <owner-linux-mm@kvack.org> X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id DF5C2CFB43F for <linux-mm@archiver.kernel.org>; Mon, 7 Oct 2024 14:50:23 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 72AF26B009E; Mon, 7 Oct 2024 10:50:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6B3C26B009F; Mon, 7 Oct 2024 10:50:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 507CF6B00A0; Mon, 7 Oct 2024 10:50:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 2BD1C6B009E for <linux-mm@kvack.org>; Mon, 7 Oct 2024 10:50:23 -0400 (EDT) Received: from smtpin01.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DEBE6C08CC for <linux-mm@kvack.org>; Mon, 7 Oct 2024 14:50:22 +0000 (UTC) X-FDA: 82647091884.01.F326DC6 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) by imf10.hostedemail.com (Postfix) with ESMTP id 09F1DC000D for <linux-mm@kvack.org>; Mon, 7 Oct 2024 14:50:20 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Fzllpzsz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1728312578; a=rsa-sha256; cv=none; b=zCj0R5qvI79GG66PARQt+90hKq6n3dyfVXGL2L5UrZUMCHYQkIoMREdB+5Ukx0ltLatg9Z iwxIV4uqAu+KgiImkWjVP0DLrCyJZuAPDiQSoCm6wCiMX9bd4zVLPh6KDIrDFGmqzJdNcb jVAf2fSSMOPYZ6ZvqqF/+rwXHujfLO0= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=Fzllpzsz; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf10.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.215.172 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1728312578; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=QQdkC9XISn7BWPlTE5/iE7aUj/L2jeLonKoaBsbNpS0=; b=3pLeLSDr18cy7Ih+bLZ1TS4EM1TNwx5KAK0rHPJ7MeyLxTAq7v5ifLnGcIG9yydjTLwH8w CyDT1iklpS9HEXMGbU9hVyVxF8JUyH4bPnEqn2s43LtP1wHysbiA6wHtsVfQI2mSzAxlSl t/JoqnceXo5DA88Dd4NXQpHgRHvmyj4= Received: by mail-pg1-f172.google.com with SMTP id 41be03b00d2f7-7e9fd82f1a5so1045751a12.1 for <linux-mm@kvack.org>; Mon, 07 Oct 2024 07:50:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1728312620; x=1728917420; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=QQdkC9XISn7BWPlTE5/iE7aUj/L2jeLonKoaBsbNpS0=; b=FzllpzszR/WlNgJ8bF6xIwLnhiCwhvlteVAJu2y4QKCweZF6ITpake5nM2UwPzfYKj c3+NFKWajtyT3WJL1p1b9Xk9cbWoZ2RkM1xcjQibJjONhzI3HpiWMUPM9sOJXixSwaYX qyNFjCNMs7yU+dYgWWl45a4MYiTq29B+5UHcgRrizGkerh+TfI/m2Q63vv4CvHygcbt8 q5Wmt06/SHzcmsAuoJ6qwI0WinsWMEYdTYDCsIu84zZSCDwDVbKXgl42MPlbKdmlV8L8 oJVpcgUD7Zk3W+DXi577Fz/+qtiDPufKdEfZnKLxKjniRGfjFUWSHBPXbM3J+2EigRrL BCEg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1728312620; x=1728917420; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=QQdkC9XISn7BWPlTE5/iE7aUj/L2jeLonKoaBsbNpS0=; b=UvVItg4Y5zw7vup4ndk0SDWFDXa8Er8kCOAt+a5oY3Va0P3iuJ4KNm4u9X3ZO5IgMQ WEoTijKb3dMgqVveBFAcOOrBZKCFk2zDeikQzLmIGb6s33LpX6Yto60hY3LZeOLgEijH vEPvbeWIromaqVwb0YuV+A/rbwAfCcxF/fbBwIse2LGPnUjWi5fvHRnhT5pHcWapzR4r AQ5+e8VxE74iLGZztUWS94vCCQKaqb/mJoSbg8b6JCZNVZVgE5T0Q1vTJLl1OogJPdPs YDw1cVUDAeJMfeHb6VUpsXeUr2D4+aINzU/1yo/PISpGQ7E0G0ZFi5dy/FUHLvQ55EWh RyAg== X-Forwarded-Encrypted: i=1; AJvYcCUhuK3HRM8gqtLrhu39N9RVwS9ewsfa0LU+p9Sjw/aZx3bLOvVsnSa1I8+kpUAUuWUhG6qSUxTCew==@kvack.org X-Gm-Message-State: AOJu0Yyo+63CxujOgjSG+VXVwFaHIPVde5Ktzag+1l3KdSq/hxBBIotM LfpvQpBP9FJjXJzAIO6lD85qH3eCPfv0XTzBQJkCIyReOTTc2HwL X-Google-Smtp-Source: AGHT+IGdJ8333QIHr9VJupVLpNtoPXxXbiV/WsIALKPyiyHXyFn3qrINZ3iUgrsX4T7ZKXd0XBWepw== X-Received: by 2002:a05:6a21:9201:b0:1d5:1729:35ec with SMTP id adf61e73a8af0-1d6dfa27a24mr21138343637.7.1728312619784; Mon, 07 Oct 2024 07:50:19 -0700 (PDT) Received: from localhost.localdomain ([223.104.210.43]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71df0d7cf82sm4466432b3a.200.2024.10.07.07.50.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 Oct 2024 07:50:19 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: akpm@linux-foundation.org Cc: torvalds@linux-foundation.org, keescook@chromium.org, alx@kernel.org, justinstitt@google.com, ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, catalin.marinas@arm.com, penguin-kernel@i-love.sakura.ne.jp, linux-mm@kvack.org, linux-fsdevel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, audit@vger.kernel.org, linux-security-module@vger.kernel.org, selinux@vger.kernel.org, bpf@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Yafang Shao <laoar.shao@gmail.com>, Quentin Monnet <qmo@kernel.org> Subject: [PATCH v9 4/7] bpftool: Ensure task comm is always NUL-terminated Date: Mon, 7 Oct 2024 22:49:08 +0800 Message-Id: <20241007144911.27693-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20241007144911.27693-1-laoar.shao@gmail.com> References: <20241007144911.27693-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspam-User: X-Rspamd-Queue-Id: 09F1DC000D X-Rspamd-Server: rspam01 X-Stat-Signature: ip6qm7fernqwog5raijc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SKlSEb4Tcas9hI0Jarn2gsAdC4rQH1rheiLoprFK/XXU7JjoEaAJ1EoQOJfoZTVaDp77fxjn0cqJbwWPYdZIMgaNEUD9hJfWvMEouDR2rm24A7qJSwhj7/pmL1Mfcpnxju78nG4fZp11A/gOvCuePyONM4l1lHOaskVU6wLlbybAKnyxtWs4CcnyVoqhHsXXsE8qcctvWCiD5ykdMuvCvs860eqdbjNkJuJksOXZWERowMC/vWYYSfkncMPRthyyW8FtnamJFlhPVLBwJdqHyAh+r1WvhHUmI6ZCKWQ/Su82IGdx1xjGT5PjtgKmbQv4gE5RspWmH3r4KifM2buTtr4GAI5uOQ9oRmmZIXACzl9CuaM581rjfDs4MLTJ8UMnPo7X4tVYX4XQ8xm9OT6GlqkZjCABIM0M5jbqY70nZB+7H0ONls+ezH4/7uneZoeAgWXJv3YmC90VEr 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: <linux-mm.kvack.org> List-Subscribe: <mailto:majordomo@kvack.org> List-Unsubscribe: <mailto:majordomo@kvack.org> |
Series |
Improve the copy of task comm
|
expand
|
diff --git a/tools/bpf/bpftool/pids.c b/tools/bpf/bpftool/pids.c index 9b898571b49e..23f488cf1740 100644 --- a/tools/bpf/bpftool/pids.c +++ b/tools/bpf/bpftool/pids.c @@ -54,6 +54,7 @@ static void add_ref(struct hashmap *map, struct pid_iter_entry *e) ref = &refs->refs[refs->ref_cnt]; ref->pid = e->pid; memcpy(ref->comm, e->comm, sizeof(ref->comm)); + ref->comm[sizeof(ref->comm) - 1] = '\0'; refs->ref_cnt++; return; @@ -77,6 +78,7 @@ static void add_ref(struct hashmap *map, struct pid_iter_entry *e) ref = &refs->refs[0]; ref->pid = e->pid; memcpy(ref->comm, e->comm, sizeof(ref->comm)); + ref->comm[sizeof(ref->comm) - 1] = '\0'; refs->ref_cnt = 1; refs->has_bpf_cookie = e->has_bpf_cookie; refs->bpf_cookie = e->bpf_cookie;