Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1481793pxb; Tue, 26 Oct 2021 09:47:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyd77wa1ik5jmOiEeFbm0rTCcwSQnE8LL5MLWn/bFvFxaVR5iz6mdgF6FbvCxV/vDirKDp1 X-Received: by 2002:a05:6a00:2283:b0:47c:494:1177 with SMTP id f3-20020a056a00228300b0047c04941177mr9600356pfe.69.1635266822106; Tue, 26 Oct 2021 09:47:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635266822; cv=none; d=google.com; s=arc-20160816; b=K4/u/91nAa8X6fjXSFSdnSDvQ+sAyixzoCwmlivp5CeQihzcldkx6yt/rXZQnCj2wW GyGjEGJmCohw6M+l429xHnYsXAkbhJhn5MNqMhnMdMzT/voYxuvGQfjb1t9VniXVPzKh IOQe+aNomoIi6AUq4vSqVmk21BpJEcLAqyqgDHOJPN5oFhumw12szziQBEMCQ7udww5J hmKeFFblhl/BRvvFkUet2IqdEdnfxFxNNTLkm+3gyPfYeHNXlwAg7BmHYLEdNRyFGo+8 ZZsKMu3oIa1oBV5AaDUV7D9o7AsEmQ7HMGJiKUp1EQADSuF5w1U/2hmWIFTIBaTk68+2 3dDA== 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=KL18mecp+SMLA07pV0ICPmPu5vLbEcjlWMyyChcoJN8=; b=M94FH+x3h0037P+jth5hQSG8WdBS6A35rhxNo2tZ2Nf6N9nvEfu841Z8GP5pFRzDsE 8MIFSOXP+/cJNTUS7g6iJ3nXJIVRuh06ZuewodtHxduQtXRq/pGiwic9D6Zha3QfHcal WCVdIUJ2nI0D92x0nBDF/puff2YAatWiOmtD/rHsrSrNfQGtUCVAReD0Ag3rPY3iCVwI Lm1tUPmsrm/+kyOC8v+xGOEsMG5KjpckHI1pO+IC1pqckj8DsFoethYQygL21SBjUb5T WNjubwN63NMM1fSovCLzCXVE7ynwBpymLP5M2rxnVhqFGkjxre8OO7FKSEeqS/Ssjs/C oZ/g== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b17si9068115pfl.47.2021.10.26.09.46.49; Tue, 26 Oct 2021 09:47:02 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236178AbhJZNOn (ORCPT + 99 others); Tue, 26 Oct 2021 09:14:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:57748 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230324AbhJZNOk (ORCPT ); Tue, 26 Oct 2021 09:14:40 -0400 Received: from gandalf.local.home (cpe-66-24-58-225.stny.res.rr.com [66.24.58.225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 18A7360C49; Tue, 26 Oct 2021 13:12:13 +0000 (UTC) Date: Tue, 26 Oct 2021 09:12:11 -0400 From: Steven Rostedt To: Yafang Shao Cc: Kees Cook , Andrew Morton , Mathieu Desnoyers , Arnaldo Carvalho de Melo , Petr Mladek , Peter Zijlstra , Al Viro , Valentin Schneider , Qiang Zhang , robdclark , christian , Dietmar Eggemann , Ingo Molnar , Juri Lelli , Vincent Guittot , David Miller , Jakub Kicinski , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Martin Lau , Song Liu , Yonghong Song , john fastabend , KP Singh , dennis.dalessandro@cornelisnetworks.com, mike.marciniszyn@cornelisnetworks.com, dledford@redhat.com, jgg@ziepe.ca, linux-rdma@vger.kernel.org, netdev , bpf , "linux-perf-use." , linux-fsdevel@vger.kernel.org, Linux MM , LKML , kernel test robot , kbuild test robot , Andrii Nakryiko Subject: Re: [PATCH v6 08/12] tools/bpf/bpftool/skeleton: make it adopt to task comm size change Message-ID: <20211026091211.569a7ba2@gandalf.local.home> In-Reply-To: References: <20211025083315.4752-1-laoar.shao@gmail.com> <20211025083315.4752-9-laoar.shao@gmail.com> <202110251421.7056ACF84@keescook> 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 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 26 Oct 2021 10:18:51 +0800 Yafang Shao wrote: > > So, if we're ever going to copying these buffers out of the kernel (I > > don't know what the object lifetime here in bpf is for "e", etc), we > > should be zero-padding (as get_task_comm() does). > > > > Should this, instead, be using a bounce buffer? > > The comment in bpf_probe_read_kernel_str_common() says > > : /* > : * The strncpy_from_kernel_nofault() call will likely not fill the > : * entire buffer, but that's okay in this circumstance as we're probing > : * arbitrary memory anyway similar to bpf_probe_read_*() and might > : * as well probe the stack. Thus, memory is explicitly cleared > : * only in error case, so that improper users ignoring return > : * code altogether don't copy garbage; otherwise length of string > : * is returned that can be used for bpf_perf_event_output() et al. > : */ > > It seems that it doesn't matter if the buffer is filled as that is > probing arbitrary memory. > > > > > get_task_comm(comm, task->group_leader); > > This helper can't be used by the BPF programs, as it is not exported to BPF. > > > bpf_probe_read_kernel_str(&e.comm, sizeof(e.comm), comm); I guess Kees is worried that e.comm will have something exported to user space that it shouldn't. But since e is part of the BPF program, does the BPF JIT take care to make sure everything on its stack is zero'd out, such that a user BPF couldn't just read various items off its stack and by doing so, see kernel memory it shouldn't be seeing? I'm guessing it does, otherwise this would be a bigger issue than this patch series. -- Steve