From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7314FC43216 for ; Wed, 28 Jul 2021 05:49:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A9BB60F00 for ; Wed, 28 Jul 2021 05:49:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234334AbhG1Ftv (ORCPT ); Wed, 28 Jul 2021 01:49:51 -0400 Received: from mail.kernel.org ([198.145.29.99]:50802 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229814AbhG1Ftt (ORCPT ); Wed, 28 Jul 2021 01:49:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AAED60F00; Wed, 28 Jul 2021 05:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627451388; bh=Uj+QHLYAZir2Mxo6cu76dwsKyC/KhFwLcw7JJiMlAdM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xXqgpI3gRWbEy8rq81hxDjfK+j0CJIwxB4I/Ae+KVbzLUN+qdK/pkNEczVCdkC1CB fCtfqsbsZlEcEq2hviBrmXL0uuu3qCrtSJHnbcmW2vDKkOM3HbDWqFcTxWgnkWe11v 7rqUxCHJeMJoMg8dvgFXbVdy0U19thX2bW8vYx0g= Date: Wed, 28 Jul 2021 07:49:46 +0200 From: Greg Kroah-Hartman To: 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 Subject: Re: [PATCH 62/64] netlink: Avoid false-positive memcpy() warning Message-ID: 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: <20210727205855.411487-63-keescook@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? Nothing breaks? thanks, greg k-h From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DFAB5C4338F for ; Wed, 28 Jul 2021 05:49:51 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9B6E860F00 for ; Wed, 28 Jul 2021 05:49:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9B6E860F00 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 25DB36ECA4; Wed, 28 Jul 2021 05:49:51 +0000 (UTC) Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3E42A6ECA1 for ; Wed, 28 Jul 2021 05:49:49 +0000 (UTC) Received: by mail.kernel.org (Postfix) with ESMTPSA id 1AAED60F00; Wed, 28 Jul 2021 05:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1627451388; bh=Uj+QHLYAZir2Mxo6cu76dwsKyC/KhFwLcw7JJiMlAdM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=xXqgpI3gRWbEy8rq81hxDjfK+j0CJIwxB4I/Ae+KVbzLUN+qdK/pkNEczVCdkC1CB fCtfqsbsZlEcEq2hviBrmXL0uuu3qCrtSJHnbcmW2vDKkOM3HbDWqFcTxWgnkWe11v 7rqUxCHJeMJoMg8dvgFXbVdy0U19thX2bW8vYx0g= Date: Wed, 28 Jul 2021 07:49:46 +0200 From: Greg Kroah-Hartman To: Kees Cook Subject: Re: [PATCH 62/64] netlink: Avoid false-positive memcpy() warning Message-ID: 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: <20210727205855.411487-63-keescook@chromium.org> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kbuild@vger.kernel.org, netdev@vger.kernel.org, linux-staging@lists.linux.dev, linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, "Gustavo A. R. Silva" , linux-block@vger.kernel.org, clang-built-linux@googlegroups.com, Keith Packard , linux-hardening@vger.kernel.org, Andrew Morton Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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? Nothing breaks? thanks, greg k-h