From patchwork Tue May 26 18:52:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 225235 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D46F5C433E1 for ; Tue, 26 May 2020 19:28:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AB0C420776 for ; Tue, 26 May 2020 19:28:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590521310; bh=2LUm7Ij2gIyRjTkio4BUtMbWDnxu6JhIsryrUp6uBq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=ldAr0miEhaCeYahz0M+bNv6b+p+KTUnWRO+15TqOxWO4V/71HaHcUYjPbJfgaySGD Qs3dvCPDaMSgmbnU1Zbx61pmrdICWRyWs2fidb3OUSFBYQAN6fjNVNFXqB653KocvO XiwLiRCT1zMQ9HiccR3Wdbl7W5eij7l0m6TgqcNQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392475AbgEZT20 (ORCPT ); Tue, 26 May 2020 15:28:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:58314 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2390609AbgEZTDK (ORCPT ); Tue, 26 May 2020 15:03:10 -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 597752086A; Tue, 26 May 2020 19:03:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1590519789; bh=2LUm7Ij2gIyRjTkio4BUtMbWDnxu6JhIsryrUp6uBq0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=yvqqdD7Drxa+iY23g2JsN7DNI+qsQBjxY2MqXpmfVAvM9VcSu8wSBdZNFXbYO3NhJ sIH10v9IVJSm1XMPYol7zlWqlXZ3olHghT6kQ10RzRNvsXhP9qeIcLEWrXPLabidmq lL9WblLGTfteVnCWN/S9+Bay0CjZWpUBW9nKUrJk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Thiago Macieira , Al Viro , Sasha Levin , stable@kernel.org Subject: [PATCH 4.19 10/81] fix multiplication overflow in copy_fdtable() Date: Tue, 26 May 2020 20:52:45 +0200 Message-Id: <20200526183926.518841230@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200526183923.108515292@linuxfoundation.org> References: <20200526183923.108515292@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Al Viro [ Upstream commit 4e89b7210403fa4a8acafe7c602b6212b7af6c3b ] cpy and set really should be size_t; we won't get an overflow on that, since sysctl_nr_open can't be set above ~(size_t)0 / sizeof(void *), so nr that would've managed to overflow size_t on that multiplication won't get anywhere near copy_fdtable() - we'll fail with EMFILE before that. Cc: stable@kernel.org # v2.6.25+ Fixes: 9cfe015aa424 (get rid of NR_OPEN and introduce a sysctl_nr_open) Reported-by: Thiago Macieira Signed-off-by: Al Viro Signed-off-by: Sasha Levin --- fs/file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/file.c b/fs/file.c index 780d29e58847..3762a3f136fd 100644 --- a/fs/file.c +++ b/fs/file.c @@ -70,7 +70,7 @@ static void copy_fd_bitmaps(struct fdtable *nfdt, struct fdtable *ofdt, */ static void copy_fdtable(struct fdtable *nfdt, struct fdtable *ofdt) { - unsigned int cpy, set; + size_t cpy, set; BUG_ON(nfdt->max_fds < ofdt->max_fds);