Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3006031pxj; Mon, 17 May 2021 15:23:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwj1iOTKZL1YVHNbWbUtY65NO2q5el56R1ZnqMdkn09ZKIO6SDd/NG2NXJ2nldLTatfK9n8 X-Received: by 2002:a17:906:3bca:: with SMTP id v10mr2208750ejf.121.1621290232759; Mon, 17 May 2021 15:23:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621290232; cv=none; d=google.com; s=arc-20160816; b=M2Zz60bp8t5tla7Oat8JDyBNwkMeZCBZS1Bj6SYpXCCpI8rMdPFvF1yvd7ugGHugEX p5kLu+PQPc8u+n+dheoAbvu/5R7AEIlKd7SeBjkbhojeEI3aw/ieODu2iM0k8yKZGiLy 8V1KSPPm5qHCd6XpZ8ubcAy+XudVfZxV3Eab5D8EiEJ/3A9pRyhSkj+/zQxec3fDJjkA 2rsvdMCJqMkSZRFsDjNCAjJBfKKQ5rzIZ0ROXxNovIr1B9mUCJ8GheFwVQxftCevjrt4 YXN36mzqXjpJDZFqrXQS3U3aHILHABkfHe12zcqDzlGIiXhy89wf3le0eA5NWgWwljse pV8g== 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=wwNVii+ZNyj188caQ5tnCoCK4KCnhhYlmUjEzgL+HBM=; b=rPGVELgOMUxSjayvpjlv/hkeiXfCQG43SoDDizlRsZlMmx3sp4Ie9l0g9w8m/L0+0p PIR2BGvF07eeQBVY7HkdnY/mXHTm4FyD9iaSFYVtT73m/tYFupb6XEK8P+nRz3Razm+5 EcNlWaA5VFjuCdV9KR7KRFaCm31uyyYEvY9vhCPkXgWHjt6INs1i2D0sG1TRWts+ucVL Mwnr/gN8jGlmQbm/B7cwMtsYnESiiEX7tLARzt6YQK4qRztLhWNkeoAJZUOMXs+a6CPa MuiB7YFE5SIrx7/u8Q6ndFcriQ0bYIOtaUob+ApqVRTY9k9gxFCkfjJEB7kRuWzGrcII anIQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=FTDh1kOz; 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 g14si7190737edv.301.2021.05.17.15.23.29; Mon, 17 May 2021 15:23:52 -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=FTDh1kOz; 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 S238615AbhEQON3 (ORCPT + 99 others); Mon, 17 May 2021 10:13:29 -0400 Received: from mail.kernel.org ([198.145.29.99]:59820 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238605AbhEQOLY (ORCPT ); Mon, 17 May 2021 10:11:24 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 88789613C5; Mon, 17 May 2021 14:07:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1621260463; bh=lcZIRNgJsFuH/pUy5vo/SVQpCr855oGUmw48fpCQeQo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FTDh1kOz+DG3ml4aaPQ7v22uBv63vuF/4GMCIP/0adgAor/NXvgyTEtNWYyK+CyeR RCZ/vuM1S8pULCnoxLxVHb9EtjasRJCRknAKx6sVHcC2YaRX2p5NXsGKWltpOB+etf y6C3Ldg6avIC8xN7SBEX5Um+RkIfAbZijTN8BUpM= 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.12 092/363] flow_dissector: Fix out-of-bounds warning in __skb_flow_bpf_to_target() Date: Mon, 17 May 2021 15:59:18 +0200 Message-Id: <20210517140305.703871300@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: 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 a96a4f5de0ce..3f36b04d86a0 100644 --- a/net/core/flow_dissector.c +++ b/net/core/flow_dissector.c @@ -828,8 +828,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