From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 025D76FA0 for ; Mon, 16 Jan 2023 17:10:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A6E9C433D2; Mon, 16 Jan 2023 17:10:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673889050; bh=aZ0JKpZUSDhGF4muQfj/pOfCpHaLsON8A2w+yYEIG1A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HxgL/ByfeaK9D/ar4yf/Ee+JXCit6zufQvYZp1TkXP3eKmAZqfvgoivqUnEuAKhyw Bod+t3kG/C7DM0Sep3NWFDok132IP57Fdd2/lD+GXRqg9cQqj2Xv1tcExdtNgVk9ZG kWztaqaPgcNi797Nak+ewGL3JQLisslKtDbNd3WY= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Jun Nie , Jamal Hadi Salim , Paolo Abeni , Cong Wang , "David S. Miller" , Sasha Levin , syzbot+4caeae4c7103813598ae@syzkaller.appspotmail.com Subject: [PATCH 4.14 212/338] net_sched: reject TCF_EM_SIMPLE case for complex ematch module Date: Mon, 16 Jan 2023 16:51:25 +0100 Message-Id: <20230116154830.266662295@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116154820.689115727@linuxfoundation.org> References: <20230116154820.689115727@linuxfoundation.org> User-Agent: quilt/0.67 Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Cong Wang [ Upstream commit 9cd3fd2054c3b3055163accbf2f31a4426f10317 ] When TCF_EM_SIMPLE was introduced, it is supposed to be convenient for ematch implementation: https://lore.kernel.org/all/20050105110048.GO26856@postel.suug.ch/ "You don't have to, providing a 32bit data chunk without TCF_EM_SIMPLE set will simply result in allocating & copy. It's an optimization, nothing more." So if an ematch module provides ops->datalen that means it wants a complex data structure (saved in its em->data) instead of a simple u32 value. We should simply reject such a combination, otherwise this u32 could be misinterpreted as a pointer. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Reported-and-tested-by: syzbot+4caeae4c7103813598ae@syzkaller.appspotmail.com Reported-by: Jun Nie Cc: Jamal Hadi Salim Cc: Paolo Abeni Signed-off-by: Cong Wang Acked-by: Paolo Abeni Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/sched/ematch.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/net/sched/ematch.c b/net/sched/ematch.c index a48dca26f178..e6078a3da76a 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c @@ -259,6 +259,8 @@ static int tcf_em_validate(struct tcf_proto *tp, * the value carried. */ if (em_hdr->flags & TCF_EM_SIMPLE) { + if (em->ops->datalen > 0) + goto errout; if (data_len < sizeof(u32)) goto errout; em->data = *(u32 *) data; -- 2.35.1