Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp3012369pxb; Mon, 18 Oct 2021 06:35:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKQTlNzPc0GDZ7/uvjuMj70bC3VQ/7dAxC1zndDkQYNEHe28CdAI68d+zpmx06w3HWcf3W X-Received: by 2002:a63:f84f:: with SMTP id v15mr24016288pgj.204.1634564121953; Mon, 18 Oct 2021 06:35:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634564121; cv=none; d=google.com; s=arc-20160816; b=Ia18aaEyZKSsGqJwbZKWzb2NI1QLIw8KMG2ThzynOltjMgrOKxPUakmFqbDBaIZE+7 qdeXeC7J4hLL0ClfjlcCRBdmaiM0kdV22kv3arajLv2/PtlIfqOr4JoDU/LTUp0+zCib Vm4dfyAXofGfPsSGv/a1h1+0+/VYZwKN6cFv/4koRWbQad58G2R2yB83zgn1qPr946AP e68iW/Ey0To/iCMtA4AXr01sNb5EO7ATk4Y3vZy1ZhTXX66934/d2whOczB8HKKyg/vi MSEU+MreBketvHxphQq9oiNidcYPvSoKuiFJaOl5CnweDi29ESLQVV2XwaYg+Tyms21W jPNg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WlCBrY8npT2R5tzFkOtnvWSyCqQZIWQ7lTwctWi1oMM=; b=Sm7uFX78iWjM4f9IHIq5/18N53cqdfh2zZadxJXW/4iAukINBPNu6SN+i5z4qOu7bc bLaRPviZJD0YgLEKVvO9OFwoatTKRuXxHTvX6i0SF5T2vCAg6l+obeKtgRZKneHGLI3P 598HqU4JHQeC2aikGf3CgriYDMBeT2yclq3V2gaqfHsJ/6g4zX+rGSnK0QVRVvjvsmdb z9xZcPf48ceqrqUBYKDTAgy7adRuZxi3cG1zhxAVlVjoIyHoptKf+GUs5i4QD5CCTOmG H1inmn/ljima246K0e8k6pKbtXXWhYVJ0XsFvrnKahyWEaK7YlQPRyQw9xQRQ9s6se+V xTaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pqEG+7G2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h5si19922455pgp.537.2021.10.18.06.35.06; Mon, 18 Oct 2021 06:35:21 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pqEG+7G2; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbhJRNe5 (ORCPT + 99 others); Mon, 18 Oct 2021 09:34:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:42364 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233171AbhJRNdN (ORCPT ); Mon, 18 Oct 2021 09:33:13 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 251F66139D; Mon, 18 Oct 2021 13:29:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1634563774; bh=IXYRbfJWY0jx1X38fkKwwubhQ5ijdz/nnxdaewCGGgQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pqEG+7G2a5aJ6VJn67GjDwd/AlHrz8LIb3JFcL+bZHxatTZ3k8XSuW6I6jlQi3QG/ bYgJzdd514csEu2qVhmkb49PQlIdXcYG7oF7GDxbShfWLv4Lsz3KoStGbsLxKQtwM9 78ULZhIjNu8mVULzVe/AEXyMDlia9qqA2HRnCVjQ= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Miklos Szeredi Subject: [PATCH 5.4 01/69] ovl: simplify file splice Date: Mon, 18 Oct 2021 15:23:59 +0200 Message-Id: <20211018132329.502323802@linuxfoundation.org> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211018132329.453964125@linuxfoundation.org> References: <20211018132329.453964125@linuxfoundation.org> User-Agent: quilt/0.66 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miklos Szeredi commit 82a763e61e2b601309d696d4fa514c77d64ee1be upstream. generic_file_splice_read() and iter_file_splice_write() will call back into f_op->iter_read() and f_op->iter_write() respectively. These already do the real file lookup and cred override. So the code in ovl_splice_read() and ovl_splice_write() is redundant. In addition the ovl_file_accessed() call in ovl_splice_write() is incorrect, though probably harmless. Fix by calling generic_file_splice_read() and iter_file_splice_write() directly. Signed-off-by: Miklos Szeredi [reported to resolve issues with 1a980b8cbf00 ("ovl: add splice file read write helper")] Signed-off-by: Greg Kroah-Hartman --- fs/overlayfs/file.c | 46 ++-------------------------------------------- 1 file changed, 2 insertions(+), 44 deletions(-) --- a/fs/overlayfs/file.c +++ b/fs/overlayfs/file.c @@ -296,48 +296,6 @@ out_unlock: return ret; } -static ssize_t ovl_splice_read(struct file *in, loff_t *ppos, - struct pipe_inode_info *pipe, size_t len, - unsigned int flags) -{ - ssize_t ret; - struct fd real; - const struct cred *old_cred; - - ret = ovl_real_fdget(in, &real); - if (ret) - return ret; - - old_cred = ovl_override_creds(file_inode(in)->i_sb); - ret = generic_file_splice_read(real.file, ppos, pipe, len, flags); - revert_creds(old_cred); - - ovl_file_accessed(in); - fdput(real); - return ret; -} - -static ssize_t -ovl_splice_write(struct pipe_inode_info *pipe, struct file *out, - loff_t *ppos, size_t len, unsigned int flags) -{ - struct fd real; - const struct cred *old_cred; - ssize_t ret; - - ret = ovl_real_fdget(out, &real); - if (ret) - return ret; - - old_cred = ovl_override_creds(file_inode(out)->i_sb); - ret = iter_file_splice_write(pipe, real.file, ppos, len, flags); - revert_creds(old_cred); - - ovl_file_accessed(out); - fdput(real); - return ret; -} - static int ovl_fsync(struct file *file, loff_t start, loff_t end, int datasync) { struct fd real; @@ -694,8 +652,8 @@ const struct file_operations ovl_file_op .fadvise = ovl_fadvise, .unlocked_ioctl = ovl_ioctl, .compat_ioctl = ovl_compat_ioctl, - .splice_read = ovl_splice_read, - .splice_write = ovl_splice_write, + .splice_read = generic_file_splice_read, + .splice_write = iter_file_splice_write, .copy_file_range = ovl_copy_file_range, .remap_file_range = ovl_remap_file_range,