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 9771BC4707F for ; Wed, 4 May 2022 17:52:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376727AbiEDRzO (ORCPT ); Wed, 4 May 2022 13:55:14 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55504 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1357057AbiEDROq (ORCPT ); Wed, 4 May 2022 13:14:46 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 36F7454180; Wed, 4 May 2022 09:58:19 -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 57422617A6; Wed, 4 May 2022 16:57:57 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A36B9C385A4; Wed, 4 May 2022 16:57:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683476; bh=pPUIlAMOVYe9srKo2SbyhxPjEu2zN8+V4ndrRz4piyc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K3FKZWwDbgEz9DNS0mr8us0dSrX6QhkIdREvw53ij7dqIjSrhtdFEpj/UEyNFpc54 DDxwgvdqtYohAN34k0PZc5X7PYpdE+lmqxNoLDabghLwI7aAYM81saGoN+zdhbiFd8 ab4mBtFXIGQ16UeWUzrmf5M3esbRZx8wC9+Bcl7c= 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 138/225] io_uring: check reserved fields for recv/recvmsg Date: Wed, 4 May 2022 18:46:16 +0200 Message-Id: <20220504153122.566841289@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: linux-kernel@vger.kernel.org From: Jens Axboe [ Upstream commit 5a1e99b61b0c81388cde0c808b3e4173907df19f ] We should check unused fields for non-zero and -EINVAL if they are set, making it consistent with other opcodes. Fixes: aa1fa28fc73e ("io_uring: add support for recvmsg()") 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 107bce75131e..531d0086d0b3 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5103,6 +5103,8 @@ static int io_recvmsg_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