From patchwork Sun Sep 29 17:38:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 174692 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp6172272ill; Sun, 29 Sep 2019 10:39:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqwbS9j2mFR6ue0GqSO/OYIjIxeJ4aQlMMZUfBfwmoqVFrewYzqHBdWUgMEKTBju5Ss6BjQs X-Received: by 2002:a50:8961:: with SMTP id f30mr15171694edf.144.1569778794934; Sun, 29 Sep 2019 10:39:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569778794; cv=none; d=google.com; s=arc-20160816; b=FmmM4TC9DapYI1yR7ga69MQtVpXAPaUP5EeL/q52zN5H1eHbTy0o4gcP/npre/4U53 4J3dlYsOlTHky2xIdLqcAxw9XkDghz2QqNlwIa6pxWugkQdhzMEOyN7PFa2sKCANxbQv vvFnpsz5s8c4m0YQaS1FzWyPeTQZEx+MLkRxjeEsQqYcdk5A/UazO+6uWhglpqcAaW67 GmtASN+fYkYyOZEXlE8ygJoDtgRnPqJN65lA+5scdLC4XIarAf8XgnLzJZEBCiqweFZx +j9w6tq/cc5n51kwdbfEz7a+3VYn4FhKDD78cO67i6l/bhPQotIkP3fVoj4r3ZE2cQUB BhFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=c7gRGregGvO6OT7bIf1xMnSekX73Q+P1Ihexxh5ywF4=; b=omBxx2t0Rc+I40WJj7T83+KUf9EBBZ/8ZhH/fkUZf3W9DD2ncaSW4nJ6whsBhXI43t oRTxkL4+d+Hr/gosTScvfDoylUQNu3nPD/Xxd9VpeaxcU2FRmsZy+YMGo99tqIrLB0UY 6oJD3RcO2T3DMZoGQxxOmWyorNfi14tLdO7VnmQC8uPCnXHvGcbLnWDYbBJheJ6TUm/c 1pqOpTv3hzFo9enidRsOeeb8WsPaHanPiNLNvVN4bcCVeIFmKl99T2tWQ2NSOWhMQiLy HBWSNP2HOUdgoCN3hJMjNTuGWx4g0Yt9qvZbk5U39E/zrmv5c1JpMRkWr3N8q0TnNYMu YFGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P+Wm3k9f; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id w5si5343359edv.66.2019.09.29.10.39.54; Sun, 29 Sep 2019 10:39:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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=@linaro.org header.s=google header.b=P+Wm3k9f; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730508AbfI2Rjv (ORCPT + 3 others); Sun, 29 Sep 2019 13:39:51 -0400 Received: from mail-wr1-f66.google.com ([209.85.221.66]:45507 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729378AbfI2Rjv (ORCPT ); Sun, 29 Sep 2019 13:39:51 -0400 Received: by mail-wr1-f66.google.com with SMTP id r5so8403054wrm.12 for ; Sun, 29 Sep 2019 10:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=c7gRGregGvO6OT7bIf1xMnSekX73Q+P1Ihexxh5ywF4=; b=P+Wm3k9f1uAZZ/SNB31mpqeYK+eLX9OOI/5HnTmGYLG/xEEAABkB/ZkELx4gYu5Xbm xldLa/dGsozZm59dGU6mkT7mvdpDFMBGyt1bbgnMcEqMcS29+mRSylfBG0FjJzwEMUGX FMtpZXCK3CBaBp+BQSps4Faghk44UqFofjft3yyoUIbliBjWho4gNp0ojvLTyWC/bA7A ra0eCjtILW2dNCvVIg4dk4eIuBhzR8eav+cmNFwC7rjwLalcp7riVGbINgoBXKU33lRZ Ac//reNGK2z4JfmWjPs5eZWxnc9dCrFXU4DYb8j1HQZlk4bUUCxfw/6/pVuqeJJ9Rwn8 VfMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=c7gRGregGvO6OT7bIf1xMnSekX73Q+P1Ihexxh5ywF4=; b=ZMQ4TAFG4e4o9/I5yt8JwzTMzeXG3ETmgdH7rNBGX8qDrRDNp/z1OXf6exW9bsRguE wSnbaNQLi6ybftO/i/uoMJEAHiZe/IZ+sCO694Zbv5NinwheMxaQnHRFIyW5/539EloO BUhiis2ruD2JhPP3jixSajPNYC4x2W+DM+QFL8rZ1r9xb051+eWexBBdG3gnmQH84aVw yXjDJQYFb4znpin6Qv8E8XlAWhdCZf783uVzi5+WgklEQkCFy9W0qfHFEbYvDyKKJuzW 9UCJ9I6q08qZB/1n5dLsp3x4OvEa8Qpt3xxXR0EDXnuY2maZHjaNQLj1v2a3aogxirFn JydQ== X-Gm-Message-State: APjAAAW5RyP1LKZlbPpcevIa0L40J1w9HLptJyKudwdbxP0VEk/eW9A/ m9NOgwLG0E0/+AKjN3Y1zG8Tc5Ni5sy1Sc/Z X-Received: by 2002:a5d:620d:: with SMTP id y13mr9891717wru.86.1569778789010; Sun, 29 Sep 2019 10:39:49 -0700 (PDT) Received: from e123331-lin.nice.arm.com (bar06-5-82-246-156-241.fbx.proxad.net. [82.246.156.241]) by smtp.gmail.com with ESMTPSA id q192sm17339779wme.23.2019.09.29.10.39.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 29 Sep 2019 10:39:47 -0700 (PDT) From: Ard Biesheuvel To: linux-crypto@vger.kernel.org Cc: linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Herbert Xu , David Miller , Greg KH , Linus Torvalds , "Jason A . Donenfeld" , Samuel Neves , Dan Carpenter , Arnd Bergmann , Eric Biggers , Andy Lutomirski , Will Deacon , Marc Zyngier , Catalin Marinas , Martin Willi Subject: [RFC PATCH 19/20] netlink: use new strict length types in policy for 5.2 Date: Sun, 29 Sep 2019 19:38:49 +0200 Message-Id: <20190929173850.26055-20-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190929173850.26055-1-ard.biesheuvel@linaro.org> References: <20190929173850.26055-1-ard.biesheuvel@linaro.org> Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org Taken from https://git.zx2c4.com/WireGuard/commit/src?id=3120425f69003be287cb2d308f89c7a6a0335ff0 Reported-by: Bruno Wolff III --- drivers/net/wireguard/netlink.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) -- 2.17.1 diff --git a/drivers/net/wireguard/netlink.c b/drivers/net/wireguard/netlink.c index 3763e8c14ea5..676d36725120 100644 --- a/drivers/net/wireguard/netlink.c +++ b/drivers/net/wireguard/netlink.c @@ -21,8 +21,8 @@ static struct genl_family genl_family; static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = { [WGDEVICE_A_IFINDEX] = { .type = NLA_U32 }, [WGDEVICE_A_IFNAME] = { .type = NLA_NUL_STRING, .len = IFNAMSIZ - 1 }, - [WGDEVICE_A_PRIVATE_KEY] = { .len = NOISE_PUBLIC_KEY_LEN }, - [WGDEVICE_A_PUBLIC_KEY] = { .len = NOISE_PUBLIC_KEY_LEN }, + [WGDEVICE_A_PRIVATE_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN }, + [WGDEVICE_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN }, [WGDEVICE_A_FLAGS] = { .type = NLA_U32 }, [WGDEVICE_A_LISTEN_PORT] = { .type = NLA_U16 }, [WGDEVICE_A_FWMARK] = { .type = NLA_U32 }, @@ -30,12 +30,12 @@ static const struct nla_policy device_policy[WGDEVICE_A_MAX + 1] = { }; static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = { - [WGPEER_A_PUBLIC_KEY] = { .len = NOISE_PUBLIC_KEY_LEN }, - [WGPEER_A_PRESHARED_KEY] = { .len = NOISE_SYMMETRIC_KEY_LEN }, + [WGPEER_A_PUBLIC_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_PUBLIC_KEY_LEN }, + [WGPEER_A_PRESHARED_KEY] = { .type = NLA_EXACT_LEN, .len = NOISE_SYMMETRIC_KEY_LEN }, [WGPEER_A_FLAGS] = { .type = NLA_U32 }, - [WGPEER_A_ENDPOINT] = { .len = sizeof(struct sockaddr) }, + [WGPEER_A_ENDPOINT] = { .type = NLA_MIN_LEN, .len = sizeof(struct sockaddr) }, [WGPEER_A_PERSISTENT_KEEPALIVE_INTERVAL] = { .type = NLA_U16 }, - [WGPEER_A_LAST_HANDSHAKE_TIME] = { .len = sizeof(struct __kernel_timespec) }, + [WGPEER_A_LAST_HANDSHAKE_TIME] = { .type = NLA_EXACT_LEN, .len = sizeof(struct __kernel_timespec) }, [WGPEER_A_RX_BYTES] = { .type = NLA_U64 }, [WGPEER_A_TX_BYTES] = { .type = NLA_U64 }, [WGPEER_A_ALLOWEDIPS] = { .type = NLA_NESTED }, @@ -44,7 +44,7 @@ static const struct nla_policy peer_policy[WGPEER_A_MAX + 1] = { static const struct nla_policy allowedip_policy[WGALLOWEDIP_A_MAX + 1] = { [WGALLOWEDIP_A_FAMILY] = { .type = NLA_U16 }, - [WGALLOWEDIP_A_IPADDR] = { .len = sizeof(struct in_addr) }, + [WGALLOWEDIP_A_IPADDR] = { .type = NLA_MIN_LEN, .len = sizeof(struct in_addr) }, [WGALLOWEDIP_A_CIDR_MASK] = { .type = NLA_U8 } }; @@ -591,12 +591,10 @@ static const struct genl_ops genl_ops[] = { .start = wg_get_device_start, .dumpit = wg_get_device_dump, .done = wg_get_device_done, - .policy = device_policy, .flags = GENL_UNS_ADMIN_PERM }, { .cmd = WG_CMD_SET_DEVICE, .doit = wg_set_device, - .policy = device_policy, .flags = GENL_UNS_ADMIN_PERM } }; @@ -608,6 +606,7 @@ static struct genl_family genl_family __ro_after_init = { .version = WG_GENL_VERSION, .maxattr = WGDEVICE_A_MAX, .module = THIS_MODULE, + .policy = device_policy, .netnsok = true };