Received: by 2002:ab2:6991:0:b0:1f7:f6c3:9cb1 with SMTP id v17csp1071801lqo; Thu, 9 May 2024 04:06:56 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXK5IW7j9RbPLtvgWxHwjrV30t0dQGVTLrIEHYnyYi1E9lZkY/oipKx2eR56Td0JYmEuz3nfkH0hcqgK4pTrX1pp+uGTARHxyTo133c2w== X-Google-Smtp-Source: AGHT+IFpDk/QDXhcrzKChxTca8ZQP4ONkceNQ+xAu9wqcyPzdrHwwgmYC33cFpf6tYCoVKwfZXim X-Received: by 2002:a17:903:2343:b0:1e2:b13f:bd64 with SMTP id d9443c01a7336-1eeaf87097amr66667055ad.0.1715252816697; Thu, 09 May 2024 04:06:56 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715252816; cv=pass; d=google.com; s=arc-20160816; b=i19HwhEi31ofSL+rXseuJ61zZ0PWwBodixcmcL2xhxjUvAhpRSfwcK+vrvAejkujpD xFuTzNS9C757BHHG4DMahFRUf9UY8hBQrDLF8Cn3DGD45+eAsDsQHdaC8G+Om8npTLA9 70MgJrojeO7JYQVxCuJCOO+qlfHc/kKW5kLjIL8HlEriNUtfQYw6A8jDdpj0UB9evYKH +4Uas7TUHJF7Opf2a5x0V5DY3rnJuLy6Sszr9W2ituz/Nq1BEp1JzJplw7/XKOrVrMTr R2iH4ggLFiDQDjN1o0X67dqlQ5FWEjELk5X2kVLxLGv2N4/OMJWb2xBt/w6X80Cq3kvo TKaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=if+Id8ngxnktCMRBldLjA3n7XZopNpgwUvJ4D4xVr5Y=; fh=Q2QQdh3gJ5K94ysRO6GVOsQEv/yKEfcV1mE0NhmFE9E=; b=xrqKqyzWvh2B3RFBHKa9szf+HMUONv+ndf75nf9yoCAiPZg1zQbVyiHOxNV3Q1kaqD RkYNT7atjEMgHJYNjJAz7sAFgx3apVfExZMQiKXk8BMkI1KNhXOgp3Y9vzkG12P1QEjx fl3S+B3zxcoJ9f8wvPtTpJG4pewXavFh96El+nNUEEqCscYd4XPrPwR+vdivf8rDQgGx M0KMAfgJdVAhivVEKpC5gcuQrEq9hFsA4OAq1nKJYOQxSr+8bfYGvSK90XrNZqEovmaK AJPaX/9RmWSAxKQYQPMyO5QjUW7erdNVBVnthkZrQRSiwSPsZU3Jc2rGlflVWnWDj5aN fEIg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zPOaFnk9; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id d9443c01a7336-1ef0bf32feasi11842305ad.301.2024.05.09.04.06.56 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 04:06:56 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-174437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b=zPOaFnk9; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-174437-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-174437-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 827C2B228D1 for ; Thu, 9 May 2024 11:06:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5BD8C1311B9; Thu, 9 May 2024 11:05:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="zPOaFnk9" Received: from mail-ej1-f48.google.com (mail-ej1-f48.google.com [209.85.218.48]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EA71A12FB0A for ; Thu, 9 May 2024 11:05:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.48 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715252742; cv=none; b=Neh+gCzpQs5jox70nKP7KMMxdr/xL2n6FNpSLRYN25Fp37ZRt7HDo5v6gOgjDmTuhTo6yXiYH9VCI0eRATb4CJCbdo/EV8pp1OymEZmZhb3LuZv9CYW8A7A90tP2hIVANOkQ2ZCIynvL3IkVTdqOZh2JBtRvNHlPOYiqaD9zSLw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715252742; c=relaxed/simple; bh=qYcuYJcsvd932hxxmJk2Q5337yfwZq0inWZSf6fynXA=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=oZo49FeqO1+DYfGAk+3KA6G9fg2O+It/6dyO9jO20JW2k6LSZMy1EI4KTKrZ8bQ7TxjjbyzQQ3YS4rCDDZCbE5d5wdWQJObvbybSxnExuIxEEpXTdP3gNPDfnt1kRqdqg2cg7+VP2mFyuKkI6UJyvA4amdDXO176Phy4DtzjwgQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=zPOaFnk9; arc=none smtp.client-ip=209.85.218.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ej1-f48.google.com with SMTP id a640c23a62f3a-a5a1192c664so195782066b.2 for ; Thu, 09 May 2024 04:05:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1715252739; x=1715857539; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=if+Id8ngxnktCMRBldLjA3n7XZopNpgwUvJ4D4xVr5Y=; b=zPOaFnk9b6rXGU5RlrZhduk7WdbLkZY/Y2Zt+DyvvyF2p0xKMd6C9PY7EmSNBmnOU0 TSGR8uymEe8+r/ojrs2fejvhABjDItOI7R1ODT3gkn8AQJvqmTBqQAOL++UtCAqemojX u6pa5Dh3Ijit5eKM3gy3+UPn4z30oP116BQp+r61SnoqEec29zCBKd/Cu2RhGkUHYbQb nL2DVuveJQ/WFnBd8KhSkLu5T2mb0QyW1SJeIMqx4E3FmoWtGnV4tmq0ROUulpc/n+TI znIwD5xAQfxeXidG+a7Q7i3C1F3ScG3NomFGt7YoNv8nLtLWq18oJxhxlsC3GaOSJRHU KhZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1715252739; x=1715857539; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=if+Id8ngxnktCMRBldLjA3n7XZopNpgwUvJ4D4xVr5Y=; b=qMPZwEVwP39CqfPy6gXUUhtYslbsjjaGBbKfIeodqd+twx3eN4GkNHCMLo11ZM92ix CFL+s0MdJHFVaFVwS2CdBK76ZAm+W79K9dfw/8Zi9JoDK/V5f2aUKgwkY6p3ClrhYtzj mj2gFsTF5e3Bl6Pg+0Yoqm7BTYcV+GVLPZ++BT8pKhojNVnP0xme4ND6i1e6DUVzgoo2 ZI2Q/4E8ECH8FELf5UyYdWAtDZ40v7zOIID6RRUW5Xmp2+u2j3wJl0PgepZPTGSEpvz2 mfzM0KaMlpgI7X/0No1ORaOwg2B7ZyxDTsTop+ZjGkyup2/Y1hVblOJo6/bgxJN31OqR A61g== X-Forwarded-Encrypted: i=1; AJvYcCWirXCZAA93dB07YUKVLIuSOz8kzdDecduK1OFSNUEXdvEdpBswY+7Fxvir6ywUCg34s8b6+2sPwH+pzAxU7B6nvtzenTVmMOH6Ebor X-Gm-Message-State: AOJu0YzzxirbGxvpeYKemrIQW4Bku6Orbo4s47+H0+4Alg1WxrHRam33 jqDJFNgDDysLxVr9yhgYz6BMr72BZGdYv95Yn9GubRYz4yHUzHQjDzpUvNQo+w== X-Received: by 2002:a17:907:7084:b0:a59:a64d:c5b9 with SMTP id a640c23a62f3a-a59fb9dcd97mr514760566b.76.1715252738913; Thu, 09 May 2024 04:05:38 -0700 (PDT) Received: from google.com (88.140.78.34.bc.googleusercontent.com. [34.78.140.88]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5a17b17555sm61158766b.189.2024.05.09.04.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 May 2024 04:05:38 -0700 (PDT) Date: Thu, 9 May 2024 12:05:30 +0100 From: Vincent Donnefort To: Steven Rostedt Cc: mhiramat@kernel.org, linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org, mathieu.desnoyers@efficios.com, kernel-team@android.com, rdunlap@infradead.org, rppt@kernel.org, david@redhat.com, linux-mm@kvack.org Subject: Re: [PATCH v22 2/5] ring-buffer: Introducing ring-buffer mapping functions Message-ID: References: <20240430111354.637356-1-vdonnefort@google.com> <20240430111354.637356-3-vdonnefort@google.com> <20240507223402.206d6ddc@rorschach.local.home> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240507223402.206d6ddc@rorschach.local.home> On Tue, May 07, 2024 at 10:34:02PM -0400, Steven Rostedt wrote: > On Tue, 30 Apr 2024 12:13:51 +0100 > Vincent Donnefort wrote: > > > +#ifdef CONFIG_MMU > > +static int __rb_map_vma(struct ring_buffer_per_cpu *cpu_buffer, > > + struct vm_area_struct *vma) > > +{ > > + unsigned long nr_subbufs, nr_pages, vma_pages, pgoff = vma->vm_pgoff; > > + unsigned int subbuf_pages, subbuf_order; > > + struct page **pages; > > + int p = 0, s = 0; > > + int err; > > + > > + /* Refuse MP_PRIVATE or writable mappings */ > > + if (vma->vm_flags & VM_WRITE || vma->vm_flags & VM_EXEC || > > + !(vma->vm_flags & VM_MAYSHARE)) > > + return -EPERM; > > + > > + /* > > + * Make sure the mapping cannot become writable later. Also tell the VM > > + * to not touch these pages (VM_DONTCOPY | VM_DONTEXPAND). Finally, > > + * prevent migration, GUP and dump (VM_IO). > > + */ > > + vm_flags_mod(vma, VM_DONTCOPY | VM_DONTEXPAND | VM_IO, VM_MAYWRITE); > > Do we really need the VM_IO? > > When testing this in gdb, I would get: > > (gdb) p tmap->map->subbuf_size > Cannot access memory at address 0x7ffff7fc2008 > > It appears that you can't ptrace IO memory. When I removed that flag, > gdb has no problem reading that memory. Yeah, VM_IO indeed implies DONTDUMP. VM_IO was part of Linus recommendations. But perhaps, VM_DONTEXPAND and MIXEDMAP (implicitely set by vm_insert_pages) are enough protection? I don't see how anything could use GUP there and as David pointed-out on the previous version, it doesn't event prevent the GUP-fast path. > > I think we should drop that flag. > > Can you send a v23 with that removed, Shuah's update, and also the > change below: Ack. [...]