From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-oo1-f45.google.com (mail-oo1-f45.google.com [209.85.161.45]) (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 17D883FCB3A for ; Tue, 31 Mar 2026 15:24:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.161.45 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774970673; cv=none; b=iZvq0QfnjDY2bFii0WVAD9Iigu7QojXN9H1EnbNgu7YrWa6m916wIu0pYqt3c3WKeEJLh4dXSqX60w3HxWv4B1Klulrw2UrJJXbODzA1AIZxVfwNzjFEvBTy/I7hKNZfMf6w5UQOu8qTu1UaKqtq/uVQFxuoHQOlTiU/8RKB4e0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1774970673; c=relaxed/simple; bh=ldSTm4EWaCOx+pwbIQI8ZcZgJB7UuIot9wRDbRrsEVU=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=c5QztHriEHnWW+RbHk1dgWyiU0RVrr+fTDXpM9tarG9a8kWmGjpGwpqvWuNysaOn1xuLGZlGzM81XA869kTbcgG5Z2slCiXsTtwj/tn0vw4aEmvI1P7q0i1G6QH2TmUQdXWM/KFBMoLqunb1x4iEo9yrf901Nwb0XqyyymLEufw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk; spf=pass smtp.mailfrom=kernel.dk; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b=QMY1/BbE; arc=none smtp.client-ip=209.85.161.45 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=kernel.dk Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=kernel.dk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel-dk.20230601.gappssmtp.com header.i=@kernel-dk.20230601.gappssmtp.com header.b="QMY1/BbE" Received: by mail-oo1-f45.google.com with SMTP id 006d021491bc7-67e23011c93so1070162eaf.3 for ; Tue, 31 Mar 2026 08:24:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20230601.gappssmtp.com; s=20230601; t=1774970671; x=1775575471; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=NKPrNSDcQjGjdl2sN+7+/jouhXcRgam12FF4jGlIj3Q=; b=QMY1/BbEPjWKzbJNoRxdHsYowhSNI6nfD4sqrYj+YUt2JRoxnth/LHjpUbY8iBc0mh Cq9VdsWK8hrDST7u3zNtMpVCNevvGuUwmzh/WazI/m+6WsBC+/7JXPw4Cn2XW+RRkCD+ 3I+CJYwr1lMpqcCqq+0DjQ0IdcPDeL4bMJILdcBmqWjDuN/p7qnPUnNWzIXP2o6kVE/x h9E5LBkCIHREFzZFuniZUT4HQQvQxV4jNqcDGkjMHwgYkjHtmVF4JWnJyjdDupCz/FNM scQCmN2/LJQF59Y+P37kC0a6/BA8g6XeDcAWmxbFNuG4nNnFNlPM1t5VVnut78ofFwQR mpuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1774970671; x=1775575471; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=NKPrNSDcQjGjdl2sN+7+/jouhXcRgam12FF4jGlIj3Q=; b=tT4hLRyAcxnBW596YNURH09xZWjIZSBFa9jQMbzRNq8b0Bbk6qORXb3DhGZJevGa1Y n4uGwTVk7jadSrO+uPC5hSfsHFp7XjttN4OV3HwvtDCZRuyI7mIsAc2qdp0Ee4DhBd5z iq5t5948bzLCAbh08IfFMapBTxFriYb/lXgCX/S4p6rZaBlriEpGE1YU5aGaja35dhCM 61gHczpqnFS2/Trowdbgd3YXUDFWUSC7Vp7/NQXrEUwSPThkUszVXRwVLgErKAt/OR5E +MlNXpy63NodIiKw2Kc1rOxvQe0caz3CHBToChqrJvZ+BMZlPviO3cLVpreIoVDTmTmJ 4EXw== X-Forwarded-Encrypted: i=1; AJvYcCW64Fi6kZoXmZhKNQQfi8Ft1CrSvKHh1aYQwUJL2ce87LM3QARxZ7myoZ6QyQj09SK/gsM8dw89/czKFLg=@vger.kernel.org X-Gm-Message-State: AOJu0YxTiARz6I2TzvXrjph8oDvnBCFYSvfRkIdqpa/rGxcjUEXCSP1Z ri1jBMZmPN+WY9PiUs1l3waWc/PAqJHWuIkyVWCBTFf7k+ndq/wQfHZu+t9F686qyNc= X-Gm-Gg: ATEYQzwh3CM4c09btPK0bpPcY9dfJqa+ZzoJfhPffMtVXu6hbG/j1N5QIqeiE46iN1o /PC5xzCKOAbQKowqchyCkBVTppQxgRW5WdzumGWyle05pzphf15eB92uOiofotE2+ENUmj4UIAl WQv1NsEStCMinUC8hIZGxDqDDetjEFkmSHK2ehRz2BoBur7X/UyDETs7tStlISLndLkeNtkntvV 1dUrueY5vIFFc5vc+74xkwk2GPklAcq1pbezBY4PkAJG0BhDjsxdqPPv1l8xgzp7YkYu/SSJeAr ppsTcN7wfDWuubr0sjzTzCagZqFQggwvOIZQmaRETr8oc9tb2YsLYn4m9snXYsUOcyXc5aePYoT JBeBHS/VgmyGH1lB8Hrc+KPplRJkFZ54RiJgKXsj8sC1WHoPxq1donZhKRNGGeAycQWUzN8tYGD EWQnQ6jBqCS18B3lyy/cobpffzftBMfHUvyF6Rnd75yifTxr00002Q5p5QHU6szdQ41kfZUlFPJ 7OYmngED5C6BeqNw6Ho X-Received: by 2002:a05:6820:c85:b0:67e:3bed:5b7c with SMTP id 006d021491bc7-67e3bed5cbemr2787017eaf.38.1774970671007; Tue, 31 Mar 2026 08:24:31 -0700 (PDT) Received: from [192.168.1.150] ([198.8.77.157]) by smtp.gmail.com with ESMTPSA id 006d021491bc7-67e2302f591sm6995602eaf.1.2026.03.31.08.24.30 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 31 Mar 2026 08:24:30 -0700 (PDT) Message-ID: <26d2e8f0-8b82-4192-9edb-e31f3975bb82@kernel.dk> Date: Tue, 31 Mar 2026 09:24:29 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] splice: prevent deadlock when splicing a file to itself To: Christoph Hellwig Cc: Deepanshu Kartikey , viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, syzbot+d31a3b77e5cba96b9f69@syzkaller.appspotmail.com References: <20260320130615.1109449-1-kartikey406@gmail.com> Content-Language: en-US From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit On 3/31/26 9:21 AM, Christoph Hellwig wrote: > On Tue, Mar 31, 2026 at 09:15:07AM -0600, Jens Axboe wrote: >> On 3/31/26 9:10 AM, Christoph Hellwig wrote: >>> On Fri, Mar 20, 2026 at 06:36:15PM +0530, Deepanshu Kartikey wrote: >>>> Fix this by checking if the input and output files share the >>>> same inode before proceeding, returning -EINVAL if they do. >>>> This mirrors the existing check in do_splice() for the >>>> pipe-to-pipe case where ipipe == opipe. >>> >>> While restricting splice to be between difference inodes sounds like a >>> nice simplification, I'm not sure we can add it 20 years after the >>> syscall was added. >> >> Well if we could break splice all over with: >> >> 36e2c7421f02 ("fs: don't allow splice read/write without explicit ops") > > Well, that had an easy way out by converting instances people actually > used to the iter ops. Which we ended up doing for a few. Sure, and it was the right thing to do, but you still end up with a broken kernel for that user. Until it gets reported, fixed, and bubbles back to a kernel that they can use. IOW, no different than this one. >> then surely this one would be OK too? > > While this has no way out. Not that I would complain if it worked, > but splicing into the same file doesn't seem like a too outlandish > idea. OTOH it probably already didn't work for file systems that > take i_rwsem in the read path like XFS or these days the block > device node. There is a way out, it's reverting it. I'd be surprised if this didn't trigger issues already, like the flagged one. Thing is, I don't really see an alternative fix to this... -- Jens Axboe