Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp3426597pxf; Mon, 29 Mar 2021 01:45:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwdAl0+05GCVVNT41PNOaLwZ4WbP+hhlrOjywKLGAaGFvY6GhTzQsH4i5tLs/eSbVM6i221 X-Received: by 2002:a17:906:4f02:: with SMTP id t2mr26982303eju.121.1617007557857; Mon, 29 Mar 2021 01:45:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617007557; cv=none; d=google.com; s=arc-20160816; b=d6Cgx+522ag3yUvZ8hVHVHGZ7OrA1jPiHZwMmxQk/bWSHPSrpJX/4iUhcPQ3uYpYnx Wnth8x8S3J6L5cXnB4laR/LHFheJ0FFrJpfE7nSY3OegM0fDXYW+ySknN2ZzrjDEORX8 SIyCsOKnc2EnUdVZ0U9xNBKjnmoeOCuICkIdg0vWxD8ajwzEkdpGVr81TsA9ASoF0es1 Q1ViCLY1QDiRGuJr8gKB9uZoPV+/RRBorKt6fyxFp3MbKu5mukK+RadtV9/uOevgJNyo xblcR3T2AXyoDmnKKVpH48KOGq5cgVJzKxnnv/vgI6UkynQHKPa+7iAvK1/IuvKJNS5O hnGg== 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=j0Ta2gLnXQmPuWHQMXx3VrliAwDMzGIaLvPBBck2Yrs=; b=Cxf0GwT3IPrYGY1RCu3Wpv5+g02df6ixl7SqVbQu7egI1tCfiFGz/iCYkZD193aoKZ AbEaqGNBITeCE/M8NRh7jDMzasWf77Ea0Z3Vx2j0ByxxqgbrwSxBP3bSqUeNm5Pplvyv 0Ft4Ddni0cw6JQdYa22omSSfyjiM/8iXJKj5FSK2akkR7hb3tECuDQ2LaxxoTFSsboPL 6wRAzFoieQ+VComIY+lypl0u5WLzI6oz4meFxteq9oAAfSRLw+XYAQOQoJtEWFZYl1Vo 7AgrVDAbz5ZBE/7G7ubeFpbfqlTo0u1UETieGqCsnNAKpC71gqqkePbnxqpbZynFQp6w 9TXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JIoNnZNr; 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=pass (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 a23si12818783eje.83.2021.03.29.01.45.34; Mon, 29 Mar 2021 01:45:57 -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=@linuxfoundation.org header.s=korg header.b=JIoNnZNr; 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=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235120AbhC2IoA (ORCPT + 99 others); Mon, 29 Mar 2021 04:44:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42698 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233682AbhC2IZ4 (ORCPT ); Mon, 29 Mar 2021 04:25:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1EAF8619BB; Mon, 29 Mar 2021 08:25:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1617006326; bh=mHF8+Ki1w5Z7pryKIf68rubLDuN40bh2yS1C9XqTdpg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JIoNnZNrQnKEAAKeMFPuOdxzNVrCrl+/Z8/bIus9gCI9XndUi4lQyhPcRTBDGAS+A FDzTDZ6gATnc/wZh0Uvh7pAtamh/6SAE9Z+9oyAg+zRCiPagkN3/JSiwcxNuMNQLcl TL7MZ+rTo6BDUzhBrgxv6CKwAT3NfdWvMBD5+/q0= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Colin Ian King , Pavel Begunkov , Jens Axboe , Sasha Levin Subject: [PATCH 5.10 200/221] io_uring: fix provide_buffers sign extension Date: Mon, 29 Mar 2021 09:58:51 +0200 Message-Id: <20210329075635.803001996@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210329075629.172032742@linuxfoundation.org> References: <20210329075629.172032742@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: Pavel Begunkov [ Upstream commit d81269fecb8ce16eb07efafc9ff5520b2a31c486 ] io_provide_buffers_prep()'s "p->len * p->nbufs" to sign extension problems. Not a huge problem as it's only used for access_ok() and increases the checked length, but better to keep typing right. Reported-by: Colin Ian King Fixes: efe68c1ca8f49 ("io_uring: validate the full range of provided buffers for access") Signed-off-by: Pavel Begunkov Reviewed-by: Colin Ian King Link: https://lore.kernel.org/r/562376a39509e260d8532186a06226e56eb1f594.1616149233.git.asml.silence@gmail.com Signed-off-by: Jens Axboe Signed-off-by: Sasha Levin --- fs/io_uring.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/fs/io_uring.c b/fs/io_uring.c index 06e9c2181995..dde290eb7dd0 100644 --- a/fs/io_uring.c +++ b/fs/io_uring.c @@ -3996,6 +3996,7 @@ static int io_remove_buffers(struct io_kiocb *req, bool force_nonblock, static int io_provide_buffers_prep(struct io_kiocb *req, const struct io_uring_sqe *sqe) { + unsigned long size; struct io_provide_buf *p = &req->pbuf; u64 tmp; @@ -4009,7 +4010,8 @@ static int io_provide_buffers_prep(struct io_kiocb *req, p->addr = READ_ONCE(sqe->addr); p->len = READ_ONCE(sqe->len); - if (!access_ok(u64_to_user_ptr(p->addr), (p->len * p->nbufs))) + size = (unsigned long)p->len * p->nbufs; + if (!access_ok(u64_to_user_ptr(p->addr), size)) return -EFAULT; p->bgid = READ_ONCE(sqe->buf_group); -- 2.30.1