Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2533297lqp; Mon, 25 Mar 2024 01:27:31 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVV38jReVFx4RhKM4ZJDUCAoXIy/WV2i1qPSDpVkYkh+41SSCpnbYekc2iZEelNm1noH4yNggY55bsexfK2sibNaMV+z1k9tO8O/imhwg== X-Google-Smtp-Source: AGHT+IGw68v4vhXYZMerutMWNKQQ0kyLHWHbY/GbTPzFzVLtVhVknBNci07r7k17p15Mlz03nNes X-Received: by 2002:a05:6359:5d25:b0:17f:854a:76f4 with SMTP id ps37-20020a0563595d2500b0017f854a76f4mr1639151rwb.6.1711355251508; Mon, 25 Mar 2024 01:27:31 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711355251; cv=pass; d=google.com; s=arc-20160816; b=YbTA+vnFYB+WrlFMfDZgEEnCIKHNXhZ3owFvDz2fayk1eepunmE9tiiQ4VMtqSm2Ro 2+Nl50UVLmGigbHfKvzCKyQ2qScnfARw5zl6dRekCUVUnV76ykrhyrdFtikFKek+eYJ0 HAi/qlvf6AFnWQuFpTBGRXVU3AIJf4WsQDm9ajAb6x7Pa0sX8+1YZk9HujAw8E528ccs eCSQcNlu0wiUvRD4Swbcgl4mfAKcXa2jZFCnBLMVB/Q7FId7vcEEVymyT8psJnOwZxpa gkQg+jklQgdFok5GAalSs0OKSwR3YsUd/ETixbg5pS54IzipIDxih0TDo04pB1W67vke 6bJw== 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=Im3O4OOkQrpzW5Lfckde4a/1CkdfXyrjCp4PCnUABnU=; fh=wL1wqGC3DgM6mI6n9WBAc1C0Sm5Hok8BeZgzc4qHaIY=; b=BcxZ9v8TVssYFVFG4/GOIPtX39IZ9vdryVT+GHTFO57IhqvgV/Zn23NwccFVnHg2F+ 2LpjlgQHXNuE5K/4gFa1pv1UdoKGqFLKdrGs9+EGfmBZo1lJ2OeM7jwLhIXOEHxeaANq tBweeQJu4E6vGpp6Vq0mrv5intVDIjpSz7JHZkwnlqGSuDnMdojTO7IEgIHrqZ52ml1O UI6eOaMi3Bkv5EFWBUZ04+J5f65EbAT5dxT4zg5Z/JPXKs9KXp3CYncRNpPYf0vJ1cSR 4nleR8BPndZD1whEYrvb37XyQd/8K35and8md9P6R46giVb8wOmsh7ufxnLKkai9mmau MqfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JyEx+EJy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115587-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115587-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 a36-20020a631a64000000b005d66232593dsi7198807pgm.868.2024.03.25.01.27.30 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 01:27:31 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-115587-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=JyEx+EJy; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-115587-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-115587-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 BC836B2DBAD for ; Mon, 25 Mar 2024 07:49:54 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C405F16A1E7; Mon, 25 Mar 2024 02:47:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="JyEx+EJy" 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 1D2CA1F9C38; Sun, 24 Mar 2024 23:01:20 +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=1711321282; cv=none; b=sfyDWziZAHPfTaH1/cogxPMscvDx5ShCU3MCtrx+5pIfeumetLk3xwHqr7PcTPQYTudF5kbHGJNx0oOiBDJUccXbZa6S6lVRJKNIcpqjITPEAYUVVimmh0nuNHHHy2T/VH75UREfhJsWBZpR1et0ZR9eTnM8YSOB6Th2pOrbHSY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711321282; c=relaxed/simple; bh=1xrkI0FaU02Etf8mrDA9l6QkmHc9mRQrQ7IPVksNPys=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UjROBUYVNBqvfaAw1JzWLHQRLmVNn8PXJK8jwiN/Zmf6GGnP4Q09lQOXhKeKRF/rVHrXl9gKLz7YecNjprqJ7dIJC+oyDmq+EZL/OLesK127SNnirT1DeYdS7BYzq3KVCsTueiMZkj7bBC+j78hrTBjm8UnPOw/LZdzc7nUc/6o= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=JyEx+EJy; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E7BDC433A6; Sun, 24 Mar 2024 23:01:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711321280; bh=1xrkI0FaU02Etf8mrDA9l6QkmHc9mRQrQ7IPVksNPys=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JyEx+EJyaXf0qTAqUYOupUOukrMqYCICFMoEo4X8zdbD+GXg6aRo5GZ9QwUMlPwyc vLYBZdy4PoWQh8BgsgKi7V7GoV7+Bs0d/GHObj7DS7uMbF2Jbxf3E6I2oLF/+R+MGP 3KPLJUQzKOHJsui34DTq1UUjJv1ds9hgow2Kt5ptSeb6Ji0UKPRIL/RDI8tU5AsMbc nQxmKpzH3ohpVBOOld1ymFlr26DxbIaQCTN2ZkM+tIWfFYJsihwtlgbvCl369Qcc/Z G7Pb6GC/63wcSeUuAiPHAXJP7nXJFu1M8k3ZbAWoh7gdhKkOS8abXEDIha5JR2NdiV PO0S7HpHP5P7w== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jens Axboe , Sasha Levin Subject: [PATCH 6.6 002/638] io_uring/unix: drop usage of io_uring socket Date: Sun, 24 Mar 2024 18:50:39 -0400 Message-ID: <20240324230116.1348576-3-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324230116.1348576-1-sashal@kernel.org> References: <20240324230116.1348576-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 | 13 ------------- io_uring/io_uring.h | 1 - net/core/scm.c | 2 +- net/unix/scm.c | 4 +--- 5 files changed, 7 insertions(+), 23 deletions(-) diff --git a/include/linux/io_uring.h b/include/linux/io_uring.h index 106cdc55ff3bd..f99ff6de926cb 100644 --- a/include/linux/io_uring.h +++ b/include/linux/io_uring.h @@ -46,7 +46,6 @@ int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, struct iov_iter *iter, void *ioucmd); void io_uring_cmd_done(struct io_uring_cmd *cmd, ssize_t ret, ssize_t res2, unsigned issue_flags); -struct sock *io_uring_get_socket(struct file *file); void __io_uring_cancel(bool cancel_all); void __io_uring_free(struct task_struct *tsk); void io_uring_unreg_ringfd(void); @@ -82,6 +81,7 @@ static inline void io_uring_free(struct task_struct *tsk) __io_uring_free(tsk); } int io_uring_cmd_sock(struct io_uring_cmd *cmd, unsigned int issue_flags); +bool io_is_uring_fops(struct file *file); #else static inline int io_uring_cmd_import_fixed(u64 ubuf, unsigned long len, int rw, struct iov_iter *iter, void *ioucmd) @@ -100,10 +100,6 @@ static inline void io_uring_cmd_do_in_task_lazy(struct io_uring_cmd *ioucmd, void (*task_work_cb)(struct io_uring_cmd *, unsigned)) { } -static inline struct sock *io_uring_get_socket(struct file *file) -{ - return NULL; -} static inline void io_uring_task_cancel(void) { } @@ -122,6 +118,10 @@ static inline int io_uring_cmd_sock(struct io_uring_cmd *cmd, { return -EOPNOTSUPP; } +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 ea772a02c1405..747d2a6ecab89 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -175,19 +175,6 @@ static struct ctl_table kernel_io_uring_disabled_table[] = { }; #endif -struct sock *io_uring_get_socket(struct file *file) -{ -#if defined(CONFIG_UNIX) - if (io_is_uring_fops(file)) { - 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_submit_flush_completions(struct io_ring_ctx *ctx) { if (!wq_list_empty(&ctx->submit_state.compl_reqs) || diff --git a/io_uring/io_uring.h b/io_uring/io_uring.h index c8cba78310831..411c883b37a95 100644 --- a/io_uring/io_uring.h +++ b/io_uring/io_uring.h @@ -61,7 +61,6 @@ struct file *io_file_get_fixed(struct io_kiocb *req, int fd, unsigned issue_flags); void __io_req_task_work_add(struct io_kiocb *req, unsigned flags); -bool io_is_uring_fops(struct file *file); bool io_alloc_async_data(struct io_kiocb *req); void io_req_task_queue(struct io_kiocb *req); void io_queue_iowq(struct io_kiocb *req, struct io_tw_state *ts_dont_use); diff --git a/net/core/scm.c b/net/core/scm.c index 7dc47c17d8638..737917c7ac627 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 6ff628f2349f5..822ce0d0d7915 100644 --- a/net/unix/scm.c +++ b/net/unix/scm.c @@ -35,10 +35,8 @@ struct sock *unix_get_socket(struct file *filp) /* PF_UNIX ? */ if (s && ops && 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