From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AB140C6FA82 for ; Mon, 26 Sep 2022 02:41:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233233AbiIZClT (ORCPT ); Sun, 25 Sep 2022 22:41:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233410AbiIZClB (ORCPT ); Sun, 25 Sep 2022 22:41:01 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 694B926AF4 for ; Sun, 25 Sep 2022 19:40:59 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id EAF63616D0 for ; Mon, 26 Sep 2022 02:40:58 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B094AC433C1; Mon, 26 Sep 2022 02:40:57 +0000 (UTC) Date: Sun, 25 Sep 2022 22:42:04 -0400 From: Steven Rostedt To: Kassey Li Cc: , , , Subject: Re: [PATCH v2] cgroup: align the comm length with TASK_COMM_LEN Message-ID: <20220925224204.4e5d341e@gandalf.local.home> In-Reply-To: References: <20220923075105.28251-1-quic_yingangl@quicinc.com> <20220923110044.7261afa0@gandalf.local.home> 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 Mon, 26 Sep 2022 10:18:55 +0800 Kassey Li wrote: > >> @@ -139,12 +139,12 @@ DECLARE_EVENT_CLASS(cgroup_migrate, > >> __entry->dst_level = dst_cgrp->level; > >> __assign_str(dst_path, path); > >> __entry->pid = task->pid; > >> - __assign_str(comm, task->comm); > >> + memcpy(__entry->comm, task->comm, TASK_COMM_LEN); > I think the problem is here, __assign_str using strcpy > the task->comm here tail is not '\0' > that's why it out of bounds access. > If this is the case, then there's a lot more than just tracing that will break. There are other places in the kernel has used strcpy() on task->comm, and many more that do "%s" on task->comm, which would also crash on this. > do you want to this version or just modify the memcpy or strncpy to do > with a known length ? please give suggest so I can modify . I'm guessing a problem exists elsewhere that makes it look like this is the issue. I suggest finding where the '\0' is dropped (if that is indeed the case). -- Steve