Received: by 2002:a17:90a:88:0:0:0:0 with SMTP id a8csp4589310pja; Thu, 21 Nov 2019 22:24:35 -0800 (PST) X-Google-Smtp-Source: APXvYqwgnnoVNmBXZZz2gHRjg3jzorZIT0XeS39D36GNP1BQWmBA0HX3IyPCqGNWhvAT/PDcI/Jb X-Received: by 2002:a17:906:3ec8:: with SMTP id d8mr20178108ejj.55.1574403875457; Thu, 21 Nov 2019 22:24:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574403875; cv=none; d=google.com; s=arc-20160816; b=QIkgDZUGPLHv+FhARHmLz2YkbqGdVbA5c0nj+z+duRvjlZAS1rfI48P246bbKlDXTP 4H6yuO3UCATStDm0Xb4TQAaKh2KFSwvDz5pLc3C2/mDroe5S9b0HYga3g9VCGgV66usO KisUoJxVzMdWLb0M7Jky3dlnZMyPpi7Vgb9tPHmumR/6L782HquFaVSSH8f1YkKH0MRP p9H4g76d3r1z6uEyRf9dU/71c8/DcJWDixUzc3cfaG14NUz+82bzCWPMcZYAE0ywJf6F fojCaW6+/WrPfMAR4o4xOJsPc1AfWy8ZJm6nf60m9zSyUgv8H1aU6173TJJpCti2TmqG ABug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=z+tCD+Ose8gkh5lgAcTI6Qzdg1Ldjkkv7ds/CWZeHos=; b=zucpkfNNyUx4ZXi+3dUhiTXar7kfKlZYOR/M2X5KAK96bXNkApA3kQuGEYdjdDyVvl Ikc6fvw6DWPuyALxkLL7BBfDYSFJ+1Lkgsn8rQEGs0p3LCvxERH7G2dFM/ro96rYwIcM 8mT7P10QcGI4wYEyQDvZbBxHL6K1G+5Mw12eoab50VhsxRxVSYoO/JOqJVxzlMIlDq3p khVBeXW7SWpRD6ESZh4Ou6UwAwxIxNPKAtWjLV6OBz/Phwcks6Dnqx3md8gCYuKxVQLp B3gp3aeg8jcsnNrqe3hPia2qedi5UhQog7x4OuuAi56vz2SDUlh9SoydaVYPElVll9Eo zwkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="S/QQMg9s"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h26si3527133ejy.355.2019.11.21.22.24.10; Thu, 21 Nov 2019 22:24:35 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="S/QQMg9s"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728669AbfKVFwq (ORCPT + 99 others); Fri, 22 Nov 2019 00:52:46 -0500 Received: from mail.kernel.org ([198.145.29.99]:58420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728602AbfKVFwi (ORCPT ); Fri, 22 Nov 2019 00:52:38 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3E5AF20721; Fri, 22 Nov 2019 05:52:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574401957; bh=jSpGLYFvMA/bog854o9Rps6L7KliDegHUV3SKraVXgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S/QQMg9sC8Kk9HdVu8a+3140A4bU7qN5jHSMEIHoSjTygAhdiT9rPfx//dfDSWpU/ Nb3qJtbytdLc8G2yLKhq5D/2g9B1vZ6WpYi7dj+lC/JbUZwF3frG6CBckOlDiU+2rX ER/6wV4iegvCdiyvRUIU4kOQ8Y2xA8Sfaq8MPJWA= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Johannes Berg , "David S . Miller" , Sasha Levin , linux-decnet-user@lists.sourceforge.net, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.19 179/219] decnet: fix DN_IFREQ_SIZE Date: Fri, 22 Nov 2019 00:48:31 -0500 Message-Id: <20191122054911.1750-172-sashal@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191122054911.1750-1-sashal@kernel.org> References: <20191122054911.1750-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore 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 bfd43e8f2c06e..3235540f6adff 100644 --- a/net/decnet/dn_dev.c +++ b/net/decnet/dn_dev.c @@ -56,7 +56,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