Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3080729pxj; Mon, 17 May 2021 17:16:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx/0Ho1BhtJrMtnGBtLf+c8g+h3wMAFPVg9ZLuO2K535WJovsfTmGOKJClW8t/4gTcmKcrj X-Received: by 2002:a50:a446:: with SMTP id v6mr3442376edb.254.1621296999698; Mon, 17 May 2021 17:16:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621296999; cv=none; d=google.com; s=arc-20160816; b=GbIH1j+pcov4xFjGouZiz2U4DhfOPt+dtgB4juSjd2XiGtLAfJcwDErCIi8ZPRoikL TkNyLgiNfnKk9vFMTE9PrFIkwr/rWMk/p8HrQcsIHNlUXJ/x0ioR+2PIm+lr3TJx0WLD K/YtH1P2AbYIJUPGzu0MG6L9IdzozCGM00HCqlBTkwL4GM3OABPmPJdJrJHeggDNKSrw QCBXa/sBrgfBTcNDQHfavH1epkSLphEVMOPudlZhQZjqnJbesvpajJ/5BqxwDdy9cYDN vmlpDLWgOlQbYuoLP5W5+BqyKLZRTSUOStG/URA0tCzLyY6Zl5b/tmzWJZHD/CKBwESh 2BxQ== 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=5XzXsAVsO64PKuxFon3AcwgRpoSnaMRaORylUUJqBQk=; b=oadQZ+1duLpicjRV8IxfYTwLp6GSeKo7zhvCY4VCRu7LMTm6KyVrL8zkP7YoRVmxbZ 9gmE+3dx7Bfs8dlDLUWd8BwfO23l4B8VBzRwtVFYSAmveqal5E6/G0zbBBAXbjz1aFDA NI5v0E0O5V6/q9imX4/oKRh+1hVtvociU7LGtCmYC+6fSkRKBYcw8CKrkGtWeSRhA+sZ y5L8aGOpEp2RGuqHmbZdCHlgRwbJTNe6x+8uSo/hLmQNMt6P1heOTdF3UZ/casUq079Q yBklxwiiXzb7SRY7ViZKJIP1fJ3629MC1SNMw3gJ6zVn+ZkZZvq09zoYvomiKXBeujUT 53yA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=pA9Am9EL; 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 jj13si808303ejc.177.2021.05.17.17.16.00; Mon, 17 May 2021 17:16:39 -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=pA9Am9EL; 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 S238377AbhEQO0Q (ORCPT + 99 others); Mon, 17 May 2021 10:26:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:36020 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239232AbhEQOW1 (ORCPT ); Mon, 17 May 2021 10:22:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 400EF6145D; Mon, 17 May 2021 14:12:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260723; bh=Jr74mpcAFGs90GVsKiJjiazXqFTEMwCXJ3RvrPOOb8o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pA9Am9ELzaUQ3spJaHQc2WuxofPxSmoUIIi5kazAgWc9bmZnW0hz0JoIV+qzNv+Dr ZfnTLd1hPDXFoNqMX/AterOaBkfXOGLxt8H8ooVVEq8edUW2sNNerAkiAc2n9Lh9h5 95YhdPFC+EK2TacCwnMiCSAExDsVgejbrGJgyNfI= 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.12 210/363] xsk: Fix for xp_aligned_validate_desc() when len == chunk_size Date: Mon, 17 May 2021 16:01:16 +0200 Message-Id: <20210517140309.680699318@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210517140302.508966430@linuxfoundation.org> References: <20210517140302.508966430@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 2823b7c3302d..40f359bf2044 100644 --- a/net/xdp/xsk_queue.h +++ b/net/xdp/xsk_queue.h @@ -128,13 +128,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