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 4FECC79C9 for ; Thu, 12 Jan 2023 14:23:59 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A8B03C43392; Thu, 12 Jan 2023 14:23:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1673533439; bh=+u3yXhRYEEIDYwXKxfXg/aoqPPZm629v9yinoOjuZtY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WJ+toNkaDSjko7skJ10yDkJOF0akqQ9XXyv5jODtraIgwcLoyP5bsGTpANyA/akwF lLrEpKC6F+wH3lSCW/Qdc4JesordCCKH+NL/WZtChU64a6pdNrCTSb8KeeNizSE5Tb ZJqUDOfqyYEcDrUkf8FDmaTYDdZ5dn2ZRwmTyAZc= 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 5.10 479/783] net_sched: reject TCF_EM_SIMPLE case for complex ematch module Date: Thu, 12 Jan 2023 14:53:15 +0100 Message-Id: <20230112135546.408009439@linuxfoundation.org> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230112135524.143670746@linuxfoundation.org> References: <20230112135524.143670746@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 f885bea5b452..b7154103e9cd 100644 --- a/net/sched/ematch.c +++ b/net/sched/ematch.c @@ -255,6 +255,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