Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2645640lqp; Mon, 25 Mar 2024 05:34:39 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUPVJBLSR7VFRVEFM2cla9DZP1VwqEy39ApNrLB/7SRHh5pCsO6eRc621K6DaNGLofV9oEgdxqoSI6uAounb7psbbQDFvn9x50XIOla1A== X-Google-Smtp-Source: AGHT+IFK3dkPLegDdHL5NCUhLavODks/WNzc3ryiDHiy7I24wgOaQgjbBFkR1Y9Cp9pNLYjcOcE8 X-Received: by 2002:a17:902:c948:b0:1e0:a819:c02 with SMTP id i8-20020a170902c94800b001e0a8190c02mr9388228pla.17.1711370079269; Mon, 25 Mar 2024 05:34:39 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711370079; cv=pass; d=google.com; s=arc-20160816; b=YmhSBglUpf3gW6S0e1RE/Rcwvix64GFXQdv6AIfHL/aHH9txORKVidzDxHgkaJxxbJ oJWCq8vWCZ59DI3dciqs3gmkil+Bu5GzI8E/9uYPp1atEsU2/oAQqQzVhF2H80xnyXvp BCLnZWhQEUR1nhAGG72WpC4rWZEQBaWgoLdurLQPs+M6XRndpKyQvaTvpL9e8uWDvbzD pbggwKoAfP0dMH873z1pVYh7E1nZ2wmg3FO1rvtSzM/k0yNKJLvgOYoBkCuOpOX7mzd+ 2TLUDWC05RDPRKh22B5xEUKEyIlPieVT1S5lzcJFg+yeDhgzK6QXl5Z5q9V98iX5Zks6 9Klg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=UOZpuhMBzW/DQYrVdWYi9iDI8t0aMNsBeNHd/vTL33c=; fh=wL1wqGC3DgM6mI6n9WBAc1C0Sm5Hok8BeZgzc4qHaIY=; b=cvFReoEzfigpIt/xXwRbTyHFKtVuDhwKVtBLN4NRAhz1ZnRogeHtg3oNhxgS5oSDjx n06xDGEtc3D2kzZzJndJJRkres0yypJ9QyVUag/mZ3qFLQY36eas6c4cbAPkjKH+zsp7 WuEU7jAYf8wt86yy67NKpJkDUweBy3jso7nE/WS6S1vafTE3Xv6jiJ9Leho13hzsNaMx ogpKO4faufPIuhixDI3NB72DpX0Pq0wD7jQQDN5x3d0bJa1mC04S7bHHFaHmEzeosqtr 033a9U4Vy60Y8+5f/jE0VIjc0JxWRc05PTuPDHVzHp/yriYzQyJplxsaX/NNOvMYoAH7 QgFg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p+ZdNEtI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id l12-20020a170902d04c00b001debbbba48dsi4869718pll.197.2024.03.25.05.34.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 05:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=p+ZdNEtI; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116111-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116111-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 CBD77B314A5 for ; Mon, 25 Mar 2024 10:09:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2842E28E414; Mon, 25 Mar 2024 03:31:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="p+ZdNEtI" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3296D2801E3; Sun, 24 Mar 2024 23:40:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323631; cv=none; b=J5m438C7atW6SjYbwishhF2LVibHU7i6na3DhFLKdsI2OCpclV+LM79qU8AhwFBLqMqaWDM0s/9WDDJ0l4LXuRlfWX3QxbE9pDoyKJmmhZWowBQJeMrrp7cvg0vttMD3xGrM0yJ0njbsfPQ26Td6twOV9RqoNwxi/bq1Q1ZGsyU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323631; c=relaxed/simple; bh=YmYGiJNWvwm8qvLTcguVJPE0uIR5n311XccO/74AuCM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Knev5wKkC+0CNSnds03LpZuo5zWbga4IABqRVGg4VlPUb4yY1csl/pgD9Ey11+S0N4gPN41VejxEJqLOsC4rRC/KN9aWO5gFzYNMK9D0sN9TuF9wuadLb3AOHGFeov0dGfUf4EbYVNQUjeIuqx5YPpD4wiGkfnZYypnLfaZHiko= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=p+ZdNEtI; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 859D7C433A6; Sun, 24 Mar 2024 23:40:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323630; bh=YmYGiJNWvwm8qvLTcguVJPE0uIR5n311XccO/74AuCM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p+ZdNEtIhUyx6zY557ezLNHqSFRjxgyysiW03vEjkrxaJRgLCPD8XHhtOe23uU8ck XfH5g6NjaXghe3XP6WwBkUnNWZqqZeyAJ6SBG8U3yEs+PJ2KqV6+x5Z1TDnM1jgt49 D1rrlclEHKosSmo+lrC91MiArdonlyxsAu4+e3VXnxotQkBUHWw/SyqeM3wqXvJwjz y8ZJ9c9inWBAZhb2qFEi0Q2gBZSeGblOvvYZYmGfIWiUocWHBkE2HoQO5W5N95jFDD FsHOGDdgxtFQmP4EHo0W2oePJLaFys3dnYWLjQgRCEYuQCRwoXWOuUu/sc0dyy1HZe LBed12OL3U5sg== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jens Axboe , Sasha Levin Subject: [PATCH 5.10 001/238] io_uring/unix: drop usage of io_uring socket Date: Sun, 24 Mar 2024 19:36:29 -0400 Message-ID: <20240324234027.1354210-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324234027.1354210-1-sashal@kernel.org> References: <20240324234027.1354210-1-sashal@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit From: Jens Axboe Commit a4104821ad651d8a0b374f0b2474c345bbb42f82 upstream. Since we no longer allow sending io_uring fds over SCM_RIGHTS, move to using io_is_uring_fops() to detect whether this is a io_uring fd or not. With that done, kill off io_uring_get_socket() as nobody calls it anymore. This is in preparation to yanking out the rest of the core related to unix gc with io_uring. Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- include/linux/io_uring.h | 10 +++++----- io_uring/io_uring.c | 18 +++++------------- net/core/scm.c | 2 +- net/unix/scm.c | 4 +--- 4 files changed, 12 insertions(+), 22 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 649a4d7c241bc..55d09f594cd14 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -6,9 +6,9 @@ #include #if defined(CONFIG_IO_URING) -struct sock *io_uring_get_socket(struct file *file); void __io_uring_cancel(bool cancel_all); void __io_uring_free(struct task_struct *tsk); +bool io_is_uring_fops(struct file *file); static inline void io_uring_files_cancel(void) { @@ -26,10 +26,6 @@ static inline void io_uring_free(struct task_struct *tsk) __io_uring_free(tsk); } #else -static inline struct sock *io_uring_get_socket(struct file *file) -{ - return NULL; -} static inline void io_uring_task_cancel(void) { } @@ -39,6 +35,10 @@ static inline void io_uring_files_cancel(void) static inline void io_uring_free(struct task_struct *tsk) { } +static inline bool io_is_uring_fops(struct file *file) +{ + return false; +} #endif #endif diff --git a/io_uring/io_uring.c b/io_uring/io_uring.c index 936abc6ee450c..a80c808d3a0ef 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1113,19 +1113,6 @@ static struct kmem_cache *req_cachep; static const struct file_operations io_uring_fops; -struct sock *io_uring_get_socket(struct file *file) -{ -#if defined(CONFIG_UNIX) - if (file->f_op == &io_uring_fops) { - struct io_ring_ctx *ctx = file->private_data; - - return ctx->ring_sock->sk; - } -#endif - return NULL; -} -EXPORT_SYMBOL(io_uring_get_socket); - static inline void io_tw_lock(struct io_ring_ctx *ctx, bool *locked) { if (!*locked) { @@ -10275,6 +10262,11 @@ static const struct file_operations io_uring_fops = { #endif }; +bool io_is_uring_fops(struct file *file) +{ + return file->f_op == &io_uring_fops; +} + static int io_allocate_scq_urings(struct io_ring_ctx *ctx, struct io_uring_params *p) { diff --git a/net/core/scm.c b/net/core/scm.c index 3c7f160720d34..d09849cb60f08 100644 --- a/net/core/scm.c +++ b/net/core/scm.c @@ -105,7 +105,7 @@ static int scm_fp_copy(struct cmsghdr *cmsg, struct scm_fp_list **fplp) if (fd < 0 || !(file = fget_raw(fd))) return -EBADF; /* don't allow io_uring files */ - if (io_uring_get_socket(file)) { + if (io_is_uring_fops(file)) { fput(file); return -EINVAL; } diff --git a/net/unix/scm.c b/net/unix/scm.c index e8e2a00bb0f58..d1048b4c2baaf 100644 --- a/net/unix/scm.c +++ b/net/unix/scm.c @@ -34,10 +34,8 @@ struct sock *unix_get_socket(struct file *filp) /* PF_UNIX ? */ if (s && sock->ops && sock->ops->family == PF_UNIX) u_sock = s; - } else { - /* Could be an io_uring instance */ - u_sock = io_uring_get_socket(filp); } + return u_sock; } EXPORT_SYMBOL(unix_get_socket); -- 2.43.0