Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp5147179pxv; Wed, 28 Jul 2021 04:24:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwWTn1DtafyoTm5eUyTposo6PSjRJu17VqnNVitC2Hf0B02Fv4/T2r6Vm/TfwJK7BNHhjA4 X-Received: by 2002:a05:6638:41a7:: with SMTP id az39mr25914558jab.52.1627471485770; Wed, 28 Jul 2021 04:24:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627471485; cv=none; d=google.com; s=arc-20160816; b=qxvPdG5zIackRluyQU92jg5Upz88HQy64n6XtK5MT0tw2yZw6oR0kviOdNVxbzSLAu b5k94kYnB0wPO7pFiWfqaSbG84NZFU1X329cvDSGQ06Ix3y7CDKC5zteDVGiLqQs57jy 2dTRdkjNG6jzTRcbVTc+q6ugx8n4gT6Qp1lns6yRVoWSpkKdEBbbMceLo2xIrPkXt0f0 +XaCXIvkghrCXOoeDDs1z/WngmpqbV8/6kGzb/2K5oTmYcBMYz0NvRnL6ewxtXKUgyZz JKCGsBCF6WaPD1TBO3WnD3Ozs+6O0tXqpTwpmyB3Oe63FJRr4dcV6ewQF7sbwgRMqa+w PTpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Wg+3/RRWhlXAdTdGrz6ZDOoqwDjAalfDgSMGfZRFy7c=; b=FwjnS+e3ZrCJrwxOkSOU5sokKRdqxEZwCqn6xHPm0pekiLRHQuZP/pQs838Ju0K3eC g4XCeQ/BxsaNwkxvIemLZb70HFhsQNux78bqEtnRcJQsnqLRzJyuPmSxFHbEvsGb4qNu hHCcx4upOMdVkrwyLU1SHLxrH/r5+cBb3EabHnbFvf7eREXnBNbUlLTsY+DNXhmuEOuS i8D7nUn8Q5xdU7aAqGLA/TaU2BdYOYw7LiuNxZvkGS9CWoosgbjZr3jUToNekDsgUVO6 IkqV6fDXRuoFu7nnS43olPpaTFN0F3QA/U1Cfb0/u1PirU4mNVKqjgxrw9HDIkPTMmgs /T8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rasmusvillemoes.dk header.s=google header.b=MqB2oQJr; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l8si3950863jaj.66.2021.07.28.04.24.33; Wed, 28 Jul 2021 04:24:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@rasmusvillemoes.dk header.s=google header.b=MqB2oQJr; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235217AbhG1LYH (ORCPT + 99 others); Wed, 28 Jul 2021 07:24:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52498 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234639AbhG1LYG (ORCPT ); Wed, 28 Jul 2021 07:24:06 -0400 Received: from mail-lj1-x22f.google.com (mail-lj1-x22f.google.com [IPv6:2a00:1450:4864:20::22f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4CC4C061765 for ; Wed, 28 Jul 2021 04:24:04 -0700 (PDT) Received: by mail-lj1-x22f.google.com with SMTP id n6so2619786ljp.9 for ; Wed, 28 Jul 2021 04:24:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Wg+3/RRWhlXAdTdGrz6ZDOoqwDjAalfDgSMGfZRFy7c=; b=MqB2oQJrWErl4M3jysGVniDJ4xARTYUEk892vt+CXTsOghQBHfw+ROqpA+FWeMfNAw 99HiHQl9pgCodpNZVcjBeusKVj1g8kcdEIy/ZsV7LY738G0Iid6EaBW2zhaAmZdiUtKc pOnrw2np1M0KCLNrhvFVpkrx8b6JNzJx5ukHc= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Wg+3/RRWhlXAdTdGrz6ZDOoqwDjAalfDgSMGfZRFy7c=; b=j2T+twXAEdTJl2vpTPS/qvbRHU7q2U6iUhGodxEh33BlOei9LxItDfoL09tkSbPEhI D2e5BVPc3zMHDhRgU9nfvYwyAAT4+tmk9N6eQILtcgsP0Eg13m51Fjv6O154hw58qXGK CmlkXahHLgvgGiKmxPWCwOF9JpYElKSLPliku0I7r31Btb4lNwGsCjiKP/T/2p2lPYOk 2fUse1YmV5eEKMqwcrkVpCvfDph0Sy3lQRCJYJ9DIjEgqklvBHIIrt/C+yfgDocneKy0 51r4u9vIYhngTFMBKnsQjGP+JUPOl7vqdkJ83TiHHn8F6YUHTLCBw62o46eAQ1WMv/bj 0VvQ== X-Gm-Message-State: AOAM533BhnGbQxr4lRBrKBMZNjHx5zna3TyM4cwWj24+2vGtYj6/q+0b 9Tz4Yfk43mBGzkUM+8iPjG5faA== X-Received: by 2002:a05:651c:124f:: with SMTP id h15mr18566268ljh.4.1627471443108; Wed, 28 Jul 2021 04:24:03 -0700 (PDT) Received: from [172.16.11.1] ([81.216.59.226]) by smtp.gmail.com with ESMTPSA id f14sm494569ljj.116.2021.07.28.04.24.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Jul 2021 04:24:02 -0700 (PDT) Subject: Re: [PATCH 62/64] netlink: Avoid false-positive memcpy() warning To: Greg Kroah-Hartman , Kees Cook Cc: linux-hardening@vger.kernel.org, "Gustavo A. R. Silva" , Keith Packard , Andrew Morton , linux-kernel@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-staging@lists.linux.dev, linux-block@vger.kernel.org, linux-kbuild@vger.kernel.org, clang-built-linux@googlegroups.com References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-63-keescook@chromium.org> From: Rasmus Villemoes Message-ID: Date: Wed, 28 Jul 2021 13:24:01 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On 28/07/2021 07.49, Greg Kroah-Hartman wrote: > On Tue, Jul 27, 2021 at 01:58:53PM -0700, Kees Cook wrote: >> In preparation for FORTIFY_SOURCE performing compile-time and run-time >> field bounds checking for memcpy(), memmove(), and memset(), avoid >> intentionally writing across neighboring fields. >> >> Add a flexible array member to mark the end of struct nlmsghdr, and >> split the memcpy() to avoid false positive memcpy() warning: >> >> memcpy: detected field-spanning write (size 32) of single field (size 16) >> >> Signed-off-by: Kees Cook >> --- >> include/uapi/linux/netlink.h | 1 + >> net/netlink/af_netlink.c | 4 +++- >> 2 files changed, 4 insertions(+), 1 deletion(-) >> >> diff --git a/include/uapi/linux/netlink.h b/include/uapi/linux/netlink.h >> index 4c0cde075c27..ddeaa748df5e 100644 >> --- a/include/uapi/linux/netlink.h >> +++ b/include/uapi/linux/netlink.h >> @@ -47,6 +47,7 @@ struct nlmsghdr { >> __u16 nlmsg_flags; /* Additional flags */ >> __u32 nlmsg_seq; /* Sequence number */ >> __u32 nlmsg_pid; /* Sending process port ID */ >> + __u8 contents[]; > > Is this ok to change a public, userspace visable, structure? At least it should keep using a nlmsg_ prefix for consistency and reduce risk of collision with somebody having defined an object-like contents macro. But there's no guarantees in any case, of course. Rasmus