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=-1.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS autolearn=ham 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 79F36C282CB for ; Tue, 5 Feb 2019 19:19:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 57D072083B for ; Tue, 5 Feb 2019 19:19:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729343AbfBETTI (ORCPT ); Tue, 5 Feb 2019 14:19:08 -0500 Received: from smtprelay0162.hostedemail.com ([216.40.44.162]:45867 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726484AbfBETTI (ORCPT ); Tue, 5 Feb 2019 14:19:08 -0500 Received: from filter.hostedemail.com (clb03-v110.bra.tucows.net [216.40.38.60]) by smtprelay06.hostedemail.com (Postfix) with ESMTP id B169318224D9E; Tue, 5 Feb 2019 19:19:06 +0000 (UTC) X-Session-Marker: 6A6F6540706572636865732E636F6D X-HE-Tag: form73_32456d64cd60a X-Filterd-Recvd-Size: 2448 Received: from XPS-9350.home (unknown [47.151.153.53]) (Authenticated sender: joe@perches.com) by omf01.hostedemail.com (Postfix) with ESMTPA; Tue, 5 Feb 2019 19:19:05 +0000 (UTC) Message-ID: <143a8f022c73c71f170eb04dc0b763f9ae83f6b5.camel@perches.com> Subject: Re: [PATCH v2 2/2] r8169: Avoid pointer aliasing From: Joe Perches To: David Miller Cc: thierry.reding@gmail.com, hkallweit1@gmail.com, andrew@lunn.ch, nic_swsd@realtek.com, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Tue, 05 Feb 2019 11:19:04 -0800 In-Reply-To: <20190205.111404.1429981997134153696.davem@davemloft.net> References: <20190204164213.30727-2-thierry.reding@gmail.com> <20190204.192040.1074738183781998611.davem@davemloft.net> <8553086eaec167846992f1cff12aa388cee81767.camel@perches.com> <20190205.111404.1429981997134153696.davem@davemloft.net> Content-Type: text/plain; charset="ISO-8859-1" User-Agent: Evolution 3.30.1-1build1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2019-02-05 at 11:14 -0800, David Miller wrote: > From: Joe Perches > Date: Tue, 05 Feb 2019 10:42:54 -0800 > > > On Mon, 2019-02-04 at 19:20 -0800, David Miller wrote: > >> From: Thierry Reding > >> Date: Mon, 4 Feb 2019 17:42:13 +0100 > >> > >> > @@ -7316,7 +7325,7 @@ static int rtl_get_ether_clk(struct rtl8169_private *tp) > >> > static int rtl_init_one(struct pci_dev *pdev, const struct pci_device_id *ent) > >> > { > >> > const struct rtl_cfg_info *cfg = rtl_cfg_infos + ent->driver_data; > >> > - u8 mac_addr[ETH_ALEN] __aligned(4) = {}; > >> > + u8 mac_addr[ETH_ALEN] = {}; > >> > struct rtl8169_private *tp; > >> > >> I agree with Heiner, you have to provide at least 2 byte alignment for this > >> buffer due to the reasons he stated. > > > > It's declared after a pointer so it is already is 2 byte aligned. > > > > A lot of drivers wouldn't work otherwise. > > That's assuming a lot about what the compiler will do when nit allocates > local variables to the stack. It's also assuming what a compiler will do when it defines a struct. > I want it _explicit_. Your choice, but there are a _lot_ of existing uses and I think requiring it is as senseless as requiring void * arithmetic to be cast to char * as gcc and clang already do not add padding after a pointer.