Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp4739708iob; Sun, 8 May 2022 23:51:49 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyEQA6xQgpEbcyrGBS1rwGdKj7nFqcfX4F9FMqGloG56BJzB6KJtcP/LRz2goViKQQsH7MS X-Received: by 2002:a17:90b:3445:b0:1d6:91a5:29fe with SMTP id lj5-20020a17090b344500b001d691a529femr24847355pjb.138.1652079108999; Sun, 08 May 2022 23:51:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652079108; cv=none; d=google.com; s=arc-20160816; b=Ozj2COdSErfqI3YSFyVOUalCEIjstBHIQltxt0GLqVf14xclvZK0ISYqTOYQeSUrW9 rhySkqIH/PXGEBqyBqysPnos11sgZM67WsX7+wkM6VkTSZg3g92YjPfmNT1MfyZ/kkTH 0IlBkT69Qf7DeejwH6cvna+vxddRNieIui7uY+w74b2crokDHB0PH+k08Q9uIOmsTdf4 aIIDRJlNSf5A/8BBGV17YpaV6pV4MJofVTCBcNTV/7/KZaIWapXZD1jPDiWrITM+XmB3 IAHs70Oe6XTIL6Mek/Alo2ude+7ip85LCyCvEZY+ZAgjGpY4W6nqmyFqtAlU7PJ2vXId 9mtw== 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=7uor6BRu3Gqk0KWw6QM42fLaqbVh8ECqNI5hzyn95iw=; b=oMqN7zM38NWRJcR98TBsxR89iou30xMN/HhhXjwBDE/h7fV9I6qDTNod+PYZGpnBTD jJYNzZ2s4wy2rN+qO3pDmXfpFTzdY1GuYVVcmsvLiyRRObqnTT/aLuv5cSqUmpmHA9R9 o58W/acTPCCarRYDDfSr/G54v20V36zsvddnJ8gzzDBaF9vFFcU2WclOYO1ynFuZsC2S 2FCy7uIhLL1TWc+KephFvCLuQ9ATdiobg1rI276EcAI442Jn2l4rDRFHrxGUf+pCxJ1c XLVFzUDUS/g88pCPrEvCfLTHFR2q6ZZHgN1hQTJ5shbEizTzkGbFPuEFi71lSQqvDPW3 ficQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hVy/T9A8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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 lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id b12-20020a056a00114c00b0050ddce187edsi14915454pfm.331.2022.05.08.23.51.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 May 2022 23:51:48 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="hVy/T9A8"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1: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: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46C9219C75B; Sun, 8 May 2022 23:49:43 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236455AbiEDR1R (ORCPT + 99 others); Wed, 4 May 2022 13:27:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1355349AbiEDRG1 (ORCPT ); Wed, 4 May 2022 13:06:27 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 971AB5131E; Wed, 4 May 2022 09:54:23 -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 5FFA461505; Wed, 4 May 2022 16:54:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id AD18EC385AA; Wed, 4 May 2022 16:54:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683262; bh=WfMlLysEVKrPRgRRFepAQTUpFSGJd3MAjR8Aqdb97Iw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hVy/T9A8JJLG5tnWYL9NNHNnQHo5rz/vgvllZiWAlSLrDIrIfi+tOi0mlvbT7M9ll ZaX+s7Mo43ydvraVSwNnHvtQkF++5kDJ2JJ+iW/9Kcf11NDkTEtcy7rM1Zid5dcgu3 ibw8cYeEq3uvaJjLULjfjTWQOblxrWO8QUCugznM= 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.15 112/177] io_uring: check reserved fields for recv/recvmsg Date: Wed, 4 May 2022 18:45:05 +0200 Message-Id: <20220504153103.234734066@linuxfoundation.org> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20220504153053.873100034@linuxfoundation.org> References: <20220504153053.873100034@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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 48c9a550e48c..7aad4bde92e9 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -5009,6 +5009,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