From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="c3Rtak9W" Received: from mail-ed1-x530.google.com (mail-ed1-x530.google.com [IPv6:2a00:1450:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4877612B for ; Wed, 6 Dec 2023 05:56:08 -0800 (PST) Received: by mail-ed1-x530.google.com with SMTP id 4fb4d7f45d1cf-54d712c254aso1187788a12.0 for ; Wed, 06 Dec 2023 05:56:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1701870966; x=1702475766; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=9NtHEXBKTWTiA0icVnsHeiE8Pfrx+OjZf5R3SvMQ/3M=; b=c3Rtak9WDCqlJMrkfbhUWGg0X01uiTncTGVQa2l5UQ7kf4+sLxg17XsPvRmDEcolf2 8x5Xs8N5AtFhl7jTsGPEzkgKA81dkKiwGRyE0rswlOmbAQw/3KDyXqZLIiE1kh34nlkw bedjnUw0Nn9N0Qo3Kw/5o1TBUS1kMBlWqt7ZuXOlrPCfPlpC3FoKDqXGmfOGoZgNBgFD Iert9wMe+o69MThuFWXmFs/9YxXZn3RuuuDtHMrCyRX8ymvJJFXmpIVl0hdJEwpy0vSn 0PhAAM/nYz6dtJSvUO5TQERf/17C9V9j9e7Jp9uAifanC3hfRS+z3+QBkN8s6XTand7t KVhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701870966; x=1702475766; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=9NtHEXBKTWTiA0icVnsHeiE8Pfrx+OjZf5R3SvMQ/3M=; b=iqPzJxlWrlgfC/rE9sX9xtN4WrEbyeLfRFu/7ax281NHYQ5f65VbCtjbN+W2m/03BT 5HyZOfoSjZF3bDDjyvDUHinKvtWEtBExM16yVUkng5GV+rb5rpeYzXJoOdHfBd4A2BBm NuQxffceEESvbwfxLezt9oubJEJXpnc6wbvmkqcy4DcY/yEtPbcky5zT5aipDuodlFN2 tCxfKUr0XLhfJhapGA8eCk3xJpso3nDzG1muANp9mUOX0cQ0dZZpOCbZEfL+BkjPeqCo S4/QRHmWFQXNeiyb68mRxhSFhZHQSnOA/+O0sgEp24LUBCWLeugB94vNK0q/5PYQPbLW q3gw== X-Gm-Message-State: AOJu0YzVl4KhiTI7rb9IcENhXpAkQhKTmvOQPbyHYWTahqxVrsbbSoQs kUs0dUW1dwsbSKe/yz5R5ppA7QSSFtQ= X-Google-Smtp-Source: AGHT+IH5c0iJqqXzNxiKLqYlDYBBvNlJXG0EAge8Ffbtw4DC8z0CPFRQ70mIfzhJ509OxMieesO2Jg== X-Received: by 2002:a50:8d18:0:b0:54c:b175:87bf with SMTP id s24-20020a508d18000000b0054cb17587bfmr646174eds.2.1701870966120; Wed, 06 Dec 2023 05:56:06 -0800 (PST) Received: from ?IPV6:2620:10d:c096:310::22ef? ([2620:10d:c092:600::2:15ce]) by smtp.gmail.com with ESMTPSA id o24-20020aa7c518000000b005485282a520sm2453765edq.75.2023.12.06.05.56.05 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 05:56:05 -0800 (PST) Message-ID: <5810c5a1-c991-4c1a-a159-6c5b16b692bf@gmail.com> Date: Wed, 6 Dec 2023 13:53:00 +0000 Precedence: bulk X-Mailing-List: io-uring@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 1/1] io_uring/af_unix: disable sending io_uring over sockets Content-Language: en-US To: io-uring@vger.kernel.org Cc: Jens Axboe , jannh@google.com References: From: Pavel Begunkov In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 12/6/23 13:26, Pavel Begunkov wrote: > File reference cycles have caused lots of problems for io_uring > in the past, and it still doesn't work exactly right and races with > unix_stream_read_generic(). The safest fix would be to completely > disallow sending io_uring files via sockets via SCM_RIGHT, so there > are no possible cycles invloving registered files and thus rendering > SCM accounting on the io_uring side unnecessary. As it involves AF_UNIX I should have CC'ed net maintainers, I'll be resending it. > Cc: stable@vger.kernel.org > Fixes: 0091bfc81741b ("io_uring/af_unix: defer registered files gc to io_uring release") > Reported-and-suggested-by: Jann Horn > Signed-off-by: Pavel Begunkov > --- > > Note, it's a minimal patch intended for backporting, all the leftovers > will be cleaned up separately. > > io_uring/rsrc.h | 7 ------- > net/core/scm.c | 6 ++++++ > 2 files changed, 6 insertions(+), 7 deletions(-) > > diff --git a/io_uring/rsrc.h b/io_uring/rsrc.h > index 8625181fb87a..08ac0d8e07ef 100644 > --- a/io_uring/rsrc.h > +++ b/io_uring/rsrc.h > @@ -77,17 +77,10 @@ int io_sqe_files_register(struct io_ring_ctx *ctx, void __user *arg, > > int __io_scm_file_account(struct io_ring_ctx *ctx, struct file *file); > > -#if defined(CONFIG_UNIX) > -static inline bool io_file_need_scm(struct file *filp) > -{ > - return !!unix_get_socket(filp); > -} > -#else > static inline bool io_file_need_scm(struct file *filp) > { > return false; > } > -#endif > > static inline int io_scm_file_account(struct io_ring_ctx *ctx, > struct file *file) > diff --git a/net/core/scm.c b/net/core/scm.c > index 880027ecf516..7dc47c17d863 100644 > --- a/net/core/scm.c > +++ b/net/core/scm.c > @@ -26,6 +26,7 @@ > #include > #include > #include > +#include > > #include > > @@ -103,6 +104,11 @@ 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)) { > + fput(file); > + return -EINVAL; > + } > *fpp++ = file; > fpl->count++; > } -- Pavel Begunkov