Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1294455pxb; Thu, 28 Jan 2021 12:39:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJy/0hx01TNPJf/ZbApHIDj2o423qm8d6ifiiVk4TIYeCBCh3PZZuZjCqVu0e6d9MQP5j2ne X-Received: by 2002:a05:6402:310d:: with SMTP id dc13mr1572845edb.291.1611866381808; Thu, 28 Jan 2021 12:39:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611866381; cv=none; d=google.com; s=arc-20160816; b=yGl/zHt16BctZUY2t7kms20VVwdhbRwosBWHEE7m0KDP98CR9/fUXzqWyasK5T3s/w Z9J2+lScTul6K8Ql/JHXlieZm/MOEg/vZovwIhUAx72EUyw1+3s8YBOseqz/GIhpGrAG s/0MVXBFmPGCF2/naDMQlqnbftAzFzITGd6rdmZsXRGsN1VFTshobhBGHLP9T8lQNSXs uoOOgiQuckYQRh7m7S0fVVfbbGWuDR/GxllFcK28KNJc5QOtq19c/sSHfyxSTsDeTl1v AlsTXeXbvmS6JyNjyLMaMtTiepVVViN1WgjYu9d5WUopOSRorPA9l95KqJsJqvwGLDK+ jw5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=1UVTyfisZAnJyUTGj4E05jEDNc8Dha7tB5MVBOZTxgI=; b=Zq0TLpZ4JhuqkOFkP1Kc4bIO4DT8TLOwKuLYsZfxTUh1/BlRNZDbVQ26GYlYf6TyJr 9BLbnwOP+E6bFGcnJyQ48+HL81cfhD0O+XDBBoJjBeTsrtFcU/38MEpXOJoTawoqXNT0 2meSEq6QDd8Tz3jhcuAeDm8xJSPUlNk+lVG7pULR5NkLgJYlOkCwv8U3UIDjYTzTTxVx cuA4T/ZFHmIQcO6JzC8GpunhowkPQhn4oHS/PB5A5CjKru9y20pHdG9eLY3P0Jp7CoGS MQ55DWioZTnJA3Y7+ZgOm12TwaDGY/doKDdYyqjz9jk7O3bga5niP2/Pzf8a1pLCZF2K hRYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=ThxQPnFl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bc16si3824030edb.335.2021.01.28.12.39.15; Thu, 28 Jan 2021 12:39:41 -0800 (PST) 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=@google.com header.s=20161025 header.b=ThxQPnFl; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231128AbhA1Uip (ORCPT + 99 others); Thu, 28 Jan 2021 15:38:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37618 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229831AbhA1Uim (ORCPT ); Thu, 28 Jan 2021 15:38:42 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C667C061756 for ; Thu, 28 Jan 2021 12:38:02 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id p15so6725692wrq.8 for ; Thu, 28 Jan 2021 12:38:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=1UVTyfisZAnJyUTGj4E05jEDNc8Dha7tB5MVBOZTxgI=; b=ThxQPnFlQS2JusYTiQxFRP3+0zCf67Lx1mZmUowPWQxOSXDGBf95O4lG5NKH0KvxFB Njg81kGWKAhCSjVrUAT5rwS36+YsMq93vtkglgZDRf9+97oM5WB/yHVObYB6bh878ytQ LI3TljWwYHbhh9xVUucfC3iUGmatqLJI0PvLxitJOoIwtWHV+iIU5A0Opi8hXMTNpipK M7sCdDcKFeXICxGPa4UxsZSjQdeWH/cT3hFXNuP/KbYlwsFrLc3vbKX9ByhKaeRH8idL 5ExA6IFOiCNtWzF1wU8tB6vVMTG/rTOHlXqIlVkwIx8rD36WcPaduWxDPtr6Kmt5APXY WcVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=1UVTyfisZAnJyUTGj4E05jEDNc8Dha7tB5MVBOZTxgI=; b=c9K+ylx9ynYgmz4wzrihPdiI5gslFfQvzP4JePOR0MGD/FwyLya1QqIdvJe3kstMuN kpGn+0TOuxvkD4pQZFm3aWlWihf5CLXJbm9TkXIa8gyJjzphFL0ROJfugURZYPcPCHQx ttLKpciDIm2tmomzdhGdmzSgRRnPHKhOUo5Dy5bEHs5vyU/n2XORCjwDpatK6kzqYOk2 3dy8e9TvYB2S/+R3oo8GCRqtUKiJEnQfLxXGq54kx+v86t4iXmTBoewYuJH957aJezoi Nr/QT56YxN8C3RAQ/a4k/RVU0jbjLM2UPGHZqlNkKOht/YZBLwWA60kri0EBt7F/4pCq Ftug== X-Gm-Message-State: AOAM531+AQn1TQjC4gQYDfd63Jx4WBH5t8T8TtBsk2fJYvCMB/8ss2kB HTQe1N7FXkycUS0m3oV0s2LCyDM0k5guSHC1yVhowA== X-Received: by 2002:a5d:6884:: with SMTP id h4mr999072wru.106.1611866280568; Thu, 28 Jan 2021 12:38:00 -0800 (PST) MIME-Version: 1.0 References: <20210120202337.1481402-1-surenb@google.com> <6cd84701-fb65-7aa0-38db-b69fe5748754@gmail.com> In-Reply-To: <6cd84701-fb65-7aa0-38db-b69fe5748754@gmail.com> From: Suren Baghdasaryan Date: Thu, 28 Jan 2021 12:37:49 -0800 Message-ID: Subject: Re: [PATCH 1/1] process_madvise.2: Add process_madvise man page To: "Michael Kerrisk (man-pages)" Cc: linux-man , Andrew Morton , Jann Horn , Kees Cook , Jeffrey Vander Stoep , Minchan Kim , Michal Hocko , Shakeel Butt , David Rientjes , =?UTF-8?Q?Edgar_Arriaga_Garc=C3=ADa?= , Tim Murray , Linux-MM , SElinux list , linux-security-module , Linux API , lkml , Android Kernel Team Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Jan 28, 2021 at 12:31 PM Michael Kerrisk (man-pages) wrote: > > Hello Suren, > > On 1/28/21 7:40 PM, Suren Baghdasaryan wrote: > > On Thu, Jan 28, 2021 at 4:24 AM Michael Kerrisk (man-pages) > > wrote: > >> > >> Hello Suren, > >> > >> Thank you for writing this page! Some comments below. > > > > Thanks for the review! > > Couple questions below and I'll respin the new version once they are clarified. > > Okay. See below. > > >> On Wed, 20 Jan 2021 at 21:36, Suren Baghdasaryan wrote: > >>> > > [...] > > Thanks for all the acks. That let's me know that you saw what I said. > > >>> RETURN VALUE > >>> On success, process_madvise() returns the number of bytes advised. This > >>> return value may be less than the total number of requested bytes, if an > >>> error occurred. The caller should check return value to determine whether > >>> a partial advice occurred. > >> > >> So there are three return values possible, > > > > Ok, I think I see your point. How about this instead: > > Well, I'm glad you saw it, because I forgot to finish it. But yes, > you understood what I forgot to say. > > > RETURN VALUE > > On success, process_madvise() returns the number of bytes advised. This > > return value may be less than the total number of requested bytes, if an > > error occurred after some iovec elements were already processed. The caller > > should check the return value to determine whether a partial > > advice occurred. > > > > On error, -1 is returned and errno is set appropriately. > > We recently standardized some wording here: > s/appropriately/to indicate the error/. ack > > > >>> +.PP > >>> +The pointer > >>> +.I iovec > >>> +points to an array of iovec structures, defined in > >> > >> "iovec" should be formatted as > >> > >> .I iovec > > > > I think it is formatted that way above. What am I missing? > > But also in "an array of iovec structures"... ack > > > BTW, where should I be using .I vs .IR? I was looking for an answer > > but could not find it. > > .B / .I == bold/italic this line > .BR / .IR == alternate bold/italic with normal (Roman) font. > > So: > .I iovec > .I iovec , # so that comma is not italic > .BR process_madvise () > etc. Aha! Got it now. It's clear after your example. Thanks! > > [...] > > >>> +.I iovec > >>> +if one of its elements points to an invalid memory > >>> +region in the remote process. No further elements will be > >>> +processed beyond that point. > >>> +.PP > >>> +Permission to provide a hint to external process is governed by a > >>> +ptrace access mode > >>> +.B PTRACE_MODE_READ_REALCREDS > >>> +check; see > >>> +.BR ptrace (2) > >>> +and > >>> +.B CAP_SYS_ADMIN > >>> +capability that caller should have in order to affect performance > >>> +of an external process. > >> > >> The preceding sentence is garbled. Missing words? > > > > Maybe I worded it incorrectly. What I need to say here is that the > > caller should have both PTRACE_MODE_READ_REALCREDS credentials and > > CAP_SYS_ADMIN capability. The first part I shamelessly copy/pasted > > from https://man7.org/linux/man-pages/man2/process_vm_readv.2.html and > > tried adding the second one to it, obviously unsuccessfully. Any > > advice on how to fix that? > > I think you already got pretty close. How about: > > [[ > Permission to provide a hint to another process is governed by a > ptrace access mode > .B PTRACE_MODE_READ_REALCREDS > check (see > BR ptrace (2)); > in addition, the caller must have the > .B CAP_SYS_ADMIN > capability. > ]] Perfect! I'll use that. > > [...] > > >>> +.TP > >>> +.B ESRCH > >>> +No process with ID > >>> +.I pidfd > >>> +exists. > >> > >> Should this maybe be: > >> [[ > >> The target process does not exist (i.e., it has terminated and > >> been waited on). > >> ]] > >> > >> See pidfd_send_signal(2). > > > > I "borrowed" mine from > > https://man7.org/linux/man-pages/man2/process_vm_readv.2.html but > > either one sounds good to me. Maybe for pidfd_send_signal the wording > > about termination is more important. Anyway, it's up to you. Just let > > me know which one to use. > > I think the pidfd_send_signal(2) wording fits better. ack, will use pidfd_send_signal(2) version. > > [...] > > Thanks, > > Michael I'll include your and Michal's suggestions and will post the next version later today or tomorrow morning. Thanks for the guidance! > > -- > Michael Kerrisk > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ > Linux/UNIX System Programming Training: http://man7.org/training/