Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2658212pxa; Mon, 17 Aug 2020 15:44:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxeU9OqgBmJ4IjKpOEzF7pu1uaKm3xW/Miv667/8MnSgnMX6ptYp0r151wdUCKZFNd3SLV2 X-Received: by 2002:a50:c38b:: with SMTP id h11mr17289456edf.308.1597704299456; Mon, 17 Aug 2020 15:44:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597704299; cv=none; d=google.com; s=arc-20160816; b=YxkVFgOG851vjIenzFF2y/8+44hMEtAhPnkMHxyZFaTkgwAA8UCfyW7IrIptVSGWQO MGkexuKgrUl+Icb8bT8fVxtYPINvW6E+yCbcdoW0GQQnWDn653a8qIUQxhS2eLmPIcb1 i5CcI+X7oqQYb+ijpsEMjiER/wJYilrEs5fh783PuCLJC872MgCtnGTNwadRi0KQb0Z0 FqkIuHiT0QnqtK7EiQ4RX12O1fbumqJxyMPg+oO5dmNwiJGMq9LtioUHheH+hixSkb08 M9biRMEH4Wd6LPsbKFfvNvGHY5n6GfsE5D9611l+zg2VX/ktT9JjTw527jrvgTmS6J5L fxOw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=a3JW9RX839gnIUATpuWRqqWRJ1bWUbCxkAyIbOdqJ/Q=; b=z9D0PgAbMxEpKtvaf12XGS/aJEFjBuL99ivxJLeUOKBDTkXpEqEqVAgZrPxyOta7C/ 6Z8zxZZIcW29sltnO7NMEN4961iKhw7/UfrIeX1lulwaX4yK1vByhl8Id+tkaJSuTCzt jgyCUw/C8M7L3cjozYihCizLzJhqiX43ikfg/oITkAr+oPdvLUSnUrXibbCNcM6Bsrqv VVQBwJNfRYv6hV2ZGXdqNgyYGNI+lZ+z8nA/rq42+aH6Ezg4HuRagEk1v9gIWyOMbWjY nikSkmwWP7KpGY1ZklPBEioWd67YBWqYGqy2+TkPBclGKRcssOAvHGVFQCc/gMVB0vwe wm7w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2gkoS6w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id di8si10622136edb.395.2020.08.17.15.44.36; Mon, 17 Aug 2020 15:44:59 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=P2gkoS6w; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392054AbgHQTJR (ORCPT + 99 others); Mon, 17 Aug 2020 15:09:17 -0400 Received: from mail.kernel.org ([198.145.29.99]:52698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387552AbgHQPmd (ORCPT ); Mon, 17 Aug 2020 11:42:33 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id B746320760; Mon, 17 Aug 2020 15:42:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1597678951; bh=FF9yg5Lc3uJgdvr2qf/PcEfwb6Gc7NL6cBLxzjc8CS8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=P2gkoS6wIXckcogzlS5Sy1DmJGwqLJ95lpaipXMZU4Wg2o4KWC9hNe5uf0SDwNOFd 2pAEpQSLAw749w4fj4PeR0WH1sMJy4YmyeIIV43a41J4WujAAnMqeHUKSMIbR5xoQE vGF8aTHv+dPSEMMMXYiyt0aczs7zli4YmoXttL8Q= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dmitry Vyukov , Hristo Venev , io-uring@vger.kernel.org, Jens Axboe , Sasha Levin Subject: [PATCH 5.7 045/393] io_uring: fix sq array offset calculation Date: Mon, 17 Aug 2020 17:11:35 +0200 Message-Id: <20200817143821.785749994@linuxfoundation.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200817143819.579311991@linuxfoundation.org> References: <20200817143819.579311991@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Dmitry Vyukov [ Upstream commit b36200f543ff07a1cb346aa582349141df2c8068 ] rings_size() sets sq_offset to the total size of the rings (the returned value which is used for memory allocation). This is wrong: sq array should be located within the rings, not after them. Set sq_offset to where it should be. Fixes: 75b28affdd6a ("io_uring: allocate the two rings together") Signed-off-by: Dmitry Vyukov Acked-by: Hristo Venev Cc: io-uring@vger.kernel.org Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 5405362ae35f1..04694f6c30a04 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -7139,6 +7139,9 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, return SIZE_MAX; #endif + if (sq_offset) + *sq_offset = off; + sq_array_size = array_size(sizeof(u32), sq_entries); if (sq_array_size == SIZE_MAX) return SIZE_MAX; @@ -7146,9 +7149,6 @@ static unsigned long rings_size(unsigned sq_entries, unsigned cq_entries, if (check_add_overflow(off, sq_array_size, &off)) return SIZE_MAX; - if (sq_offset) - *sq_offset = off; - return off; } -- 2.25.1