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 Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA6B2C4707A for ; Wed, 4 May 2022 17:17:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357787AbiEDRUC (ORCPT ); Wed, 4 May 2022 13:20:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55274 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356949AbiEDROh (ORCPT ); Wed, 4 May 2022 13:14:37 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 76AD053E24; Wed, 4 May 2022 09:58:18 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66F4361926; Wed, 4 May 2022 16:57:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B11FFC385A5; Wed, 4 May 2022 16:57:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683475; bh=FSy8OxLu6ImTtFkfpaaWWjsYOWcsYH05gS/6+cpnjGc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=X9cGs9OrrS0ppgCIU3M6I+6TaZ0f8Um5KFDJOp3TVqHtxQqWRyeKxRtrT7ilSkM1t 0ijRvGRLvAZZVltQoyUmg9mxomgc0Ag/7EhVSwej0SDQOOWaLNkPd2sgpuXW47ap0x tAJ0Hq8VFoMERq2izSdS9G+Iz8521CmGu01CgB4A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jens Axboe , Sasha Levin Subject: [PATCH 5.17 137/225] io_uring: check reserved fields for send/sendmsg Date: Wed, 4 May 2022 18:46:15 +0200 Message-Id: <20220504153122.491940346@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153110.096069935@linuxfoundation.org> References: <20220504153110.096069935@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Jens Axboe [ Upstream commit 588faa1ea5eecb351100ee5d187b9be99210f70d ] We should check unused fields for non-zero and -EINVAL if they are set, making it consistent with other opcodes. Fixes: 0fa03c624d8f ("io_uring: add support for sendmsg()") Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/io_uring.c b/fs/io_uring.c index fbba8342172a..107bce75131e 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4890,6 +4890,8 @@ static int io_sendmsg_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) if (unlikely(req->ctx->flags & IORING_SETUP_IOPOLL)) return -EINVAL; + if (unlikely(sqe->addr2 || sqe->file_index)) + return -EINVAL; sr->umsg = u64_to_user_ptr(READ_ONCE(sqe->addr)); sr->len = READ_ONCE(sqe->len); -- 2.35.1