Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp2368257iob; Fri, 6 May 2022 00:43:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw0YM8qDO46mZxp+vPUT0EB2OPa1jXDzl9lrFsQ1Xt2LNlwUbe5CuWo+rMHe0v5bx6yZ8i0 X-Received: by 2002:a17:907:2cc3:b0:6e6:45fb:39fa with SMTP id hg3-20020a1709072cc300b006e645fb39famr1760428ejc.545.1651823007351; Fri, 06 May 2022 00:43:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651823007; cv=none; d=google.com; s=arc-20160816; b=DBZlpuVXFxB6e5dcSArxfxzNYL1TWBxxK3looXqTIKi9TNbDuhyrN0Llq5KDrhM6Gd FpGpA3SsZY3FQD23LVkJv4K9pZIfJdO60wg1ox6XGUcRpFg2nRXHYYTfJNg7FQhIsN77 2ixeTl8t2DQ0ByQPz1nE23Bomn42M3UZySO3pqTYAWgoFWkr1lXTkF9H4D4bOnWZutsJ bSgMCGJwkgCOhAPw4lNP0Uti2QlwOpTsaRHTN4E54CcH6rzD+2y+Y3SBK99zbzOkVyjQ 5+/Rp63kXguWLi5GPQrA5PHmjDPGPhoGR2hV2Pzqivw18eqISeo9XDNzUQUElfCnCLaM gOyQ== 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=/F69envjaqpc+M8OODRIWRWYzGqU8rFvpuR+LUbjxDE=; b=FIA/eXCf7BFnquC7Pvygk1Pw9RnH4/OeYicEfIWvdseNB8Tpn9JZOy4I+KzDMglda8 Jf9u3ok9LMxc55rCEllrHQJKImaE1XjYvlryWaCiN7b1w9kcU5vBOHwEM6N+dSZJX3ti pcin94Mqf3Pfw0/3RNcQzgpgsXIrbKPVWMLuDRQFugfp4dCx9hkVYdWFZtrYrwp43UFF tLYJfHmbtS4F8nlXStR1AJ+7LQ0sAkrAqBoy1QFGzS96SF5PrndZ5oK/5AVtsOC4pt+j C/SuT3WeXNfN34z1zqMtSoIXW4MJyjvauMn/SI74h/W9SnOnmIFGxXPL+ShMSBRYs7LT ax1A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tC4sruaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 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 out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g22-20020a056402321600b00427f9b2477esi3734227eda.448.2022.05.06.00.42.58; Fri, 06 May 2022 00:43:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=tC4sruaK; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1357149AbiEDR03 (ORCPT + 99 others); Wed, 4 May 2022 13:26:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51332 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353159AbiEDRFU (ORCPT ); Wed, 4 May 2022 13:05:20 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A7235133B; Wed, 4 May 2022 09:54:15 -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 C386561896; Wed, 4 May 2022 16:54:14 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B196C385AF; Wed, 4 May 2022 16:54:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1651683254; bh=V/5M8e8MGND+F+zgU4fwcSKS4RgrHl+diawDinNCLTw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=tC4sruaKsbzsrPUaG4cCRAauocgxewfJiCae+3R6tuaO7FIXbSjOFk3Wuoh5HMFFs tHzd3M6Xq84WUJcbhlPX6NzIpSElt10BUEJ7E9Rl7xbd3lxaWRX89vp47+QPKySu4B tJOnlsDQVpQHK/pB33dI6zULiY6H5lRH3n/RLL/4= 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 111/177] io_uring: check reserved fields for send/sendmsg Date: Wed, 4 May 2022 18:45:04 +0200 Message-Id: <20220504153103.153328353@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=-7.7 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 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 1bf1ea2cd8b0..48c9a550e48c 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -4786,6 +4786,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