Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp298998rwb; Sun, 25 Sep 2022 21:13:49 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6nMh0qdJylnI80/Z8dWwN8iZfWTlrghc+Uq/k2awXBGOrmZASVg5Bd+JBqVGYtsKaTpf98 X-Received: by 2002:a05:6402:370a:b0:456:d006:6948 with SMTP id ek10-20020a056402370a00b00456d0066948mr13995782edb.90.1664165629632; Sun, 25 Sep 2022 21:13:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664165629; cv=none; d=google.com; s=arc-20160816; b=JLDCoEoBvHp/QVeBpTRa9SXA1wMKeDC14LnEizrLUJbXgqm7WYsgWRH54p+pOGiSSX tilAr3XK58/j8JuiW3U2JNClA4XbcJVIFV1iKDdWrE43x0/kNr20+WcZAgPLluI4frt3 ioF1qAUW7OBoE4c1u6KqP2K5spUFBcSpkbU4k+r/DqmXO8ETkRaSldV/tQPU9yaNHpO9 6wDM8H/cUg4KOrC+9Dr7M//mWGWbXAORNCAjL7DQsKIPHl8RDpPE9E69SSg+CYkdWYQV E3CwLj8D4LYcY/vwadtM3VfTOc0/JUEVVNrJvv6pgWXBgE3w8t/FqPUgw72j5ZAW8B6V j5Ww== 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:subject:cc:to:from:date; bh=qbcF+4iB7OqAw2bwpBxHyTgrBMEySUtohqGgRPaJraU=; b=Cx2zo0m0SLRwJEEWVBgjleevlOdlP01NJmcfu5oBh4/Q4QKeDVsmexzsT5rLCobpY9 hytKs2uvB6al/X+f5j/ODsz7/hFiEhX9oBgXJYXbUVGJmDRt1YEu/vgSxrmpFuDOk0RF Tlhb+eOvs+BAkfb+Idd4UgkT9iJjaxbeMf+9ia6IQ+BXtgl1ApnMs5jBJooWuGn3/GvL rehhMvlgauh2assunt+WBNGhjMnm9OJOfO0TiwgJneqtJyxeyp8MCqY9w5YMUxsMOgcZ UENqxJjyAtbx2/X8wh5c6VKPGAWNVq/KvEs4mD/3/pwb/IlY7mKd9hxo9CltQu2OnI4w Zxdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h7-20020a056402280700b00448ab5d3ba3si17102188ede.1.2022.09.25.21.13.15; Sun, 25 Sep 2022 21:13:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233222AbiIZClS (ORCPT + 99 others); Sun, 25 Sep 2022 22:41:18 -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 X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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