Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp3316326pxx; Mon, 2 Nov 2020 05:58:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJyJGBEA/ckrZFD6kMxtJjYr+9VUJ+hMIoFSmgJrubAFxuJ06tKjtI9BCMhTwbS6C+9nhf3F X-Received: by 2002:a17:906:e216:: with SMTP id gf22mr15309754ejb.286.1604325522674; Mon, 02 Nov 2020 05:58:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604325522; cv=none; d=google.com; s=arc-20160816; b=RJ7ARfxtNOsFuTWL0TR89m+902Yw8nv0ZJsnMql2YURC2dV1QwpbpupIVEFPEwjwzM bjoiBsDwrHRFEWK+ZLwAoZhs6ydcUQno7yoJ6IgJxoZePfOpQz0I2aepN1KflYsYx6m+ Or9Qgl6DfxWy4IqKz+Bojusm+9guoilcyBLdMNiYqSt+6gazY7j0IIf4hVsQ8dFXfdnG g1ICIgc7w9o5BJ3zHyJZDDAg7bt9dkbcFLkz34zIxbl4Ma53eO9zeI51/YEz5N+SnhsJ eNZGXK46ek2of3yNqQo1mA5+nlX8oQ/xLEqJ5mwHdjOijICEH12D4SsNptNE9bSTiARG vQ9A== 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=crmhEgzkOmERlRibdWJQ5fJu4CKk3cly9oNaCdoNCWg=; b=GmBDS+r3wymHzFIR0+D42tzLEeoNl5CyhsvRd5cGnhq+CYHBDNKGOw4fuSYQ7XpFkT /5RWtfpunxHeZKPNX3LBDm0cgL14XkMBjzbYHWA21xiX9jtcIhMDMjntQhNlruPOOc7S JtrojUqBNOBf+UuxfplCaY0r0EHPD95K2ZifuOrcwbJdO5JQQCKRf/Co5tx0CLRf4KVl R0Ms/gSVCj59dAfoh7oNSReDGJLuNIVOnQufhl/NYFU4wCn26bRjiF1Uo44iyU0ocWvZ CwDfG7NKF3roW01ykYU3V/UBV49A0cqC2WEJNPoyuET2wmK93ZatjoU9oXHeDjFG2rJJ /MlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=e6rC0R5e; 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 y10si6619805ejf.165.2020.11.02.05.58.19; Mon, 02 Nov 2020 05:58:42 -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=e6rC0R5e; 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 S1725955AbgKBNtb (ORCPT + 99 others); Mon, 2 Nov 2020 08:49:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42488 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725791AbgKBNtb (ORCPT ); Mon, 2 Nov 2020 08:49:31 -0500 Received: from mail-lf1-x12c.google.com (mail-lf1-x12c.google.com [IPv6:2a00:1450:4864:20::12c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15B5BC061A04 for ; Mon, 2 Nov 2020 05:49:31 -0800 (PST) Received: by mail-lf1-x12c.google.com with SMTP id b1so17492090lfp.11 for ; Mon, 02 Nov 2020 05:49:30 -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=c26plOGfoQs1ts9hS3mn+gBQ+EKk5S0oVAorSUsLr98LA2SEgLV8yX5bAXO4H0YN80 UIQ6wAutHHFdJn9LjuDgviUs5qfdO6uqk0oL7kO0VYzCCjUy405ODFNTaHH8ER4cfAKa M0K1U21RNTyNhcQ76n1f6oy92vBlpbQ7rVuqOV+zsflv7l4n8foRj/9VhxkESxN2uNcA hQX+spTVjMaOW8ZU7DXc1xRPMuhdiMUZfO7N65NmURff3vqKjGj2G4R8pMGYAcoT+j5a mJFms6P7bVaZ6sjDfgm8jNUs6IpUsOBLJ1qBOkCXfh0Ojjjq5+nmwWo+9s/BAGzZ7+LY 3zvA== X-Gm-Message-State: AOAM530064vaI/5cc05MMshXLpia3nh1xaV23p0jdAOjRzpzC3YSw6RC jZnt2Ew8CO9EL0IwjZnL63vs+Fmh6UBviis56GAEFA== 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-kernel@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.