Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4026684pxb; Wed, 13 Oct 2021 18:52:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy5/vKjwT/KxlZn7/jKonojSExIVirLkcAXU8kUayOS/sKT3iyN22TZ+XFDhtZOjOGCoIgh X-Received: by 2002:aa7:c357:: with SMTP id j23mr4596484edr.145.1634176361698; Wed, 13 Oct 2021 18:52:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634176361; cv=none; d=google.com; s=arc-20160816; b=M0WUR4EWWUK5OycKp9t2iuA6PWGDJ7odr2fvYA0PmRCBYoomVVymbXrqlHFF9iylCR IhuOYhMALDruMOQRYyNfraEbbywLdPj/DXwQkAw7b8SScZxcxWOy/USdlWoWwI7A9izj Dc2GXB4so5jWj0uAKu3lryVdogu5tJDKXMgcy684+Lfy3PsxeELqM6PWxhqkOLgANDci w658yaEtwzJoFjUKOg00NduP9RxZnV6LfuKAK2gUAugpjwCJbNvf0qZKJiiq014FV1SA PLRn5GXiLfthBU6y0u4T6VSV6oY/o6TUl49Sp4597I9tXtSpXjtxVx+xRcEPdfLLojUA ++WA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=kVH0kaeOj57wkHN4yL00qa3HiDy3zcOXZu80Mp+X5lE=; b=clKP4UZOu/3z5mXMFyiZp/GfmdZS4CZ9bbje66QkY4YR9x9B/KfSG69p8sJgeVdOPM YcGMU9n2snJSJVktbA2HFFXhO8q3or9UdZznieyechJHHeoG8VKMtPIBV7MNgLSOeiDI yfsSybpn+HaOKSf8kTNPnyFyGsT/6h0vm/pfWeErnYEs8D3hUqhXCEsjSqrBdW8vtrfU 5XZ+Mgw0AAxK1UmihKnPE1YJfWGZE42FMjat5HmnU3fRfFWe7j4VNGwDouhpltG5nHa6 BKBZkcnYwyl7sIdgmWXJ3KMv6MWpz5QPzuRQAfyCY71NkeNmXbazVBRvFTNTb0Q3kIot +spA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=cdkMepIp; 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 y16si2543179edc.470.2021.10.13.18.52.18; Wed, 13 Oct 2021 18:52:41 -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=cdkMepIp; 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 S229910AbhJNBuw (ORCPT + 99 others); Wed, 13 Oct 2021 21:50:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36610 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229902AbhJNBuv (ORCPT ); Wed, 13 Oct 2021 21:50:51 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F009C061570 for ; Wed, 13 Oct 2021 18:48:47 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id t2so14365674wrb.8 for ; Wed, 13 Oct 2021 18:48:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kVH0kaeOj57wkHN4yL00qa3HiDy3zcOXZu80Mp+X5lE=; b=cdkMepIprdbSBOTb+X+Y/58dYEd6l6HL1vRJSBQ8lPCFcELewmNjvsTADlYAmQsZUI 9/3bb39OvnZpy/AtK6/BQDhoO1b+G0ogFzcpGf5ZfySk4eduB9ox25trwxKRkh7v2pXG NR6gNcVKkv1BRKp7P3DdJL5KaBqO3DMVjrqg/qnGKITbUs++XEQknErhhuH1rnKz5/4d 7oAzkVvi7tpO7DdASj71jeYyCs/L3N3vDcW8tFOVJJhVXBBMxFdwq59XluioyZd/uiBl xutsWAufc3uLWxn+S8c9bRVrD4K0Phekr3r+l84a60bVXVaHCLC68Y79ysOazBpuUCrs Nlsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kVH0kaeOj57wkHN4yL00qa3HiDy3zcOXZu80Mp+X5lE=; b=6JH1ZZ47t1v5cyFrHsiq2sTLmaEG/iWsvCX5quUMTA/cv+rND0X4Ti1Fus8nZ/kyhG VzoW6U5zLsMhSG3RsRnVpx7ziABwOkN/LNamaRf0Pu098P3IMSYvGEOhXjVQ4J8IaNl4 fJSdeHkKCtGErJSdyQpjnPw6oNHJS/3eAtjQH7wgdYz4XzFDJ71LXDdYEDU13HnWA2Nb Wq92hVwTIjR0eEC7rLk2SeZyOlc5Au7/+man0peV/7pi8IJ6nuvJbxTW9sEjWzxaTDpZ aSRdJpPz2x2zH3XqObuPvk7vjqMitzFtkp4USNgFY8iVzFYsTPEA/0uGP5O/F4Hg10eR JoFQ== X-Gm-Message-State: AOAM530NWp0wcFNDuMW75hW8qkNILwSsDA41lTiCiu2kLIvk3npr3bq9 s2D1R1N9ljvbOfWSimns+Fuog6ZXVcPo+ELNbIU= X-Received: by 2002:a05:6000:15c6:: with SMTP id y6mr3174423wry.210.1634176125813; Wed, 13 Oct 2021 18:48:45 -0700 (PDT) MIME-Version: 1.0 References: <20211013102346.179642-1-laoar.shao@gmail.com> <20211013102346.179642-3-laoar.shao@gmail.com> <20211013101921.0843aaf0@gandalf.local.home> In-Reply-To: <20211013101921.0843aaf0@gandalf.local.home> From: Yafang Shao Date: Thu, 14 Oct 2021 09:48:09 +0800 Message-ID: Subject: Re: [PATCH v4 2/5] connector: use __get_task_comm in proc_comm_connector To: Steven Rostedt Cc: Kees Cook , Peter Zijlstra , Petr Mladek , Al Viro , Andrew Morton , Valentin Schneider , Mathieu Desnoyers , qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, Dietmar Eggemann , Ingo Molnar , Juri Lelli , Vincent Guittot , Benjamin Segall , Mel Gorman , Daniel Bristot de Oliveira , David Miller , kuba@kernel.org, LKML , Vladimir Zapolskiy , David Howells Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Oct 13, 2021 at 10:19 PM Steven Rostedt wrote: > > On Wed, 13 Oct 2021 10:23:43 +0000 > Yafang Shao wrote: > > > --- 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 */ > > __get_task_comm() uses strncpy() which my understanding is, does not add > the nul terminating byte when truncating. Which changes the functionality > here. As all task comms have a terminating byte, the old method would copy > that and include it. This won't add the terminating byte if the buffer is > smaller than the comm, and that might cause issues. > Right, that is a problem. It seems that we should add a new helper get_task_comm_may_truncated(). -- Thanks Yafang