From patchwork Sat Dec 2 20:23:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johannes Berg X-Patchwork-Id: 10089015 X-Patchwork-Delegate: johannes@sipsolutions.net Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A942A60327 for ; Sat, 2 Dec 2017 20:23:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9A4ED29032 for ; Sat, 2 Dec 2017 20:23:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8E46229205; Sat, 2 Dec 2017 20:23:57 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E43A529032 for ; Sat, 2 Dec 2017 20:23:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752347AbdLBUXh (ORCPT ); Sat, 2 Dec 2017 15:23:37 -0500 Received: from s3.sipsolutions.net ([144.76.63.242]:52084 "EHLO sipsolutions.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752308AbdLBUXg (ORCPT ); Sat, 2 Dec 2017 15:23:36 -0500 Received: by sipsolutions.net with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1eLEJy-0006nK-EM; Sat, 02 Dec 2017 21:23:34 +0100 From: Johannes Berg To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org Cc: j@w1.fi, David Ahern , Johannes Berg Subject: [PATCH net 1/2] netlink: add NLA_U8_BUGGY attribute type Date: Sat, 2 Dec 2017 21:23:31 +0100 Message-Id: <20171202202332.10205-1-johannes@sipsolutions.net> X-Mailer: git-send-email 2.14.2 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Johannes Berg This netlink type is used only for backwards compatibility with broken userspace that used the wrong size for a given u8 attribute, which is now rejected. It would've been wrong before already, since on big endian the wrong value (always zero) would be used by the kernel, but we can't break the existing deployed userspace - hostapd for example now fails to initialize entirely. We could try to fix up the big endian problem here, but we don't know *how* userspace misbehaved - if using nla_put_u32 then we could, but we also found a debug tool (which we'll ignore for the purposes of this regression) that was putting the padding into the length. Fixes: 28033ae4e0f5 ("net: netlink: Update attr validation to require exact length for some types") Signed-off-by: Johannes Berg --- include/net/netlink.h | 1 + lib/nlattr.c | 1 + 2 files changed, 2 insertions(+) diff --git a/include/net/netlink.h b/include/net/netlink.h index 0c154f98e987..448a9b86c959 100644 --- a/include/net/netlink.h +++ b/include/net/netlink.h @@ -180,6 +180,7 @@ enum { NLA_S32, NLA_S64, NLA_BITFIELD32, + NLA_U8_BUGGY, /* don't use this - only for bug-ward compatibility */ __NLA_TYPE_MAX, }; diff --git a/lib/nlattr.c b/lib/nlattr.c index 8bf78b4b78f0..2b89d25d4745 100644 --- a/lib/nlattr.c +++ b/lib/nlattr.c @@ -28,6 +28,7 @@ static const u8 nla_attr_len[NLA_TYPE_MAX+1] = { }; static const u8 nla_attr_minlen[NLA_TYPE_MAX+1] = { + [NLA_U8_BUGGY] = sizeof(u8), [NLA_MSECS] = sizeof(u64), [NLA_NESTED] = NLA_HDRLEN, };