diff mbox series

[net] rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation

Message ID 20240502155751.75705-1-rzats@paloaltonetworks.com (mailing list archive)
State Accepted
Commit 1aec77b2bb2ed1db0f5efc61c4c1ca3813307489
Delegated to: Netdev Maintainers
Headers show
Series [net] rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation | expand

Checks

Context Check Description
netdev/series_format success Single patches do not need cover letters
netdev/tree_selection success Clearly marked for net
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag present in non-next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 928 this patch: 928
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 4 of 6 maintainers
netdev/build_clang success Errors and warnings before: 938 this patch: 938
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 939 this patch: 939
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 8 lines checked
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 6 this patch: 6
netdev/source_inline success Was 0 now: 0
netdev/contest success net-next-2024-05-03--15-00 (tests: 1001)

Commit Message

Roded Zats May 2, 2024, 3:57 p.m. UTC
Each attribute inside a nested IFLA_VF_VLAN_LIST is assumed to be a
struct ifla_vf_vlan_info so the size of such attribute needs to be at least
of sizeof(struct ifla_vf_vlan_info) which is 14 bytes.
The current size validation in do_setvfinfo is against NLA_HDRLEN (4 bytes)
which is less than sizeof(struct ifla_vf_vlan_info) so this validation
is not enough and a too small attribute might be cast to a
struct ifla_vf_vlan_info, this might result in an out of bands
read access when accessing the saved (casted) entry in ivvl.

Fixes: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")
Signed-off-by: Roded Zats <rzats@paloaltonetworks.com>
---
 net/core/rtnetlink.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Donald Hunter May 3, 2024, 10:06 a.m. UTC | #1
Roded Zats <rzats@paloaltonetworks.com> writes:

> Each attribute inside a nested IFLA_VF_VLAN_LIST is assumed to be a
> struct ifla_vf_vlan_info so the size of such attribute needs to be at least
> of sizeof(struct ifla_vf_vlan_info) which is 14 bytes.
> The current size validation in do_setvfinfo is against NLA_HDRLEN (4 bytes)
> which is less than sizeof(struct ifla_vf_vlan_info) so this validation
> is not enough and a too small attribute might be cast to a
> struct ifla_vf_vlan_info, this might result in an out of bands
> read access when accessing the saved (casted) entry in ivvl.
>
> Fixes: 79aab093a0b5 ("net: Update API for VF vlan protocol 802.1ad support")
> Signed-off-by: Roded Zats <rzats@paloaltonetworks.com>

Reviewed-by: Donald Hunter <donald.hunter@gmail.com>
patchwork-bot+netdevbpf@kernel.org May 3, 2024, 11:10 p.m. UTC | #2
Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  2 May 2024 18:57:51 +0300 you wrote:
> Each attribute inside a nested IFLA_VF_VLAN_LIST is assumed to be a
> struct ifla_vf_vlan_info so the size of such attribute needs to be at least
> of sizeof(struct ifla_vf_vlan_info) which is 14 bytes.
> The current size validation in do_setvfinfo is against NLA_HDRLEN (4 bytes)
> which is less than sizeof(struct ifla_vf_vlan_info) so this validation
> is not enough and a too small attribute might be cast to a
> struct ifla_vf_vlan_info, this might result in an out of bands
> read access when accessing the saved (casted) entry in ivvl.
> 
> [...]

Here is the summary with links:
  - [net] rtnetlink: Correct nested IFLA_VF_VLAN_LIST attribute validation
    https://git.kernel.org/netdev/net/c/1aec77b2bb2e

You are awesome, thank you!
diff mbox series

Patch

diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index a3d7847ce69d..8ba6a4e4be26 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2530,7 +2530,7 @@  static int do_setvfinfo(struct net_device *dev, struct nlattr **tb)
 
 		nla_for_each_nested(attr, tb[IFLA_VF_VLAN_LIST], rem) {
 			if (nla_type(attr) != IFLA_VF_VLAN_INFO ||
-			    nla_len(attr) < NLA_HDRLEN) {
+			    nla_len(attr) < sizeof(struct ifla_vf_vlan_info)) {
 				return -EINVAL;
 			}
 			if (len >= MAX_VLAN_LIST_LEN)