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=-9.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, PDS_BTC_ID,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT 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 22986C2BC73 for ; Wed, 4 Dec 2019 17:59:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EE0EF2081B for ; Wed, 4 Dec 2019 17:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482391; bh=3pT4tzAQDoCWy1rARRfevvK6RgLlOffebbAAx/Ips6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=zLnnF7BcAxoCguSYHDvbTmzA/ZqY/0fWOcuJpd/+88eiP84hzkSbgmiFTsj5kuWqp caEVFjfpcp2UaztpJ3DFBN6OnWxvaVRjSz2iUMUEXuo5tgwIeOCXEE133j08qRdMEz bLToOzgS7JhkcNqr3/67wxH4zbgNdgS0Lgnwi1rQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729203AbfLDR7u (ORCPT ); Wed, 4 Dec 2019 12:59:50 -0500 Received: from mail.kernel.org ([198.145.29.99]:36968 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729187AbfLDR7s (ORCPT ); Wed, 4 Dec 2019 12:59:48 -0500 Received: from localhost (unknown [217.68.49.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id CA8BC20675; Wed, 4 Dec 2019 17:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1575482387; bh=3pT4tzAQDoCWy1rARRfevvK6RgLlOffebbAAx/Ips6Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CAfR6RXyuTldze/8LM6CojPdpwu6E9DIZxAP2pNoc2RBcpFc/VfMy7UtkeTzOot8z X0E7h9nNdS7X3vZdEtYQ9HIRI1E2ztEbHtIWpItWTT5v7E7joMhVQxk+xzdheClKJJ rOHYpoREg3ppYhtSGIJJ2hes4KO1Kc0zknE2a/ww= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Johannes Berg , "David S. Miller" , Sasha Levin Subject: [PATCH 4.4 67/92] decnet: fix DN_IFREQ_SIZE Date: Wed, 4 Dec 2019 18:50:07 +0100 Message-Id: <20191204174334.364269486@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191204174327.215426506@linuxfoundation.org> References: <20191204174327.215426506@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Johannes Berg [ Upstream commit 50c2936634bcb1db78a8ca63249236810c11a80f ] 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 Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- net/decnet/dn_dev.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/net/decnet/dn_dev.c b/net/decnet/dn_dev.c index b2c26b081134a..80554e7e9a0f6 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c @@ -55,7 +55,7 @@ #include #include -#define DN_IFREQ_SIZE (sizeof(struct ifreq) - sizeof(struct sockaddr) + sizeof(struct sockaddr_dn)) +#define DN_IFREQ_SIZE (offsetof(struct ifreq, ifr_ifru) + sizeof(struct sockaddr_dn)) static char dn_rt_all_end_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x04,0x00,0x00}; static char dn_rt_all_rt_mcast[ETH_ALEN] = {0xAB,0x00,0x00,0x03,0x00,0x00}; -- 2.20.1