Message ID | 20200601174034.017831101@linuxfoundation.org |
---|---|
State | New |
Headers | show
Return-Path: <SRS0=Ycwd=7O=vger.kernel.org=stable-owner@kernel.org> 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=-6.8 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham 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 774F8C433E0 for <stable@archiver.kernel.org>; Mon, 1 Jun 2020 18:05:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 52D5321556 for <stable@archiver.kernel.org>; Mon, 1 Jun 2020 18:05:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034744; bh=hr+aE4vMyCm2J9i/HYfT1scmVwkjoweSmSyJiGUBJ00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=FfbSu8+DVQ6covw1GJxKVu6QvnCgh8aA3036Xo7KHieHNkGRldkIJy96eokIesxku C7S9H6y+swapcVgbmUl3ev8VxpkFjOQfiJEfxJoOFfWY92tUbYc7ZgyBbl7aXCP6+Q IPiI3AgtonA+PIMBEWy3qoQBHqRgFKJfu6bkTHkA= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730357AbgFASFm (ORCPT <rfc822;stable@archiver.kernel.org>); Mon, 1 Jun 2020 14:05:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50878 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730351AbgFASFm (ORCPT <rfc822;stable@vger.kernel.org>); Mon, 1 Jun 2020 14:05:42 -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 9D6752068D; Mon, 1 Jun 2020 18:05:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591034741; bh=hr+aE4vMyCm2J9i/HYfT1scmVwkjoweSmSyJiGUBJ00=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=d7jI2olt2d1nEn24HmbQerIt28JviB1G0O5DhcNe4LGOIgn1PInkKGdAKCKqeYyJO tE1TPylVbQJd1OPWweuAnx2q1FJfVEyL7epe9IwAy+svlxCzrVhbL2aWXjrFCV8gLN vgWlLfKbUD0RL4IWjW2wYQ8AGrzldm6ioKh0z2GI= From: Greg Kroah-Hartman <gregkh@linuxfoundation.org> To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, stable@vger.kernel.org, =?utf-8?q?Minh_B=C3=B9i_Quang?= <minhquangbui99@gmail.com>, =?utf-8?b?QmrDtnJuIFTDtnBlbA==?= <bjorn.topel@intel.com>, Daniel Borkmann <daniel@iogearbox.net>, Jonathan Lemon <jonathan.lemon@gmail.com> Subject: [PATCH 4.19 89/95] xsk: Add overflow check for u64 division, stored into u32 Date: Mon, 1 Jun 2020 19:54:29 +0200 Message-Id: <20200601174034.017831101@linuxfoundation.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200601174020.759151073@linuxfoundation.org> References: <20200601174020.759151073@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: <stable.vger.kernel.org> X-Mailing-List: stable@vger.kernel.org |
Series |
None
|
expand
|
--- a/net/xdp/xdp_umem.c +++ b/net/xdp/xdp_umem.c @@ -258,8 +258,8 @@ static int xdp_umem_account_pages(struct static int xdp_umem_reg(struct xdp_umem *umem, struct xdp_umem_reg *mr) { u32 chunk_size = mr->chunk_size, headroom = mr->headroom; + u64 npgs, addr = mr->addr, size = mr->len; unsigned int chunks, chunks_per_page; - u64 addr = mr->addr, size = mr->len; int err, i; if (chunk_size < XDP_UMEM_MIN_CHUNK_SIZE || chunk_size > PAGE_SIZE) { @@ -285,6 +285,10 @@ static int xdp_umem_reg(struct xdp_umem if ((addr + size) < addr) return -EINVAL; + npgs = div_u64(size, PAGE_SIZE); + if (npgs > U32_MAX) + return -EINVAL; + chunks = (unsigned int)div_u64(size, chunk_size); if (chunks == 0) return -EINVAL; @@ -303,7 +307,7 @@ static int xdp_umem_reg(struct xdp_umem umem->props.size = size; umem->headroom = headroom; umem->chunk_size_nohr = chunk_size - headroom; - umem->npgs = size / PAGE_SIZE; + umem->npgs = (u32)npgs; umem->pgs = NULL; umem->user = NULL; INIT_LIST_HEAD(&umem->xsk_list);