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=-4.0 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED 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 8C2A3C282C8 for ; Mon, 28 Jan 2019 07:13:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 60F8420882 for ; Mon, 28 Jan 2019 07:13:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726746AbfA1HNP (ORCPT ); Mon, 28 Jan 2019 02:13:15 -0500 Received: from mx1.redhat.com ([209.132.183.28]:55516 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726630AbfA1HNP (ORCPT ); Mon, 28 Jan 2019 02:13:15 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C59A385546; Mon, 28 Jan 2019 07:13:14 +0000 (UTC) Received: from localhost (ovpn-112-14.rdu2.redhat.com [10.10.112.14]) by smtp.corp.redhat.com (Postfix) with ESMTP id 219D25C557; Mon, 28 Jan 2019 07:13:12 +0000 (UTC) Date: Sun, 27 Jan 2019 23:13:11 -0800 (PST) Message-Id: <20190127.231311.1851509323400218212.davem@redhat.com> To: johannes@sipsolutions.net Cc: netdev@vger.kernel.org, viro@zeniv.linux.org.uk, linux-decnet-user@lists.sourceforge.net, johannes.berg@intel.com Subject: Re: [PATCH] decnet: fix DN_IFREQ_SIZE From: David Miller In-Reply-To: <20190126201219.14934-1-johannes@sipsolutions.net> References: <20190126201219.14934-1-johannes@sipsolutions.net> Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Mon, 28 Jan 2019 07:13:15 +0000 (UTC) Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Johannes Berg Date: Sat, 26 Jan 2019 21:12:19 +0100 > From: Johannes Berg > > Digging through the ioctls with Al because of the previous > patches, we found that on 64-bit decnet's dn_dev_ioctl() > is wrong, because struct ifreq::ifr_ifru is actually 24 > bytes (not 16 as expected from struct sockaddr) due to the > ifru_map and ifru_settings members. > > Clearly, decnet expects the ioctl to be called with a struct > like > struct ifreq_dn { > char ifr_name[IFNAMSIZ]; > struct sockaddr_dn ifr_addr; > }; > > since it does > struct ifreq *ifr = ...; > struct sockaddr_dn *sdn = (struct sockaddr_dn *)&ifr->ifr_addr; > > This means that DN_IFREQ_SIZE is too big for what it wants on > 64-bit, as it is > sizeof(struct ifreq) - sizeof(struct sockaddr) + > sizeof(struct sockaddr_dn) > > This assumes that sizeof(struct sockaddr) is the size of ifr_ifru > but that isn't true. > > Fix this to use offsetof(struct ifreq, ifr_ifru). > > This indeed doesn't really matter much - the result is that we > copy in/out 8 bytes more than we should on 64-bit platforms. In > case the "struct ifreq_dn" lands just on the end of a page though > it might lead to faults. > > As far as I can tell, it has been like this forever, so it seems > very likely that nobody cares. > > Signed-off-by: Johannes Berg Applied.