Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3494026ybz; Mon, 4 May 2020 04:12:04 -0700 (PDT) X-Google-Smtp-Source: APiQypKY4+B2BEFB208Inonb03FVeh3nvlHKNp4UmmFz1WYVzQazFRaMRsGWd5PT2ZJkPR/uU21P X-Received: by 2002:a05:6402:b2a:: with SMTP id bo10mr14497144edb.366.1588590724581; Mon, 04 May 2020 04:12:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588590724; cv=none; d=google.com; s=arc-20160816; b=zE9JmwaB4pFgUDZFyIfc1o0yCJ4XMzmPAKP68B/43bbWIaFM7H+j1WeIrRWrkaHelA 7oaZKzBf+iDz0d4w5cTPcLUFS926yNJDBVhclA+FpZOboV2bHL+G73BiD5p1j/SCK3PU WR2uoWjvOUBtPJHiBaX91n8BegLq3c4jYibCsWfFpLBpGnm6C/T5TyzqXgizVPB0OTb9 JcY9aaN5x3gLjK4G5HvlE41BSZEgU2PldN2IrXZXA0/ad9q0GYzMEJGrjt61uDe/vREb EHHMbrcZ4MLf7yKH9X4hHAQketBl2xhQIp+QwVUFQwduSDYNuB5qXn3F0AwwR2DxPnwP mDbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=kdLTHxO9IddcIoMI/8THqMR0N6LIXAbkMhmdlHl48Hc=; b=e+Ucumv238eirOFw1IiDi3tyMHcfWKQ6h+SoI9qZyDUEPYI0A5orZRuyl/lp4Niqas zMya/x8Z5gpXPPPiQg9iL7Lr+wIEi4xhus6YkGuQ18yokkDw92LvVfYqA+MkTSUL5sx2 Z3b8Pn/btA0C2xfY5RDEnol+a7ih8JU96DjdKGVFqnsEKxtX76HcDzvi819RojwK59ur KgUvXuRbJD8JLMoMoDweDgDMFbWMS2qTSCEXizNkvDAQHpdlbtJItU/Rc9AxBoZEZWHz p6AA+y3EmlCV+axfJiifEPYwC8q6NTcLKbrgA3T1FqySAkmBvKc5Jp8Jj/Per8MJXqsG K81w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b=EBkBWfDs; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p8si6986664ejz.441.2020.05.04.04.11.41; Mon, 04 May 2020 04:12:04 -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=@google.com header.s=20161025 header.b=EBkBWfDs; 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=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728119AbgEDLJb (ORCPT + 99 others); Mon, 4 May 2020 07:09:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1726445AbgEDLJa (ORCPT ); Mon, 4 May 2020 07:09:30 -0400 Received: from mail-lj1-x241.google.com (mail-lj1-x241.google.com [IPv6:2a00:1450:4864:20::241]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7E5B3C061A0E for ; Mon, 4 May 2020 04:09:30 -0700 (PDT) Received: by mail-lj1-x241.google.com with SMTP id a21so9186250ljj.11 for ; Mon, 04 May 2020 04:09:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=kdLTHxO9IddcIoMI/8THqMR0N6LIXAbkMhmdlHl48Hc=; b=EBkBWfDsbVxU7ShnPu9MmCzKnY96MUEv8NG3QCP9FdBISR6BN2GZq9UQ3Cdmg/flkp +OVkM1mF0URDaXGbY+OD9SsFs+ceKjLZinXQU+NCB8VLXKVxXZfOmBNODg6s1f2vWgN0 6+rjuqtE2q09uIcQDXvWXWuS+4MBSvAov8MAMrr+whe/6rNQgDPi7lxMMgo4cllYt658 jZG7FaTHkSrUDBifEO7ZZomaXD5NM1ez/9Kmv7A99+Vw9wIPnP0o3hTrbAnpSsL8+gHn y3zPSNwlkmrx8VTaMHd+KfDN5FJYOHTHFUgzihcLJi01WIe2AsRJjU4JP+mmM38ZBY5d Pi/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=kdLTHxO9IddcIoMI/8THqMR0N6LIXAbkMhmdlHl48Hc=; b=ebPBd0j4ggJd7AhN9Z43mLWH37CZWb4Y5dDE1jATg3ryh9+nlMEQ9ZreKS5ulTm/Mp 7VmKqsW5V1uNH4HfORrtObIFKBCYNpFb3iQd2NDJ9HKGmpEiEU6VYhDfSoD1P2sB+EBl M5pl05oQMPNqsXe/lb4k1DlhYNjG2Y/rZC3YcDW47xHqtd4uGlkZmk4BvtoEBK3ovqeM Se/8WFga75g3mh370eSSc8I2sxe2yI8mGHq3qu0Xrdr7LMnBj6v4JWSeHuTsWOm7CDMg kJK3iF8t68u8whNthPJzlYcJQ9e87YhUzwwTwppobUmPpsKH5avYRRRwdqf2AiVJItDU ckxw== X-Gm-Message-State: AGi0PuaH4ZfpGzX+aHNdI9DEouvc9qLRH/DiVLwmK9HLFG2xh7xcU4b2 VPrwm/sgqc96c5uCiDpzNr/uVxat0XNsF57H4WGeoYa6 X-Received: by 2002:a2e:8087:: with SMTP id i7mr9226190ljg.99.1588590568751; Mon, 04 May 2020 04:09:28 -0700 (PDT) MIME-Version: 1.0 References: <56e9c3c84e5dbf0be8272b520a7f26b039724175.1588421219.git.asml.silence@gmail.com> In-Reply-To: <56e9c3c84e5dbf0be8272b520a7f26b039724175.1588421219.git.asml.silence@gmail.com> From: Jann Horn Date: Mon, 4 May 2020 13:09:02 +0200 Message-ID: Subject: Re: [PATCH 1/2] splice: export do_tee() To: Pavel Begunkov , Jens Axboe Cc: io-uring , kernel list , Alexander Viro , linux-fsdevel , Clay Harris Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, May 2, 2020 at 2:10 PM Pavel Begunkov wrote: > export do_tee() for use in io_uring [...] > diff --git a/fs/splice.c b/fs/splice.c [...] > * The 'flags' used are the SPLICE_F_* variants, currently the only > * applicable one is SPLICE_F_NONBLOCK. > */ > -static long do_tee(struct file *in, struct file *out, size_t len, > - unsigned int flags) > +long do_tee(struct file *in, struct file *out, size_t len, unsigned int flags) > { > struct pipe_inode_info *ipipe = get_pipe_info(in); > struct pipe_inode_info *opipe = get_pipe_info(out); AFAICS do_tee() in its current form is not something you should be making available to anything else, because the file mode checks are performed in sys_tee() instead of in do_tee(). (And I don't see any check for file modes in your uring patch, but maybe I missed it?) If you want to make do_tee() available elsewhere, please refactor the file mode checks over into do_tee(). The same thing seems to be true for the splice support, which luckily hasn't landed in a kernel release yet... while do_splice() does a random assortment of checks, the checks that actually consistently enforce the rules happen in sys_splice(). From a quick look, do_splice() doesn't seem to check: - when splicing from a pipe to a non-pipe: whether read access to the input pipe exists - when splicing from a non-pipe to a pipe: whether write access to the output pipe exists ... which AFAICS means that io_uring probably lets you get full R/W access to any pipe to which you're supposed to have either read or write access. (Although admittedly it is rare in practice that you get one end of a pipe and can't access the other one.) When you expose previously internal helpers to io_uring, please have a look at their callers and see whether they perform any checks that look relevant.