Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp582499pxb; Mon, 25 Oct 2021 14:16:41 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeVqmNW/jSy/6juBeIFyqityof45A9LgwE0PKe6PWUmkOl2Y0MVLjKRdUVKGlqkhJ7cLns X-Received: by 2002:a17:90b:1bc6:: with SMTP id oa6mr38421102pjb.206.1635196601285; Mon, 25 Oct 2021 14:16:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635196601; cv=none; d=google.com; s=arc-20160816; b=yNxpMPms7XgT/asAeqFhEKxGCSSkVXGFEwS1eCF9STEGnmTuy37IPm90OsskghLACw Z9TVHkRl3ABtItA6o5zyENcPCWhpthJXCkh1Ka/hgSFgWZ/lxnDr3rKiublWluCoeB00 tn70K182V5Yi8OKtZI3YtsKZl9ezTEcK+BS8gvRpH7CmCfwgNa2SwWpz+vfMGutx6TCo iwVmvvOWPgYLL1yzWQbANdV9Q+8wdP74FY0JPg0Ik6UuMIKn4Dv2bHym3kAdkWKYrPL7 ktPu+ZbmNSk1XkZ66DUmi3bkal1LUGMa0AqcD+ZljxbYt/VwdJ5zKJ6g82/GX1aOZmLB aTJw== 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=z00lUsatKc2imgSiGWIDZF0uIcC3k7FGBboNiOBf+rE=; b=t4QegkGCmVZ5D8ta17PWTOqsNX0MhuGL7FatS7A8n7TvE3Aq2EIchPVBBM3LDHq/v4 U7NInfzYoTRFn5BztePRWzZleS1J3afYmq7GNOCJ4LZlVGsyX0Xhn4QTr42h126zatic cn/mLswcMCU0WhXJ2HwDLPCB+4P1do+2Wwht/XgqCtne9rT9N3hBr4K70qq6bMfvNZHs xwFFk76l/Mr0gEzN12MSVxLZZpL2/OrImrTg94fWkTkqT8JVA5/5p30BOYsfTXI/mHDO MAvWJA5/+Zxviv+ZupMZCUfGdoioNX4UuDQUKXlByxwNYYKp1uLEkggcKdWOH2VePEYV 7nEg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=eId9LLzy; 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 z5si27971337pjh.44.2021.10.25.14.16.26; Mon, 25 Oct 2021 14:16: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=@chromium.org header.s=google header.b=eId9LLzy; 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 S235045AbhJYVRM (ORCPT + 99 others); Mon, 25 Oct 2021 17:17:12 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234960AbhJYVRH (ORCPT ); Mon, 25 Oct 2021 17:17:07 -0400 Received: from mail-pg1-x52e.google.com (mail-pg1-x52e.google.com [IPv6:2607:f8b0:4864:20::52e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 85DCAC061226 for ; Mon, 25 Oct 2021 14:14:37 -0700 (PDT) Received: by mail-pg1-x52e.google.com with SMTP id g184so11938788pgc.6 for ; Mon, 25 Oct 2021 14:14:37 -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=z00lUsatKc2imgSiGWIDZF0uIcC3k7FGBboNiOBf+rE=; b=eId9LLzyLrwvA9SohTjGnv3oVmE6ccHoQVKehocpPnrGwwPgiFRy84ppKNC+f37VpV mRt73YFIU/x33pg3q5YAAetghE/xrqlePxhK0vjYN35FOjfLpjl+tvmFfeY2XYDAeKh6 sn/dyNA2Nqsw61mI5VTCzsVgIk1CFPaNCLrGQ= 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=z00lUsatKc2imgSiGWIDZF0uIcC3k7FGBboNiOBf+rE=; b=lwLqbWPNrdAWGVt1TQXVM4p6HRVG8iQPEZKg/A8VeTBKowHxFK9T+SsBrJ1XbPRyFA R5igUUHT5zXa24lOcJJ+pzAQgQypeKo/Zxd/W7b2JczSXLlHq/2Rj1walgPPkAQN85tk yOg9QLzcIX+eRzDjiKU4gSK6mM9sReDzAfUgqU0ApFamkhwHHPoeYDmcA0Pumgg/gR04 1WbdnxUgM4kgDbNLMiENXFLdDiWkrOA9VCBvK3jw4nR3XZsvkoAu1tfBuySR/Kc9EQwG E7fy2g3eaLnjSnYHccACsuo37ocpnVu4wGJVw1nZYecARySZXa+ok0MPepdM3yj/0hLf BCCA== X-Gm-Message-State: AOAM5337D94DzkV6H8Cwkn4yYDefJfpcsGXj5PIcdiFeSyOGOsP+A+/6 VK6CuSEXqvaiwkfuDf1vNF9Zkg== X-Received: by 2002:a05:6a00:2388:b0:44d:4b5d:d5e with SMTP id f8-20020a056a00238800b0044d4b5d0d5emr20949254pfc.80.1635196477239; Mon, 25 Oct 2021 14:14:37 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id t3sm16694772pgu.87.2021.10.25.14.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Oct 2021 14:14:36 -0700 (PDT) Date: Mon, 25 Oct 2021 14:14:36 -0700 From: Kees Cook To: Yafang Shao Cc: akpm@linux-foundation.org, rostedt@goodmis.org, mathieu.desnoyers@efficios.com, arnaldo.melo@gmail.com, pmladek@suse.com, peterz@infradead.org, viro@zeniv.linux.org.uk, valentin.schneider@arm.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, davem@davemloft.net, kuba@kernel.org, ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, kafai@fb.com, songliubraving@fb.com, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, dennis.dalessandro@cornelisnetworks.com, mike.marciniszyn@cornelisnetworks.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com, Andrii Nakryiko , Vladimir Zapolskiy , David Howells Subject: Re: [PATCH v6 03/12] drivers/connector: make connector comm always nul ternimated Message-ID: <202110251411.93B477676B@keescook> References: <20211025083315.4752-1-laoar.shao@gmail.com> <20211025083315.4752-4-laoar.shao@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211025083315.4752-4-laoar.shao@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Oct 25, 2021 at 08:33:06AM +0000, Yafang Shao wrote: > connector comm was introduced in commit > f786ecba4158 ("connector: add comm change event report to proc connector"). > struct comm_proc_event was defined in include/linux/cn_proc.h first and > then been moved into file include/uapi/linux/cn_proc.h in commit > 607ca46e97a1 ("UAPI: (Scripted) Disintegrate include/linux"). > > As this is the UAPI code, 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). To prepare for the followup change - extending task > comm, we have to use __get_task_comm() to avoid the BUILD_BUG_ON() in > proc_comm_connector(). I wonder, looking at this again, if it might make more sense to avoid this cn_proc.c change, and instead, adjust get_task_comm() like so: #define get_task_comm(buf, tsk) __get_task_comm(buf, __must_be_array(buf) + sizeof(buf), tsk) This would still enforce the original goal of making sure get_task_comm() is being used on a char array, and now that __get_task_comm() will truncate & pad, it's safe to use on both too-small and too-big arrays. -- Kees Cook