Received: by 2002:ab2:7855:0:b0:1f9:5764:f03e with SMTP id m21csp711703lqp; Wed, 22 May 2024 18:46:04 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWDbowP3WPDPsCZ4ux1MgnM0ns4Wl4LMDhSByEcKNO93GT4Bja7Io+GfTyeSPxCCuCJi9KD9nbo5bDYLDeLj8IPJlv/uUn7N69Glm3fIQ== X-Google-Smtp-Source: AGHT+IEqzIZqKdzGw2/PpLMzyMeMWcJCCGP8nO3K8XCNa4psIbgA/RJG5XX8Z2dJWJOFZ5x8s2O1 X-Received: by 2002:a17:90a:be02:b0:2bd:b21d:cfd6 with SMTP id 98e67ed59e1d1-2bdb21dd274mr2618846a91.33.1716428763729; Wed, 22 May 2024 18:46:03 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716428763; cv=pass; d=google.com; s=arc-20160816; b=hfOBG30lTDMgQzeDJ3ONfoNWr37imSmbed/f3c6b+X+bTwccltW2KZ1YmktAPYpOOx nQJ906TYtj8KiEEG2Qx7FBuL0zFSqlVR5HokCroR4hJftuD2RFKVacKQjHtRuBr9MEAW U5Wis/4sPbzWR0mGEOPJnrLCjuSLZ1jkmSkhAaQhnHWQ9HoCp7Xkw3/uI93FruBd26Bz rHiN1RbyiDhkLQYrbz4tBIihTPiNDaDMNwAHrHAP4zWLKLiXD/OCZcwVLDK6cjjmiA7v MYO20CSwUc6vPV/nOzedROgExuZG4A4PAN26VoEI3E/2EWYL33GvH3pQqP6lQhdPSXfk yYkA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=cc:to:from:subject:message-id:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature; bh=o8roWRztlDKuXSQ8oPu1ka3tEPYb3RZ6tO+a/lEDnXs=; fh=/YQuUh76/kgEPfE2YXowbUqqIqOgE7f6+06v5Dxr91g=; b=AvBvMiYpecVAsCz5YlVx7Ksvu1C4e31VU0VcJ1wnoYDEVU/ny0YE+mXPsHBaqdTnoa c0GqmkmonlJDcZw4NlOot40Eee0aVniSAhGdOBK/HRuC2qFZbF1mxeM9iLwbpls3UEPU 4NoOoL7FPNMIChEXuUJzBlAyNsb22inXiaNwCgMZsnufTW1zgHARn+2uP+G5g5M5eBlD KtUw+AFgepGh0sL7u+Gtum4uPRewMFQ/DK1dACf5iD7tAICCNt2gvq5aEzgyktaJ+2y/ 6bO4iaJ6opnYDUszPiwztwP+tePky3OAHLJKyzozz+fpcTF8iC+1FArGKI8XgUQi4CRH HEcw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="O8k4/FYS"; arc=pass (i=1 spf=pass spfdomain=flex--avagin.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-186889-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186889-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 98e67ed59e1d1-2bdd9f49a51si603044a91.178.2024.05.22.18.46.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 22 May 2024 18:46:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-186889-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="O8k4/FYS"; arc=pass (i=1 spf=pass spfdomain=flex--avagin.bounces.google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-186889-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-186889-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 E459BB214AD for ; Thu, 23 May 2024 01:46:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B5D443C30; Thu, 23 May 2024 01:45:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="O8k4/FYS" Received: from mail-io1-f74.google.com (mail-io1-f74.google.com [209.85.166.74]) (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 9A42BA34 for ; Thu, 23 May 2024 01:45:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.166.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716428754; cv=none; b=QNgG0knRM4zbc+SKt/r+1zR4MDshU2DSTlSy6MuvGYmQtNeAWkEHodxgPGPZuJuIYBqV3N813d3sVlKdLx4+eYSqx5SlqfnzWw5jUCuyvLeCuORy8XcTzBq95PjcH7KVjn6/05KlxdTpq0YCXLD83C2CprzafudSt12lnt8sKMw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716428754; c=relaxed/simple; bh=jxZtMhUdnJx/zGHULiYyTgOvORYAT1DV7mt/OghoYso=; h=Date:Mime-Version:Message-ID:Subject:From:To:Cc:Content-Type; b=jn94NJWHF/OarS80Qy/BPk1K0Qkp1oAavUXVs4af1e08TTJ9G29n2cNlFaT6tHoiP2q3oJ7S9A8BQnzvdjeb6PnM4J3UzYKI/vrZBTIYPSvr0eKZI+wmD38syXa9M9dzLFytgfgDsI1uX616sFfVoQSUpSm9I2fxFrd2S/M6YbE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--avagin.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=O8k4/FYS; arc=none smtp.client-ip=209.85.166.74 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=flex--avagin.bounces.google.com Received: by mail-io1-f74.google.com with SMTP id ca18e2360f4ac-7e1de4c052aso104702639f.0 for ; Wed, 22 May 2024 18:45:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1716428753; x=1717033553; darn=vger.kernel.org; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=o8roWRztlDKuXSQ8oPu1ka3tEPYb3RZ6tO+a/lEDnXs=; b=O8k4/FYSeUVPmhTwo4K1K6dqKXOZuX2HL1F8lxXeIQb6UY7bWJoJdCsHBtJ3wmNihW UX2reDMPrSpDj9JrxVyDBMPM1ronlCrEslGiPBX79Wga1mwl0aoFCG60pP+Qf0Knp29t GJsb1EoLzoblL6eMrN05WSMGZRFQnRTGWKx2Yi94KUKx2eJdNXHH9tItcFwqX3hEUpOd cgXNEZtABuWT7RI84WghQvWJnhQfeuOvMpuWayZoKKgHtmncX4z0EPAgUBhD4kVK+gAs FO2SXa8+pP0Teju/vP91/giiykSJ8JA1CYxp4VSOmVGg0V74LRUdHzp6v9Co12Xh2iMu fqRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716428753; x=1717033553; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=o8roWRztlDKuXSQ8oPu1ka3tEPYb3RZ6tO+a/lEDnXs=; b=eqgITa3IWPvDtmfjrmrXwXOItFpB3JJoV4quGup2y82Ud6qg5LNQ32Btz1jK4UjWUo 8FYerax5xxhCEHQ2ezS87PnidECFZvFCnW8RAMW/g4DlI7QPMKE2v0PU1qiSnViDzDdi 9M+D+OCoDLU024Ma+CDWP1si7R9chcfiFmcpzJwIH6IvKaZzN5kxC7ORjRvVuCkoj0m6 bIBDwbfDlg3Ymjevjgmu1Uf76heqh3qugxtJvd5vBubQJXESbBRlPdMnGaw7ASNFVb1f cjM4BC5mRBTMnM4MSjXNaAnnzFc6BG4TKDG3ASzbqCUdL08w/FyrM9KBfvv8gkOQdPDw StGw== X-Gm-Message-State: AOJu0YwiQ96RrCi6yhoTKFQchs6rovFRSSGEYRJqcTtGJqT/0H4Fvs9y tghyaID/dbfdPJUNjWZGiGGoBZLEuAXN0wrD8LhCe2ZSwUnZ6lBvxkJE9OFgnY/1iHtn6rmBEmR G8g== X-Received: from avagin.c.googlers.com ([fda3:e722:ac3:cc00:2b:ff92:c0a8:b84]) (user=avagin job=sendgmr) by 2002:a05:6602:3408:b0:7de:e10d:34e9 with SMTP id ca18e2360f4ac-7e3a0ca1247mr15866039f.4.1716428752856; Wed, 22 May 2024 18:45:52 -0700 (PDT) Date: Thu, 23 May 2024 01:45:37 +0000 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 X-Mailer: git-send-email 2.45.1.288.g0e0cd299f1-goog Message-ID: <20240523014540.372255-1-avagin@google.com> Subject: [PATCH 0/3 v2] seccomp: improve handling of SECCOMP_IOCTL_NOTIF_RECV From: Andrei Vagin To: Kees Cook , Andy Lutomirski , Will Drewry , Oleg Nesterov , Christian Brauner Cc: linux-kernel@vger.kernel.org, Tycho Andersen , Andrei Vagin , Jens Axboe Content-Type: text/plain; charset="UTF-8" This patch set addresses two problems with the SECCOMP_IOCTL_NOTIF_RECV ioctl: * it doesn't return when the seccomp filter becomes unused (all tasks have exited). * EPOLLHUP is triggered not when a task exits, but rather when its zombie is collected. v2: - Remove unnecessary checks of PF_EXITING. - Take siglock with disabling irqs. Thanks to Oleg for the review and the help with the first version. Andrei Vagin (3): seccomp: interrupt SECCOMP_IOCTL_NOTIF_RECV when all users have exited seccomp: release task filters when the task exits selftests/seccomp: add test for NOTIF_RECV and unused filters kernel/exit.c | 3 +- kernel/seccomp.c | 38 ++++++++++--- tools/testing/selftests/seccomp/seccomp_bpf.c | 54 +++++++++++++++++++ 3 files changed, 88 insertions(+), 7 deletions(-) Cc: Kees Cook Cc: Andy Lutomirski Cc: Will Drewry Cc: Jens Axboe Cc: Christian Brauner Cc: Oleg Nesterov Cc: Tycho Andersen -- 2.45.0.rc1.225.g2a3ae87e7f-goog