Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1306773pxb; Thu, 21 Oct 2021 21:02:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxXFM5olu9W31PXSoKDilO6GX7Y74M/qVbevphQwInUb4fMPFPDuPuB3owl/l89mgpqN4t6 X-Received: by 2002:a63:7d46:: with SMTP id m6mr7663262pgn.409.1634875358816; Thu, 21 Oct 2021 21:02:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634875358; cv=none; d=google.com; s=arc-20160816; b=rx5zgK2U2dI9I53yFX6VcPSECGPRVjC2Bl8ivm9K2EKcgDwimS4QtAghA+INwPtZy8 NW+wQNRJWuxNm08i1mQbbHXESNIUsAV2NHIbNTJ8RLD0E8wv94412rxPHTlkj/trJjx+ aep63AmpFhI2vMYP79hy7LtQ4ZfRM9x2E75VAZQ81VtMyawPRSq5gSQZbIgHQP3g/tSn AiIDoGPXjba4eRlZy6eb1UCXj7l3pzufCtA54MDUO6F2drxGktdrYzvj13gitTNZTjbw uGLPkNu4BmaCvuYqR7pxm6R/iCZAGmZLuIRef7jKmx7V2B394Dt6HJPjgnN81FMwxSPH 8T5Q== 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=63mhhziKLiqFO4zSrh9ukWKmqfg2gNncagqLuotvmtA=; b=C0vFfTlbSxJU4tcrkQbn2HdzmQoXoIgwU5ew0wDT9Pbph7T4eiSrD1vbCWX0sLU+Dv YOocj3aLlcyM5pKRhPY3zPIo2w9ezWlO669ESbf4VMI9K9H6QWSsTMsCOye9Jcp7Wc7s J3VvmQss3/4g/+PPoheD9c8RwzS9jl6vYwCMhxO5t/3rfCww44to+oWQl5woQrWdNze9 lWmX+c3nBgoVKK250JNhNKc4IkIV8T1+pGYxLQ1c+t05sN5D3QcW3vsROtNHnmA18Mo4 EuQJ4NxlrI4R83qYrOVqdVsLw9W9BXq+tFHZY15UchzybPW5bJXcVg/tZPZcBxqDpD/C hLrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=X39ypBn4; 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 on12si11411293pjb.40.2021.10.21.21.02.16; Thu, 21 Oct 2021 21:02:38 -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=X39ypBn4; 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 S229507AbhJVEDL (ORCPT + 99 others); Fri, 22 Oct 2021 00:03:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229505AbhJVEDK (ORCPT ); Fri, 22 Oct 2021 00:03:10 -0400 Received: from mail-pj1-x102d.google.com (mail-pj1-x102d.google.com [IPv6:2607:f8b0:4864:20::102d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8CFBBC061348 for ; Thu, 21 Oct 2021 21:00:53 -0700 (PDT) Received: by mail-pj1-x102d.google.com with SMTP id np13so1990566pjb.4 for ; Thu, 21 Oct 2021 21:00:53 -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=63mhhziKLiqFO4zSrh9ukWKmqfg2gNncagqLuotvmtA=; b=X39ypBn4CFGyhh2sL9znOr84NnhkCZ2dA8quRYgjwHWkDgmOEmgYHM8c6Mom/wBP40 SU5jAJWBBxqkVabzf7HmWjQafrkN1Yp3s0phP8OooZWlipf8a3KFdcohgAYXL2YE4ddy w0UbekNVppvN0r+cy2CltOEugZ45mOSYsGbO4= 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=63mhhziKLiqFO4zSrh9ukWKmqfg2gNncagqLuotvmtA=; b=ap5KsgrqzC1ip2zV8HFqNX2/vbpGSv0ENgaMe8NhEcp8j8J9t1mh9+GaOTh+vcsbIz 14hMaJ5EpHZB8zPFAEFfeSa8Sq9Jmuo5frkmLjLRM8clEORQg/Td2fvtlKlRMfLBA+V2 CQjJBsSJy+l093AhPRl9iZycbB6vHtsn7jLfKn5xMHf9ixl9QcHBgSktykjzyygbAz/d 2XeY/o1uVLvPVEF9cuKasM45d3h9XW1nwABQVNSfu1kZQ4hd8ndfOZr4V87wITbq5Sjo TIGViMq/LoTu+X6WZf36RV72u2DHS+yenv5DypG8q4V+TpFF5nhHn/6X/NDedtb/Xmsw EL9Q== X-Gm-Message-State: AOAM533gB7YIk0Clx4We5opqQrrduKflRImVpowWs9BNP1RBuq1Cpgmv e+FXcG7fDxm2ANvqAEo0H/DOGg== X-Received: by 2002:a17:902:a50f:b029:11a:cd45:9009 with SMTP id s15-20020a170902a50fb029011acd459009mr9269460plq.38.1634875252833; Thu, 21 Oct 2021 21:00:52 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id a7sm7618987pfo.32.2021.10.21.21.00.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 Oct 2021 21:00:52 -0700 (PDT) Date: Thu, 21 Oct 2021 21:00:51 -0700 From: Kees Cook To: Andrew Morton Cc: Yafang Shao , 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, netdev@vger.kernel.org, bpf@vger.kernel.org, linux-perf-users@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, oliver.sang@intel.com, lkp@intel.com Subject: Re: [PATCH v5 00/15] extend task comm from 16 to 24 for CONFIG_BASE_FULL Message-ID: <202110212053.6F3BB603@keescook> References: <20211021034516.4400-1-laoar.shao@gmail.com> <20211021205222.714a76c854cc0e7a7d6db890@linux-foundation.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211021205222.714a76c854cc0e7a7d6db890@linux-foundation.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Oct 21, 2021 at 08:52:22PM -0700, Andrew Morton wrote: > On Thu, 21 Oct 2021 03:45:07 +0000 Yafang Shao wrote: > > > This patchset changes files among many subsystems. I don't know which > > tree it should be applied to, so I just base it on Linus's tree. > > I can do that ;) > > > There're many truncated kthreads in the kernel, which may make trouble > > for the user, for example, the user can't get detailed device > > information from the task comm. > > That sucked of us. > > > This patchset tries to improve this problem fundamentally by extending > > the task comm size from 16 to 24. In order to do that, we have to do > > some cleanups first. > > It's at v5 and there's no evidence of review activity? C'mon, folks! It's on my list! :) It's a pretty subtle area that rarely changes, so I want to make sure I'm a full coffee to do the review. :) > > 1. Make the copy of task comm always safe no matter what the task > > comm size is. For example, > > > > Unsafe Safe > > strlcpy strscpy_pad > > strncpy strscpy_pad > > bpf_probe_read_kernel bpf_probe_read_kernel_str > > bpf_core_read_str > > bpf_get_current_comm > > perf_event__prepare_comm > > prctl(2) > > > > 2. Replace the old hard-coded 16 with a new macro TASK_COMM_LEN_16 to > > make it more grepable. > > > > 3. Extend the task comm size to 24 for CONFIG_BASE_FULL case and keep it > > as 16 for CONFIG_BASE_SMALL. > > Is this justified? How much simpler/more reliable/more maintainable/ > would the code be if we were to make CONFIG_BASE_SMALL suffer with the > extra 8 bytes? Does anyone "own" CONFIG_BASE_SMALL? Gonna go with "no": $ git ann init/Kconfig| grep 'config BASE_SMALL' 1da177e4c3f41 (Linus Torvalds 2005-04-16 15:20:36 -0700 2054)config BASE_SMALL And it looks mostly unused: $ git grep CONFIG_BASE_SMALL | cut -d: -f1 | sort -u | xargs -n1 git ann -f | grep 'CONFIG_BASE_SMALL' b2af018ff26f1 (Ingo Molnar 2009-01-28 17:36:56 +0100 18)#if CONFIG_BASE_SMALL == 0 fcdba07ee390d ( Jiri Olsa 2011-02-07 19:31:25 +0100 54)#define CON_BUF_SIZE (CONFIG_BASE_SMALL ? 256 : PAGE_SIZE) Blaming lines: 100% (46/46), done. 1da177e4c3f41 (Linus Torvalds 2005-04-16 15:20:36 -0700 28)#define PID_MAX_DEFAULT (CONFIG_BASE_SMALL ? 0x1000 : 0x8000) 1da177e4c3f41 (Linus Torvalds 2005-04-16 15:20:36 -0700 34)#define PID_MAX_LIMIT (CONFIG_BASE_SMALL ? PAGE_SIZE * 8 : \ Blaming lines: 100% (162/162), done. f86dcc5aa8c79 (Eric Dumazet 2009-10-07 00:37:59 +0000 31)#define UDP_HTABLE_SIZE_MIN (CONFIG_BASE_SMALL ? 128 : 256) 02c02bf12c5d8 (Matthew Wilcox 2017-11-03 23:09:45 -0400 1110)#define XA_CHUNK_SHIFT (CONFIG_BASE_SMALL ? 4 : 6) a52b89ebb6d44 (Davidlohr Bueso 2014-01-12 15:31:23 -0800 4249)#if CONFIG_BASE_SMALL 7b44ab978b77a (Eric W. Biederman 2011-11-16 23:20:58 -0800 78)#define UIDHASH_BITS (CONFIG_BASE_SMALL ? 3 : 7) -- Kees Cook