Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp6565321pxv; Thu, 29 Jul 2021 18:40:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz92mGY1pzXXl5ODWG4Z9d/i63C0f4nhdPOwPOmLwWTd1HbsY1aw4BQfoW/M48UCq62tZuF X-Received: by 2002:a17:906:74c1:: with SMTP id z1mr244093ejl.466.1627609244617; Thu, 29 Jul 2021 18:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1627609244; cv=none; d=google.com; s=arc-20160816; b=kICwjZA8pwiRf/gW0bhf+ezqoN21jwXCCKeA7xUThQ+LvPfORPWUADIKu7i5YsiXor VwG2ui4Ya7wKpgir2gYAT2dvBlFbPBL/SIxCap8I3IUGk1OCnzfLGX+f8uV3szQHdY6j 9km77VJhha8Qy6+hhH/aFiWmo/efKByA1OmtkJtxe/2ER+VO2b6JiyFz8QopPUPH+fOi DN93NWLIHZ5KFvFxqv59zK41MKvIl5KXd61KZzxkpk3zL3WNFNcTSmBHWYRt/sWNkdPn RJysNrGrJXyqfWBC6VuoDZPOVEeszARh9Hr0GB2l8SV5AotON/WVYJuu4MqKchhy7O1R EPpw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=vPAHzrcSpfKuQzB1lrV/ttkpcnRRhB/aWzazYKPR4LA=; b=k1N0nVLRdhuJcqDkoxevoq8IWOOhMBnfD/Cf7eH3eMwn+LHPyHJx9u9boz9gBO9zfo pEEPaGKucbNJKaNi1fLFMchNTiE5Rh3XAN2qLB+ieRChstexs1Kg/PLNSLqN5B+G5vnh CRvei0Occ2AwGQSdiDPbioA30tVirv7pjOxtJRP6JLayWit95sPq0voolzqFnq5s1CDc QlbulKOxBKrMi6HIRb7CaG/C/0IO2buT5ItPamsNne7zhhRdY2oTdKBl7QM2TSDJkGMn Ji2AzWxY6KIQETcFG/TURXJS5l9ohxyd63eAitENGRW33fIl5hkfjWa4M3rrTwjvHXrW ziJA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=Nkis4e81; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q25si162777ejn.362.2021.07.29.18.40.07; Thu, 29 Jul 2021 18:40:44 -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=@chromium.org header.s=google header.b=Nkis4e81; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234742AbhG3Bja (ORCPT + 99 others); Thu, 29 Jul 2021 21:39:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52098 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234495AbhG3Bj3 (ORCPT ); Thu, 29 Jul 2021 21:39:29 -0400 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ABB07C0613D5 for ; Thu, 29 Jul 2021 18:39:24 -0700 (PDT) Received: by mail-pj1-x1032.google.com with SMTP id pf12-20020a17090b1d8cb0290175c085e7a5so18478236pjb.0 for ; Thu, 29 Jul 2021 18:39:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=vPAHzrcSpfKuQzB1lrV/ttkpcnRRhB/aWzazYKPR4LA=; b=Nkis4e8105uAbCge9aO+StXNkXelrJqOpF7xNsIBtcoe+D0iGfGrhXWOijeKDfFQS8 tcGIefv5L6ODB7FGlHuoK3nhQNiRzvNAcTkGvlhjpZKPls5MD5zfBf1pJ7Ll8rA8iZ5f LTaEoFLk38qAHkDnPefiooUaNHcHv32+03LBo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=vPAHzrcSpfKuQzB1lrV/ttkpcnRRhB/aWzazYKPR4LA=; b=kHZJJnAqkuM3pMtHqqWgOg4L53cp3DSoNZT0QFgIH4y0Edvc7yNVlneJbXPKCZm7/s eH6Ol0V8UGyGIynvdyej59KG4w+Dqvb3uAZ1KWsV5BLVYANmf336AyiLGgRe81gKJbtx 2JgkmKVdEOaUHS0i5QSrozMvTnQIQy8ayxSUuBjx2d3+YfpUdF06vuAUQB5hjbTt3JgL YeiyPX4w4Kb/+ea64GsLl7xwXZw7XmafIseMbadrui/aO1YE3jMTNX0BFplrOD3hHws+ UKqwBue/oYBq3gwvnfv31uINnTlgVqSgUtg6WRN+nSUqTYHmIM3qUGdDVQWClQwjxJZW uTpw== X-Gm-Message-State: AOAM533vRXYxljBCkaxAw/iM7cW0h/Bm/k73uLO/YZ4j/1b15CveBWXO ZyE9Iabpv2lR4ioMCpy3RARd0Q== X-Received: by 2002:a63:1053:: with SMTP id 19mr5768pgq.395.1627609164105; Thu, 29 Jul 2021 18:39:24 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id z5sm97349pgz.77.2021.07.29.18.39.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 29 Jul 2021 18:39:23 -0700 (PDT) Date: Thu, 29 Jul 2021 18:39:22 -0700 From: Kees Cook To: Rasmus Villemoes Cc: Greg Kroah-Hartman , 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 Subject: Re: [PATCH 62/64] netlink: Avoid false-positive memcpy() warning Message-ID: <202107291838.25D1F118C@keescook> References: <20210727205855.411487-1-keescook@chromium.org> <20210727205855.411487-63-keescook@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Wed, Jul 28, 2021 at 01:24:01PM +0200, Rasmus Villemoes wrote: > 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. Ah, good call. I've adjusted this and added a comment. Thanks! -Kees -- Kees Cook