From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A3DDCC35254 for ; Sat, 8 Feb 2020 10:29:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7D9CD20726 for ; Sat, 8 Feb 2020 10:29:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Z5V55QYH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727317AbgBHK3I (ORCPT ); Sat, 8 Feb 2020 05:29:08 -0500 Received: from mail-ed1-f65.google.com ([209.85.208.65]:45972 "EHLO mail-ed1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727195AbgBHK3G (ORCPT ); Sat, 8 Feb 2020 05:29:06 -0500 Received: by mail-ed1-f65.google.com with SMTP id v28so2385043edw.12; Sat, 08 Feb 2020 02:29:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=zZANyoUtLJgO2X0P6+mGDVLO8WvlROP6oDHUPiBS41o=; b=Z5V55QYHJ6M0QOchakaJ+C95zcPvNTMHdQRnK5IJfwrrjnh0xE+3wvt4lgeeTt4BDm iRA74+Lqbg2SrUv0rQDmDg4NiLIKk9NChuNLWPY9dFlQLkfUrOKcBe4bYgPlpv8v5CnL T/Z2KlE24xXGBPMP3MNb37w3wkOx8E30P6zV7A03saLKqJsyetTew1+D5+FgiZenQop1 2ccVWoZ2PsSnCD30UWelnz9eyyW6RMt0e4SZ5sEZsv57clPEiyNXsdxb3mt/25rkgTDS WzFT995rh2GElti69ZmnYTUcYrjvkvF4Ea7NwncVCXinnu4eJMAWKAGfgLt++iBFk7lD Dtjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zZANyoUtLJgO2X0P6+mGDVLO8WvlROP6oDHUPiBS41o=; b=DxSvD79Snj7/rql1Ef8EtgofB5KV73lU5gqhpQTi7+wWXrXS5N+UBVtc7R/B0DbeeG 6hQbAOsWiZJGMJQHhyV7z0rLOpiQnI88Kpnfq/H2E7I6eSp2uQwTqckG0ilWoF6hiRcb +kdVlOb9G1EyJi7rQqUDj/L1BcKchOjW7dZLKyBPe/R04tCGpJjB1KCdjREyPbCiROAo z5mp5g9PpcQDm8Tl59UpUBbCQVdkj/v93+Kns2cknjEF7k41WLCWaERi/t1dCECghLn5 zpNgfb9TQoBWmzJ5oywiFqleFiFULAPy24wCYcVoxUlUXV02gHZwHdqUP1Uv0FI5zDt6 YnAg== X-Gm-Message-State: APjAAAXMTE5RhP6qgi+fX4GjyUUAreqfm9tnCUWIVXsYnsypez+Y+Ku7 N1FS9f5zilXUe0tKthbU2ZU= X-Google-Smtp-Source: APXvYqzAyJtG0w+5SrLqkpfET0wQjyfRnGbRniypN3xH00arCjp3js9BeMdpSLeLRKK1cq2EeSAipA== X-Received: by 2002:a50:fb82:: with SMTP id e2mr2936983edq.359.1581157744209; Sat, 08 Feb 2020 02:29:04 -0800 (PST) Received: from localhost.localdomain ([109.126.145.62]) by smtp.gmail.com with ESMTPSA id f13sm257742edq.26.2020.02.08.02.29.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 08 Feb 2020 02:29:03 -0800 (PST) From: Pavel Begunkov To: Jens Axboe , io-uring@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/2] io_uring: fix openat/statx's filename leak Date: Sat, 8 Feb 2020 13:28:03 +0300 Message-Id: <14f45901fa84b4f9f46e7cf9afa20ac1324f6ebd.1581157341.git.asml.silence@gmail.com> X-Mailer: git-send-email 2.24.0 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: io-uring-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: io-uring@vger.kernel.org As in the previous patch, make openat*_prep() and statx_prep() to handle double prepartion to avoid resource leakage. Signed-off-by: Pavel Begunkov --- fs/io_uring.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index f5aa2fdccf7a..c3bac9d850a5 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -2536,6 +2536,8 @@ static int io_openat_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) return -EINVAL; if (sqe->flags & IOSQE_FIXED_FILE) return -EINVAL; + if (req->flags & REQ_F_NEED_CLEANUP) + return 0; req->open.dfd = READ_ONCE(sqe->fd); req->open.how.mode = READ_ONCE(sqe->len); @@ -2564,6 +2566,8 @@ static int io_openat2_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) return -EINVAL; if (sqe->flags & IOSQE_FIXED_FILE) return -EINVAL; + if (req->flags & REQ_F_NEED_CLEANUP) + return 0; req->open.dfd = READ_ONCE(sqe->fd); fname = u64_to_user_ptr(READ_ONCE(sqe->addr)); @@ -2763,6 +2767,8 @@ static int io_statx_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) return -EINVAL; if (sqe->flags & IOSQE_FIXED_FILE) return -EINVAL; + if (req->flags & REQ_F_NEED_CLEANUP) + return 0; req->open.dfd = READ_ONCE(sqe->fd); req->open.mask = READ_ONCE(sqe->len); -- 2.24.0