Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp330678pxj; Tue, 18 May 2021 04:31:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyVSvtRZ2J9bROOSA2Xdt/1OiDfE7cnV1BpIX2+Vg2q+F2fDYuV3VjTMLx4zixPKSE0bXp X-Received: by 2002:a05:6602:164c:: with SMTP id y12mr3847943iow.78.1621337472825; Tue, 18 May 2021 04:31:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621337472; cv=none; d=google.com; s=arc-20160816; b=gFnuTHoLw4WYWNHtRU4Oa5PMNgYY8vWmkCQhukiyHOPrQslmjf8hYH2bVS44ULxX6Q n/rMg6v+mz4dslODbLZWsOl1/teJEpOPoerrRkmOLfc4Zvj+4jB6ioNNhCrN/Yynbywt qnLraBPsCnAh5dQhrFpexWVd4W+b9drwJfdz8W6Yunu9ZMhBbBErErn/uVdTnt6OPtac qQoNxnGm3K0E1jPKSSCpBbqdU09qs5yx7i5hH0CwutE52Opjnu69iIOXSDxxTC9Ceqgj o2rglyg/DUanDrpyS2U8YKHQM5QnOMHaNFdhxN/sy3rZkcxB5rYVnmXvBeVU8nqRhwsU KnfQ== 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=JYFWR/C9b1XG7nK2M4Bm6lHhAKZoJgEa1pclERh5Nrg=; b=FWnz8QcSN07EWFcVf/i+p7B3Ni6OMRwfO7JEMYubPAps2tJ36H3PDzcaM2ZIeeZdnF /w5cSsAl1vEuVgFOUWxM/KUUp43dWg7o5W7+pWqgKdQNPnl5xgfuB88Ev8zWl+lj4T1A 6BwEkglepgI/Gp30EPS3FBTk6mP9iaVX1uKEc1jmw6m6oYhrFGebCmYmsuwq7g2O94et 86ufwx21/ACZcj857zOcvZiKvlybEQ18h8UmRdAyJSy5mV4lgOWeLPp1PD1+ykDtYY6C kzmo1p0O7oLcukCXobe92UTewW7PGlfz01bdTb8ccOQjLBFoPLZe8+DNMkufiO9dTxlc E7sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="ajpdME4/"; 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 u15si6628015jam.75.2021.05.18.04.30.58; Tue, 18 May 2021 04:31:12 -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="ajpdME4/"; 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 S244381AbhEQPU0 (ORCPT + 99 others); Mon, 17 May 2021 11:20:26 -0400 Received: from mail.kernel.org ([198.145.29.99]:46480 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243029AbhEQPI3 (ORCPT ); Mon, 17 May 2021 11:08:29 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 47CA561C4D; Mon, 17 May 2021 14:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621261789; bh=adqCZvn3CB5Z8TEYdP3GeIFvHxOWGVZuXz+9duvWo78=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ajpdME4/F1+KkTOMwWYQcWM1tbKbGqkgwHBav9ikOD5D+vCgUUMdJJ+gH5YecKzu2 E+jXdf611AZ8kxmYmrSRWgoM35H+aIBezHbU8vfo624WbVV1ssIzq6hFe33/ifXFC9 yGvoJ3brwPuM0vAxX5g6rgg6EV796lRa+fIID9Uk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, kernel test robot , "Gustavo A. R. Silva" , "David S. Miller" , Sasha Levin Subject: [PATCH 5.10 066/289] flow_dissector: Fix out-of-bounds warning in __skb_flow_bpf_to_target() Date: Mon, 17 May 2021 15:59:51 +0200 Message-Id: <20210517140307.416055945@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: Gustavo A. R. Silva [ Upstream commit 1e3d976dbb23b3fce544752b434bdc32ce64aabc ] Fix the following out-of-bounds warning: net/core/flow_dissector.c:835:3: warning: 'memcpy' offset [33, 48] from the object at 'flow_keys' is out of the bounds of referenced subobject 'ipv6_src' with type '__u32[4]' {aka 'unsigned int[4]'} at offset 16 [-Warray-bounds] The problem is that the original code is trying to copy data into a couple of struct members adjacent to each other in a single call to memcpy(). So, the compiler legitimately complains about it. As these are just a couple of members, fix this by copying each one of them in separate calls to memcpy(). This helps with the ongoing efforts to globally enable -Warray-bounds and get us closer to being able to tighten the FORTIFY_SOURCE routines on memcpy(). Link: https://github.com/KSPP/linux/issues/109 Reported-by: kernel test robot Signed-off-by: Gustavo A. R. Silva Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/core/flow_dissector.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/net/core/flow_dissector.c b/net/core/flow_dissector.c index d48b37b15b27..c52e5ea654e9 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -822,8 +822,10 @@ static void __skb_flow_bpf_to_target(const struct bpf_flow_keys *flow_keys, key_addrs = skb_flow_dissector_target(flow_dissector, FLOW_DISSECTOR_KEY_IPV6_ADDRS, target_container); - memcpy(&key_addrs->v6addrs, &flow_keys->ipv6_src, - sizeof(key_addrs->v6addrs)); + memcpy(&key_addrs->v6addrs.src, &flow_keys->ipv6_src, + sizeof(key_addrs->v6addrs.src)); + memcpy(&key_addrs->v6addrs.dst, &flow_keys->ipv6_dst, + sizeof(key_addrs->v6addrs.dst)); key_control->addr_type = FLOW_DISSECTOR_KEY_IPV6_ADDRS; } -- 2.30.2