Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1458477pxb; Thu, 7 Oct 2021 08:11:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyOcItVUFTGRkRGdf52WaE32fuef8QZCnmC/mC9DYD4oHh+TgLwVYz1SNph5geNMLI2K6Tk X-Received: by 2002:a63:f963:: with SMTP id q35mr184383pgk.132.1633619507289; Thu, 07 Oct 2021 08:11:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633619507; cv=none; d=google.com; s=arc-20160816; b=v1XpecBtxwaSpLGwrwTwC79VU/9QtF5nZolVmoUuBRtl0drxVx6QySyO4iDpLcC7he 8hKS1mEYeKaHaxJPYzGhJdjpSzsc6RytWivHB0q1pY/jLElXN7vhyzK4fs8EQo+hF5hY KYpgdv0Lc1heZkUXOsOQ+Z53Xt+TdLiWj5aVZPho15KnM+Nd8jZT6REbzMsPzHQ7AdJP GfUcXl3kGhyVzOcPkf8dcZkP30xIRnIbjiFEIzl/WKvxNF0AbR6ThXvzzkPlliqt0peR 5draa6j4AMkn1TeJjuq0n/HeRnjH+ZZ4dFWq2wIe+9Do0N7FkAoNaovWsy1rYMw4om75 IcOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=EwBFVgL0rWbgcfbyCDG1TsRp9Ifys2zsPzP9eEcQnP8=; b=vjGdADqvVkWE7HeergcuOmeQUZIHWjEDWuH66uzAGqCBTicaIR4vDurh4kTXxIC2sO z+dAGKS+YBPMS2i8a3vW6M9Y42WrwB6zRTn2DbuZ8dPcpki41tIMGr8UOzNxJrDJupG6 Meu/UCYDsnrhDPYa6Sm2sMl3PjCn1XikUTsp1Rz1LATkctkHHQf07nlKY4TbyQexgwHr bmTNKnFMzstzsKZ72ftOd0y0by7cWvX3WctE5nZzvyHBwd28/OKY6qUahZUjFx1ZaoLc sj3B/9SV7iKNh3BCMgSW4Ywcd8FpajyiGIta6Hfs6qEn337asRJfUoRlqm8/5711QL1G b3/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Lt2MndVh; 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=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z11si29811439pla.170.2021.10.07.08.11.24; Thu, 07 Oct 2021 08:11:47 -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=@chromium.org header.s=google header.b=Lt2MndVh; 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=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242372AbhJGPLs (ORCPT + 99 others); Thu, 7 Oct 2021 11:11:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242312AbhJGPLr (ORCPT ); Thu, 7 Oct 2021 11:11:47 -0400 Received: from mail-pj1-x1036.google.com (mail-pj1-x1036.google.com [IPv6:2607:f8b0:4864:20::1036]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 115F5C061570 for ; Thu, 7 Oct 2021 08:09:54 -0700 (PDT) Received: by mail-pj1-x1036.google.com with SMTP id ls18-20020a17090b351200b001a00250584aso6650795pjb.4 for ; Thu, 07 Oct 2021 08:09:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=EwBFVgL0rWbgcfbyCDG1TsRp9Ifys2zsPzP9eEcQnP8=; b=Lt2MndVhQ6hEVWM3iH8Kh6Tp3WCXCBYbRdJJD8TrlN5XO4q9z1/5o39ICKHnf+oO/p Ug5Vv2y8LHjMCYy6uVFN03eFh0AyYJsueTHlrT7Fo+UGvzUwDY4310poHgxXfOtOTTTN tilWf03y6mHUBEzx9gTWv+ASxy76ndmGWfKqc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=EwBFVgL0rWbgcfbyCDG1TsRp9Ifys2zsPzP9eEcQnP8=; b=huZI59jEn4EJcxG3BhLGtZhUG4OPq2AkA7/em6ULiLNygHkZK0sHkeVH2JWtNINLNv h5GUHFbAxrIrrSuP2rrPyyrsMOnUJEP1OmePqs8CKMc0TW49i6vZ5SwAF81X4/4uJWMl 85piDAl3A4j8q1nWJAiwZHXdMoRFV8YlNKmkk5F0jgdqjlzIWWFpDcNiNS/c0p8Vpydl 1vR0XMQF0vaMb4l59odAZMzMLacEqKlHordGWi5BAQCHxSU65Zlm5LbuECqR6yZR/D7N f4yfU2VHhN9rRam/9sZgpuYwQzE5lkSf4ojbLXohv8c2P4hTLEZSMPgWPDNVptq7CKI+ jh/A== X-Gm-Message-State: AOAM531z0g5kE/2lCLH6aD24gX77ayGIrnX5iBJtdyX696wUFuwVE6Tc I3L81G6yS7jGs0Sc+MqzS4ladA== X-Received: by 2002:a17:90a:9f91:: with SMTP id o17mr6036386pjp.225.1633619393507; Thu, 07 Oct 2021 08:09:53 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n207sm15374608pfd.143.2021.10.07.08.09.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Oct 2021 08:09:53 -0700 (PDT) Date: Thu, 7 Oct 2021 08:09:52 -0700 From: Kees Cook To: Yafang Shao Cc: pmladek@suse.com, viro@zeniv.linux.org.uk, akpm@linux-foundation.org, peterz@infradead.org, valentin.schneider@arm.com, mathieu.desnoyers@efficios.com, qiang.zhang@windriver.com, robdclark@chromium.org, christian@brauner.io, dietmar.eggemann@arm.com, mingo@redhat.com, juri.lelli@redhat.com, vincent.guittot@linaro.org, rostedt@goodmis.org, bsegall@google.com, mgorman@suse.de, bristot@redhat.com, linux-kernel@vger.kernel.org, Vladimir Zapolskiy Subject: Re: [PATCH v2 1/4] cn_proc.h: use TASK_COMM_LEN instread of 16 in struct proc_event Message-ID: <202110070808.43B5AAEB9@keescook> References: <20211007120752.5195-1-laoar.shao@gmail.com> <20211007120752.5195-2-laoar.shao@gmail.com> <202110070750.8754AA33@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202110070750.8754AA33@keescook> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 07, 2021 at 07:51:35AM -0700, Kees Cook wrote: > On Thu, Oct 07, 2021 at 12:07:49PM +0000, Yafang Shao wrote: > > struct comm_proc_event was introduced in commit > > f786ecba4158 ("connector: add comm change event report to proc connector"). > > It seems that there is no strong reason we must define the comm as a > > hardcode 16 bytes. So we can use TASK_COMM_LEN instead. > > > > Signed-off-by: Yafang Shao > > Cc: Vladimir Zapolskiy > > Cc: Kees Cook > > Cc: Al Viro > > Cc: Petr Mladek > > --- > > include/uapi/linux/cn_proc.h | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/include/uapi/linux/cn_proc.h b/include/uapi/linux/cn_proc.h > > index db210625cee8..351d02786350 100644 > > --- a/include/uapi/linux/cn_proc.h > > +++ b/include/uapi/linux/cn_proc.h > > @@ -110,7 +110,7 @@ struct proc_event { > > struct comm_proc_event { > > __kernel_pid_t process_pid; > > __kernel_pid_t process_tgid; > > - char comm[16]; > > + char comm[TASK_COMM_LEN]; > > } comm; > > Hrmm. This is UAPI -- we can't change it without potentially breaking > things (i.e. userspace binaries have this size built in, so we can't > just change the size). This will either need to stay truncated, or may > need a new interface with a variable-sized structure... Specifically, this is needed for this series: diff --git a/drivers/connector/cn_proc.c b/drivers/connector/cn_proc.c index 646ad385e490..34bcba25c488 100644 --- a/drivers/connector/cn_proc.c +++ b/drivers/connector/cn_proc.c @@ -230,7 +230,9 @@ 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 */ -- Kees Cook