From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.4 required=3.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_IN_DEF_DKIM_WL autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6BBC7C388F2 for ; Mon, 2 Nov 2020 13:51:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 16EE3223AB for ; Mon, 2 Nov 2020 13:51:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="e6rC0R5e" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725849AbgKBNtb (ORCPT ); Mon, 2 Nov 2020 08:49:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725844AbgKBNtb (ORCPT ); Mon, 2 Nov 2020 08:49:31 -0500 Received: from mail-lf1-x131.google.com (mail-lf1-x131.google.com [IPv6:2a00:1450:4864:20::131]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1743AC061A47 for ; Mon, 2 Nov 2020 05:49:31 -0800 (PST) Received: by mail-lf1-x131.google.com with SMTP id j30so17553194lfp.4 for ; Mon, 02 Nov 2020 05:49:31 -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=crmhEgzkOmERlRibdWJQ5fJu4CKk3cly9oNaCdoNCWg=; b=e6rC0R5eB3PGQ+ozTxEoHwxYIrjTzj/lowbcSttME14YVqM0lIps4VooUuhm29uIFE q8sNXcIJGw1ny8hoRglYxZ9KpzrARGaG8u/N9tg9+2fxDLajahu8D7ztqKBx0+P+97wD 4+7gApcowelSqDo/j7gBpM0LF9LMwoRBhHlWlLF0AWUWkY6K823EIHiJsubXmHK+E3xk lOAWs2Oo413J9KNPAL17FSBQ2PIaDC1vMh4rOc652o/EuV589g2E4DXpKlkXZkO6XhAc gzqCT04f7oiU+lnIkGSrqs7iuqhzD+uA6V/Vg3+E84dav23WLkJXEsQtCLEKQAUdGu0f o0cA== 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=crmhEgzkOmERlRibdWJQ5fJu4CKk3cly9oNaCdoNCWg=; b=UmP72zrFSJUNhgz3XET2hbhz5QBZhhNy3QpDQPVnjtC2c6gi76xel2cFA92ygvnjmP PHklrZT6ZT/6inU7B/fRFboTMczHPRH43/kARdpghOXb9qSs9hnfd/0zsMaOZu8iHgCP 5ep+WdrgbSggOAS2/YetbXli6rAddtbjwLXC/HQlwwOw9oxmWXqMapchYC0SIk+ue1aq XmodB3tgY5FN/Gb3DQvXbQP7PXHUHbt3Ke1FbNgPUz0WLa+VzdmKSwgpOyWkVQ+xxtUj gSEIaWWAKr1mL1FNbx9hgehx/y10n64/mOIOr8aKbuqCYPfETig/xDjR/m1N1k0d9cI1 NLbQ== X-Gm-Message-State: AOAM533qaWfiPXNEdokTwp1Stp1xQuxeNDoSiw+FgNz8R1UYWfs5y2/D IwrPwma7ZLRZfTQ4veB2k6rz1VLDf9SxaFNOimGGLQ== X-Google-Smtp-Source: ABdhPJzGqIM5asHLIuy+EbHVmr9RXtwczq03HEhFi/zVkHIauFUcnrDjghLCaRPEjzU8Vbt4y8sReBCfx7RX76nxcBo= X-Received: by 2002:a05:6512:51a:: with SMTP id o26mr5441083lfb.381.1604324969162; Mon, 02 Nov 2020 05:49:29 -0800 (PST) MIME-Version: 1.0 References: <63598b4f-6ce3-5a11-4552-cdfe308f68e4@gmail.com> <0de41eb1-e1fd-85da-61b7-fac4e3006726@gmail.com> <9f9b8b86-6e49-17ef-e414-82e489b0b99a@gmail.com> In-Reply-To: <9f9b8b86-6e49-17ef-e414-82e489b0b99a@gmail.com> From: Jann Horn Date: Mon, 2 Nov 2020 14:49:01 +0100 Message-ID: Subject: Re: For review: seccomp_user_notif(2) manual page [v2] To: "Michael Kerrisk (man-pages)" Cc: Kees Cook , Tycho Andersen , Sargun Dhillon , Christian Brauner , Daniel Borkmann , Giuseppe Scrivano , Song Liu , Robert Sesek , Containers , linux-man , lkml , Aleksa Sarai , Alexei Starovoitov , Will Drewry , bpf , Andy Lutomirski Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-man@vger.kernel.org On Sat, Oct 31, 2020 at 9:31 AM Michael Kerrisk (man-pages) wrote: > On 10/30/20 8:14 PM, Jann Horn wrote: > > With the caveat that a cancelled syscall > > could've also led to the memory being munmap()ed, so the nread==0 case > > could also happen legitimately - so you might want to move this check > > up above the nread==0 (mm went away) and nread==-1 (mm still exists, > > but read from address failed, errno EIO) checks if the error message > > shouldn't appear spuriously. > > In any case, I've been refactoring (simplifying) that code a little. > I haven't so far rearranged the order of the checks, but I already > log message for the nread==0 case. (Instead, there will eventually > be an error when the response is sent.) > > I also haven't exactly tested the scenario you describe in the > seccomp unotify scenario, but I think the above is not correct. Here > are two scenarios I did test, simply with mmap() and /proc/PID/mem > (no seccomp involved): > > Scenario 1: > A creates a mapping at address X > B opens /proc/A/mem and and lseeks on resulting FD to offset X > A terminates > B reads from FD ==> read() returns 0 (EOF) > > Scenario 2: > A creates a mapping at address X > B opens /proc/A/mem and and lseeks on resulting FD to offset X > A unmaps mapping at address X > B reads from FD ==> read() returns -1 / EIO. > > That last scenario seems to contradict what you say, since I > think you meant that in this case read() should return 0 in > that case. Have I misunderstood you? Sorry, I messed up the description when I wrote that. Yes, this looks as expected - EIO if the VMA is gone, 0 if the mm_users of the mm_struct have dropped to zero because all tasks that use the mm have exited.