Message ID | 20240613023044.45873-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 24C41C27C6E for <linux-mm@archiver.kernel.org>; Thu, 13 Jun 2024 02:31:39 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B58306B00A2; Wed, 12 Jun 2024 22:31:38 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B089B6B00A3; Wed, 12 Jun 2024 22:31:38 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 981E66B00A4; Wed, 12 Jun 2024 22:31:38 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 7612D6B00A2 for <linux-mm@kvack.org>; Wed, 12 Jun 2024 22:31:38 -0400 (EDT) Received: from smtpin26.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay10.hostedemail.com (Postfix) with ESMTP id DB928C04EC for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:31:37 +0000 (UTC) X-FDA: 82224289434.26.90723C3 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf03.hostedemail.com (Postfix) with ESMTP id 0BE9F20007 for <linux-mm@kvack.org>; Thu, 13 Jun 2024 02:31:35 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ROPaub8Q; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1718245895; 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=c7QH8g7nY2INvVrL4NU75ftNhN6FL7HL04IiCAjwJmE=; b=GOk8HNrIKE8MI5kvzVsG6Mota5WZiUjUbH0gz9EVHaI5dSTFiklIr9W/RJ2a3MeZOLjPf4 80XYPzr4adMnIvGHLromVwH5wNvy+DVYZ2Y9kcOmzgV01TeRupaIIT93DeuLF4WpjK817a rdXQuBEYJ46H1ZxBMDjKinV0EW3JYJA= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=ROPaub8Q; spf=pass (imf03.hostedemail.com: domain of laoar.shao@gmail.com designates 209.85.214.180 as permitted sender) smtp.mailfrom=laoar.shao@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1718245895; a=rsa-sha256; cv=none; b=kvvAxKuGoSGUumPyU8u8OGSVKk4ITGc5ZeXAwXpwH1iwDNsZbzirlv1h8O4AOjzQzahq3w 3tjX4Svvz1HkFrjI2JS6/YQgeRDiJpeFhOlKdoZxVKHZC0UV0JayfNsfI/VpYPeqQo9vm6 9NmS5+QtXKCdjXHoZzJIfxFI4l3zD6k= Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-1f32a3b9491so5300035ad.0 for <linux-mm@kvack.org>; Wed, 12 Jun 2024 19:31:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1718245895; x=1718850695; 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=c7QH8g7nY2INvVrL4NU75ftNhN6FL7HL04IiCAjwJmE=; b=ROPaub8QEtC1bbmt/a48HM6qVXpl1qEDkq0zhUa+Wa3OjWmVCwD7XLqwpsPBPBhT/E fZ6XeIV2RCy96qsJAAYo9NvCP1zIXrx6gEUfGftPnIQN9FAx1L96WwE+/hemwceQBKFu ncRQiJEbQOKaJajN6dW+2qrrybyu8RShRDbGGBYVLP2aDP9bQK6cNJKnRv6Bi94W2zPA wwXlQVhO9PtJqVOWM1+bAW/m+ZzINJZssrVU+Ijh8SirdBxTHKgcKHqAAT6sS5Mv9Kin swae368qgZxROZgX1sfuIRCqhTuwcUV2Sb9zn1xJuv5xufRawUPcoVNvg0SnX83ppu1G YNQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718245895; x=1718850695; 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=c7QH8g7nY2INvVrL4NU75ftNhN6FL7HL04IiCAjwJmE=; b=Jk94+OtIjlnN3bOgDK5phIhwBWXEETLBzzaFWWxT0ohlC1AXAy4LDm1vhm+8sZi4Az Jm1ZeTvRe7wXjAITKHTKXRVJoJKoRjULTyMfIgzDk4AS/fCxmOnGZXeY0K4Phad1yq8C t3kboODXvN6ZADpopY3yw9T3UaXvPQGkbtrh0y1zv3AeTl6r4lk+iOEpy66EjeJLUSdv cH+lNbI7QOOEhpr70Bc8K8SpKQM1T4Fslek602m7A/4Ik7nOq3bN3WPruvIExIqQwkBY VZjcnr6T4gRg0a8YCfRAFX5V+NvhSsubb0WwULnduBWtNKzoK3lywxKiZUuxvSbCYiga 3K4w== X-Forwarded-Encrypted: i=1; AJvYcCXQrXPTLRr7WDUNrdaYBK5Aiw11Ul30za/J/mh2p/uwu+jKEubJIyt6QG4CmWAG6a5k/4vt7dTMsR0f2A6t0nlsZVg= X-Gm-Message-State: AOJu0YwhwsoZbGqVLBYsWYDme45edK5XMFEf5hjA51roxBcI1HkYKdxd xmgwhmEEiLl5C0KnxextuOhoK72x+5YCjf8NwCC625PWfbolD/GB X-Google-Smtp-Source: AGHT+IFO0RiQEuS+ZZx5NhUKFkro4pSWALq4fQpBCAuUBHe6UDJpEGOEOlucSptFPDnQxh/E7HkfRA== X-Received: by 2002:a17:903:2283:b0:1f7:2051:18ba with SMTP id d9443c01a7336-1f83b565dbbmr48444305ad.14.1718245894762; Wed, 12 Jun 2024 19:31:34 -0700 (PDT) Received: from localhost.localdomain ([39.144.105.92]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-1f855f4d159sm1755695ad.289.2024.06.12.19.31.26 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 Jun 2024 19:31:34 -0700 (PDT) From: Yafang Shao <laoar.shao@gmail.com> To: torvalds@linux-foundation.org Cc: ebiederm@xmission.com, alexei.starovoitov@gmail.com, rostedt@goodmis.org, 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 v2 04/10] bpftool: Ensure task comm is always NUL-terminated Date: Thu, 13 Jun 2024 10:30:38 +0800 Message-Id: <20240613023044.45873-5-laoar.shao@gmail.com> X-Mailer: git-send-email 2.30.1 (Apple Git-130) In-Reply-To: <20240613023044.45873-1-laoar.shao@gmail.com> References: <20240613023044.45873-1-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Stat-Signature: mde6x31cpaz6da7e7cej7powt8r5z8n3 X-Rspam-User: X-Rspamd-Queue-Id: 0BE9F20007 X-Rspamd-Server: rspam02 X-HE-Tag: 1718245895-165668 X-HE-Meta: U2FsdGVkX19UCBzmBbzXaZcyFhnm+DCeZrFoHhZWRrikT5xR3D7Jj4mDRJ10rEdks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/z4jI9eVGJD5fdtHs9prq9voGBIcPtHEpFYNBPHpOaBcV8pvJolAQnXhWgAorAgsulMO2BwwIinRTnn3l/gtALskxu/EXFgwzDy+3p/dxSGgDLJtdbsexLbrMc8EBGsUeKWp86ccAVXNe1rhOZjixOQjM8EU5kASrYbvMAKcL5baXQ6vnM3VyLn2PvOK3v4c1FuwntwnbJnQzTFbtjT+XeOMOlzOpN5oXq47JsPQ1qD7akjCUfClHKeTze+ni/35kQMiI4rQ+R4YFx2yQawmsFO1Fq2ce5sskicms2PoYdIB7JcK261lVSL20oAXNbw/tjUgJa8qKJI4qkxEnxKGNu9T10iblljBthGoP5stuZhgalKWXbOU= 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;