Received: by 2002:a17:90a:9103:0:0:0:0 with SMTP id k3csp11802870pjo; Thu, 2 Jan 2020 14:32:50 -0800 (PST) X-Google-Smtp-Source: APXvYqxw+VM9j1omJoPmw1Ke0AhB/g1QeHna5E8S/yj0f/9x0kP6iZSmjqTUodNled7Jzv7r4sPq X-Received: by 2002:a05:6830:1188:: with SMTP id u8mr94957559otq.274.1578004370183; Thu, 02 Jan 2020 14:32:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578004370; cv=none; d=google.com; s=arc-20160816; b=Bh1yexosCS/OlYo39+1eR2kIrza3RJOVXYAEQ+yxEaTWvwlGX4yrbNlO6sFsO8wtGj JsGXj+dO3TVp4PWFuse6lU1nh+PyXail/PMoGhq4SICze/vCqJgPIT3M2z44TVMhqxbA a7YZbi13SDSzgvnXZLhPVvDKaLP7UEd57NgegB3aI1b5G2OCbb5bGr6t/9E7JbBA5qn0 9svsRS33B1AHuSevigrzMN4xkvgTtoB5hM/vjs8Mr/kIZdi8ZCij6c/qkiBXPF3w1bNe 1Pl3MRnWIPTC3MPGV2T4shV0DnUcr1Nx5AWPZk3kJ7qEqVtKiKRkGqdinoPEnIJLEixR 45nA== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aYEXSsJhwQQD8TwOE8kvj5tIOMrTymOYlortYZa1e5Y=; b=GpdF4meZomv08GMG/PxNnzvm5JMGn+u8gzGJnI1MmFhVCRhgOwrliW599X+u9xmtxi ZtjTfs04HWZprSWZNsQ1ckbJezGUTb0gsuVJUzZ7x4uKfvNVLi+TqwE+KHBOG5F1fxHL dzWl4aydiKVXtceXPpfmYuwGetBqqiK/jo227dXFu1rhALhy08SHBT+NucOYTn+M1Ef2 jzZ2JJQiXN71pT9HKi+XUi6X4vkA3WWGw9uMy0VtSWZC4Kzdb1kSL54BJEQ9WHiLN41s 7iu+x/Svx7U8ybyhx8ra2akt4lebrgunobyz8bS/YBPFPotZ7P6YoHduD0kSDRfogIpf 4afg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=G1WXg7Dg; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u16si27784677otq.92.2020.01.02.14.32.38; Thu, 02 Jan 2020 14:32:50 -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=G1WXg7Dg; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730200AbgABWb4 (ORCPT + 99 others); Thu, 2 Jan 2020 17:31:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:37568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730340AbgABWby (ORCPT ); Thu, 2 Jan 2020 17:31:54 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 36DF1222C3; Thu, 2 Jan 2020 22:31:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578004313; bh=G4IQT9yQ3RYgtofCZxFhL1uzsyB48PGKX/G/oh9lTm8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=G1WXg7Dgy52nXs8GThNQbo8/GGkK/YVwa/KX3+vCk0vzfGNJT66JS6f9ZZhb2nkX1 kf+UEJXbE889eSuahl200qgb5q6XyG9qMNhrMZXpkJwbNdRjSMiQidR/Syyp0HWXyu X7xEQn9oUe6gOqtJd7jwI8c6bAHBq59bfwLDpUO4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Geert Uytterhoeven , "David S. Miller" Subject: [PATCH 4.9 101/171] net: dst: Force 4-byte alignment of dst_metrics Date: Thu, 2 Jan 2020 23:07:12 +0100 Message-Id: <20200102220601.194131296@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220546.960200039@linuxfoundation.org> References: <20200102220546.960200039@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: Geert Uytterhoeven [ Upstream commit 258a980d1ec23e2c786e9536a7dd260bea74bae6 ] When storing a pointer to a dst_metrics structure in dst_entry._metrics, two flags are added in the least significant bits of the pointer value. Hence this assumes all pointers to dst_metrics structures have at least 4-byte alignment. However, on m68k, the minimum alignment of 32-bit values is 2 bytes, not 4 bytes. Hence in some kernel builds, dst_default_metrics may be only 2-byte aligned, leading to obscure boot warnings like: WARNING: CPU: 0 PID: 7 at lib/refcount.c:28 refcount_warn_saturate+0x44/0x9a refcount_t: underflow; use-after-free. Modules linked in: CPU: 0 PID: 7 Comm: ksoftirqd/0 Tainted: G W 5.5.0-rc2-atari-01448-g114a1a1038af891d-dirty #261 Stack from 10835e6c: 10835e6c 0038134f 00023fa6 00394b0f 0000001c 00000009 00321560 00023fea 00394b0f 0000001c 001a70f8 00000009 00000000 10835eb4 00000001 00000000 04208040 0000000a 00394b4a 10835ed4 00043aa8 001a70f8 00394b0f 0000001c 00000009 00394b4a 0026aba8 003215a4 00000003 00000000 0026d5a8 00000001 003215a4 003a4361 003238d6 000001f0 00000000 003215a4 10aa3b00 00025e84 003ddb00 10834000 002416a8 10aa3b00 00000000 00000080 000aa038 0004854a Call Trace: [<00023fa6>] __warn+0xb2/0xb4 [<00023fea>] warn_slowpath_fmt+0x42/0x64 [<001a70f8>] refcount_warn_saturate+0x44/0x9a [<00043aa8>] printk+0x0/0x18 [<001a70f8>] refcount_warn_saturate+0x44/0x9a [<0026aba8>] refcount_sub_and_test.constprop.73+0x38/0x3e [<0026d5a8>] ipv4_dst_destroy+0x5e/0x7e [<00025e84>] __local_bh_enable_ip+0x0/0x8e [<002416a8>] dst_destroy+0x40/0xae Fix this by forcing 4-byte alignment of all dst_metrics structures. Fixes: e5fd387ad5b30ca3 ("ipv6: do not overwrite inetpeer metrics prematurely") Signed-off-by: Geert Uytterhoeven Signed-off-by: David S. Miller Signed-off-by: Greg Kroah-Hartman --- include/net/dst.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/include/net/dst.h +++ b/include/net/dst.h @@ -110,7 +110,7 @@ struct dst_entry { struct dst_metrics { u32 metrics[RTAX_MAX]; atomic_t refcnt; -}; +} __aligned(4); /* Low pointer bits contain DST_METRICS_FLAGS */ extern const struct dst_metrics dst_default_metrics; u32 *dst_cow_metrics_generic(struct dst_entry *dst, unsigned long old);