Received: by 2002:ab2:6857:0:b0:1ef:ffd0:ce49 with SMTP id l23csp2546873lqp; Mon, 25 Mar 2024 02:04:30 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWc+TEcca2OPzShKtxRGJFXFdBxVrTDLd5Dw+7LUPzA85CBEPry1fEba4B1ggwN/PAamHwidc8HEmZ3VOcWcpmuaiVYkCIbd3rirIpkwg== X-Google-Smtp-Source: AGHT+IFSEwUKB37V4WUvcZpkqnxfenB0GbE/QjOp4nh5i1soWh782T0lBfAVlalcEkYIGTKnI6Mi X-Received: by 2002:a05:6358:590b:b0:17f:8831:21b4 with SMTP id g11-20020a056358590b00b0017f883121b4mr1446986rwf.23.1711357470218; Mon, 25 Mar 2024 02:04:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711357470; cv=pass; d=google.com; s=arc-20160816; b=ZnQX+mvAtOByyUFTaVmIq47TzbbAVMzgKTZfYj4sUWfPqrgjKD5yUa3xvNmMl2K3Ao z8M4lNaJg0noJAiScFumdqWp0C0/XspSpuk9nxj/RikWGyWhdw6jtBZ/Ay50lKeZuEHB ug6qdezST0waWVd0Rhy1l4zUFyjkCAEZvSSGE79PJwGZ9CuHcwM6q5nt5yvawSLcCLhc RKiY74WSelGyacBK2SLmSJjCKxvRak1yV1rlApRhNXpQk+opNfXzq3Q1mpMK+YuVlw8Q PQv6XHF3SDC/s45Wl4dRSqGYfX2BOc0W5qOyDbgosscwXKdHuS+J34977mGPPPqf4hxJ 9Svg== 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=ftErlRJDclk8hvrWS0nOfdeql5FKBurBS8UdzZFYvac=; fh=wL1wqGC3DgM6mI6n9WBAc1C0Sm5Hok8BeZgzc4qHaIY=; b=OZk+o7bmIwLJWJegp0qG07DlkGROwl3QzU2gypT0Uyf23X5sjglvN6NfobRzRDG64h 7U6lWz25nqFfkqx7d1n6CKpFaxiqRHqddobBUcxIRyB9dTgh6W7dJMf+SNUX2hps33ZU q/pgcG8gKeUT1p2rOvSk/evoLnUEVv0QS6WkqF+mYABb5LGm2fxdNGBD9x5kEREvB12S SYHKblXqAojSTrDA0JhtID9zEsWI3NZydnAhnVKhblv6tlQuq1Er06MVgabLfWz6pbeJ AgYwYS5hbEt0HHLPwEDr7QJMCGNfEluchx/HTdkxJ9OLq5R2Vqgyf5+O9ryzyOBNRPmT rhLg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=TkGynwkz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116002-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 f20-20020a631f14000000b005e85aa13467si6988803pgf.553.2024.03.25.02.04.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Mar 2024 02:04:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-116002-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=TkGynwkz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-116002-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-116002-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 E4AF1B25269 for ; Mon, 25 Mar 2024 08:26:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2602B1788B4; Mon, 25 Mar 2024 03:25:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TkGynwkz" 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 CCAF42716DB; Sun, 24 Mar 2024 23:35:01 +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=1711323301; cv=none; b=pk1wibud46OMD2PWgmmBx/C7QFQ2ddgmAJdpQbZqSlh7ah63HmGDJ+/eliNKlyRyTzvn9npqwTLc/VuSXzG+/mYxC4dMfBNEoYDplMbLp+HyQ1w751AhxJzpNp2H9/at3E5C6AgegKgE2C3J5nP2ighCjHGtackS4TeegTfwepA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711323301; c=relaxed/simple; bh=ELzVn+rRe6bS2yKeO1yNV5To5LEEcDbleSatoALaGSo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=RFrzAAwUZkFiGMQyL1OxokPjwowrsVp2irJryeEMKUSiPChEbfrkrder+jacxMMhS1IyC1zHgims65Vmp9Uf9PnmyFD7OmZHqPdJADAlFaN4VD0rLJ+J8vcbkJn4Lv680S/JI3iQbWg/pqB3S391j65IBX/7r7XFKpbtokQiIw0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TkGynwkz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CBFD8C43390; Sun, 24 Mar 2024 23:35:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1711323301; bh=ELzVn+rRe6bS2yKeO1yNV5To5LEEcDbleSatoALaGSo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TkGynwkzZ3DL3PjeKqXAsTDEMIwgXNRPc5rba1NVxbXbu15hEjeETmzTXw8mZfp08 HhMV2w0L1j9g0ALepIXR2/IQn2KFIRvHbG58PV8+BuECOJVKwH0OeNunVf49rzf14G v8Hr/EMXmYOGP1Pmvr9YyjNvBJpNhYSaHhmnLK4CtJY6fkniV9sYzrAw2e92c34EIR PcGVPU9zq3DQfosUA6OSo+8HwdnkV7jDCfDmZ+U8oAkYaylB4FgU4UUe7lLsrJzQfH 5NP0yWy4CXreYAF+wmXQRiotPb0U8rb5Su31QbVDezHgz09SpCr27SgXhl0G2RsfoA ALtS5g7rotzxQ== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jens Axboe , Sasha Levin Subject: [PATCH 5.15 001/317] io_uring/unix: drop usage of io_uring socket Date: Sun, 24 Mar 2024 19:29:41 -0400 Message-ID: <20240324233458.1352854-2-sashal@kernel.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240324233458.1352854-1-sashal@kernel.org> References: <20240324233458.1352854-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 55fd6d98fe121..541e6a6985ecc 100644 --- a/io_uring/io_uring.c +++ b/io_uring/io_uring.c @@ -1116,19 +1116,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) { @@ -10445,6 +10432,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 e762a4b8a1d22..a877c4ef4c256 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