Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp480219pxj; Tue, 18 May 2021 07:39:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwicf6ex5l78Fg28ha91zoA1o7q9HuHImyEZx14TRtf0v1EU/gnE8iqC7GxvsT/Upw/4NXl X-Received: by 2002:a05:6402:10cc:: with SMTP id p12mr7553006edu.328.1621348797828; Tue, 18 May 2021 07:39:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621348797; cv=none; d=google.com; s=arc-20160816; b=QnPx//7G59RWJNixP/bpk05mGi3mObkfZboTBrAkiePdzznVt5HyIzFbXbqk7O9VZu W04Z4kdUAw5PpdbMcdqrWDD0L/Bl7ykdARUiaRfB1K/365WSa8gDGPZom+2ZE45hcrsY v/cHA+mYjdYJNxRFUvNdTE0iNOYA5YWjA+T421BQ20wGKg8RGHjV+YnbTzimZRMUbprD EJzS5byHLjfOUlU3BamlG8JEkJFkTzdWbOe+UaI3MJhyQnm8JESAG+MY7o0Fr8cnb0Oa /XGNYQnUopi2YuuPrarbe//fx0y9JSusGk4DX0c5zkZviIlfNO13k6b2RNvcPA0ya5SH ZSaQ== 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=JoSiWeSM9m3Gk907xVf+AJHUupLJgUxaIAz5dL+xFno=; b=PLBDBFpjuZx6vV/U6haqjYjMo9D5NS7XD8eczt5fqm9nSwFm8f2znot0ITWFWE0YXa Eo/c4hSZ4wIsYlLwHcD3D5H2Wyk7747jNilH4ZoyMSAGmeKlVDOBH/YszS6BgmWyp5o4 3cbkpZ4SFjg4UJHc9yvHlSNOaKnukj5/tZmBPZBzfC+NbZOwVersj2GnlyxLJh8D5a6W MaOQjddFjJHBaWuwVPLS8tJUC3tzN54D6SNxW9Q1sYdvNV+bprnYmZjEbuY+TySFoi1c utbYpe4QUggg2vKvX6xpMPoPg5uh0NAy1d+6uf2eK+aGicqkp6tZwYZHibO5sZlxDqf7 hIPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=t2YPRjCD; 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 b14si5938527ejv.445.2021.05.18.07.39.33; Tue, 18 May 2021 07:39: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=t2YPRjCD; 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 S245662AbhEQPtK (ORCPT + 99 others); Mon, 17 May 2021 11:49:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:55330 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245008AbhEQPcl (ORCPT ); Mon, 17 May 2021 11:32:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 501DA61CCA; Mon, 17 May 2021 14:38:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621262319; bh=FYzr0IcFNdDk9NQ7sALdLPdfdYnKdbc2Uo8cSAUB5hU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=t2YPRjCD2Qpc/FtmPBah0Oi0R88LV7L3rSlgDZ+9mnwYIregitX5UfQb/k9vu6MHX 9vbnIvrP0CBfzp6WSW/CzIUAVLx1ooBjWJYFDy7vEQN98qXdGJq8r6ITylAx7YAUBY ijloVZhLHXZXOId3HgxcGVC9HQQaGj2aA5DTS5II= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Xuan Zhuo , Daniel Borkmann , Magnus Karlsson , Sasha Levin Subject: [PATCH 5.10 160/289] xsk: Fix for xp_aligned_validate_desc() when len == chunk_size Date: Mon, 17 May 2021 16:01:25 +0200 Message-Id: <20210517140310.512875721@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140305.140529752@linuxfoundation.org> References: <20210517140305.140529752@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: Xuan Zhuo [ Upstream commit ac31565c21937eee9117e43c9cd34f557f6f1cb8 ] When desc->len is equal to chunk_size, it is legal. But when the xp_aligned_validate_desc() got chunk_end from desc->addr + desc->len pointing to the next chunk during the check, it caused the check to fail. This problem was first introduced in bbff2f321a86 ("xsk: new descriptor addressing scheme"). Later in 2b43470add8c ("xsk: Introduce AF_XDP buffer allocation API") this piece of code was moved into the new function called xp_aligned_validate_desc(). This function was then moved into xsk_queue.h via 26062b185eee ("xsk: Explicitly inline functions and move definitions"). Fixes: bbff2f321a86 ("xsk: new descriptor addressing scheme") Signed-off-by: Xuan Zhuo Signed-off-by: Daniel Borkmann Acked-by: Magnus Karlsson Link: https://lore.kernel.org/bpf/20210428094424.54435-1-xuanzhuo@linux.alibaba.com Signed-off-by: Sasha Levin --- net/xdp/xsk_queue.h | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/net/xdp/xsk_queue.h b/net/xdp/xsk_queue.h index ef6de0fb4e31..be9fd5a72011 100644 --- a/net/xdp/xsk_queue.h +++ b/net/xdp/xsk_queue.h @@ -126,13 +126,12 @@ static inline bool xskq_cons_read_addr_unchecked(struct xsk_queue *q, u64 *addr) static inline bool xp_aligned_validate_desc(struct xsk_buff_pool *pool, struct xdp_desc *desc) { - u64 chunk, chunk_end; + u64 chunk; - chunk = xp_aligned_extract_addr(pool, desc->addr); - chunk_end = xp_aligned_extract_addr(pool, desc->addr + desc->len); - if (chunk != chunk_end) + if (desc->len > pool->chunk_size) return false; + chunk = xp_aligned_extract_addr(pool, desc->addr); if (chunk >= pool->addrs_cnt) return false; -- 2.30.2