Received: by 2002:a05:6a10:17d3:0:0:0:0 with SMTP id hz19csp2066575pxb; Mon, 12 Apr 2021 13:27:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxaGTZsyWf9BN9IjjVYPyXNPARzItlYp2BNhPedqijTA49gxcCqYMqC4NCjEtGcOUspdk5F X-Received: by 2002:a17:906:704a:: with SMTP id r10mr28908580ejj.312.1618259220737; Mon, 12 Apr 2021 13:27:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1618259220; cv=none; d=google.com; s=arc-20160816; b=kJsebj2ApVjGbnnf49QVooI/DSSwVX9JOGYtlpn6lN3rM8KTjAjun4f8XMgN2mltBw YoIIuyPOW11gffePmQebMJovU3sgemWg2YtTwYiY5dJT6cgK6+qUGhdg1LdsoCzldwd1 Zren5sMrLyD5zT+loeFI0MkUPDEMz70Mzu9L+48v/ojqS9vIOS2SChmU5lgTr4SjeUgK fBOamLsnDotqJT1CJGKECEncUCsBqOiCKCOou5V8FNgkYvaD2PtJWi0tsY9b6gk6hhPO 6PA9gOcFaSWZZdeYq7lb3Jdr5EJVeaqn1bWKMwTAf49VbwGfL1JARYIT4M9dB7ckhxtd MMfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DNmSVv3BbOjjsJg9zbaLdwwyWN664XliN1ctC9u1mQs=; b=HyuVCNEhobUEFw1KgTB8O1aK6d+ag5NAUIiDZO/wq3VTefft9LdWd8bv+bmGZk12Vb bwH2Y8u1/WrZEH2TLaR+iBwPX3oAPa1+kXEmn9PHVXCuOP1makxcgt6CFiRma9KAn5wJ 14a1XH7uPaOF0cQ9NpDWdz/atK8fA/d6Q8nLcLYuVMq8gbJEaovUSlvj56lnfpOoocPm LKPrd4lMS0ugCjJ1tHOR3XX657kP04y2rgtGNxTAcQj0Fs7nVlxWMtcidoQkvF12W1H3 5yzUingStA0Aw7Xkyr+T5lbdKH8XgBWPQ10uP/VE1N/F2ca0nlZLQf6pfKdQ7ftS4s3k 0qtA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UF8IFXsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o2si8291439ejr.38.2021.04.12.13.26.37; Mon, 12 Apr 2021 13:27:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=UF8IFXsu; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238711AbhDLI6c (ORCPT + 99 others); Mon, 12 Apr 2021 04:58:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:38180 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238697AbhDLIu0 (ORCPT ); Mon, 12 Apr 2021 04:50:26 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 99E3060241; Mon, 12 Apr 2021 08:50:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1618217409; bh=vtmMATUhTRbQ5ANUCsfBOEYyu18D0Az7WZPu+cNvztI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=UF8IFXsuafm/cSqDEbYEtQM44GOWMrtCss11DLQTVxvXVeZ8xTAZzExEP2G/kXGb9 OKQpNKOzLVFoMgZDTfKW7avUQAji3Tse0UW78Gi8kouwlBGHz+WsmAhYG1UG6XVNVJ BU2WrM2eSBQd6ZRaWodH5zAVFb9gg9zHfkbZRkzk= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Mark Bloch , Leon Romanovsky , Jason Gunthorpe , Sasha Levin Subject: [PATCH 5.4 093/111] RDMA/addr: Be strict with gid size Date: Mon, 12 Apr 2021 10:41:11 +0200 Message-Id: <20210412084007.345524174@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210412084004.200986670@linuxfoundation.org> References: <20210412084004.200986670@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Leon Romanovsky [ Upstream commit d1c803a9ccd7bd3aff5e989ccfb39ed3b799b975 ] The nla_len() is less than or equal to 16. If it's less than 16 then end of the "gid" buffer is uninitialized. Fixes: ae43f8286730 ("IB/core: Add IP to GID netlink offload") Link: https://lore.kernel.org/r/20210405074434.264221-1-leon@kernel.org Reported-by: Dan Carpenter Signed-off-by: Mark Bloch Signed-off-by: Leon Romanovsky Signed-off-by: Jason Gunthorpe Signed-off-by: Sasha Levin --- drivers/infiniband/core/addr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/infiniband/core/addr.c b/drivers/infiniband/core/addr.c index 8beed4197e73..c9e63c692b6e 100644 --- a/drivers/infiniband/core/addr.c +++ b/drivers/infiniband/core/addr.c @@ -76,7 +76,9 @@ static struct workqueue_struct *addr_wq; static const struct nla_policy ib_nl_addr_policy[LS_NLA_TYPE_MAX] = { [LS_NLA_TYPE_DGID] = {.type = NLA_BINARY, - .len = sizeof(struct rdma_nla_ls_gid)}, + .len = sizeof(struct rdma_nla_ls_gid), + .validation_type = NLA_VALIDATE_MIN, + .min = sizeof(struct rdma_nla_ls_gid)}, }; static inline bool ib_nl_is_good_ip_resp(const struct nlmsghdr *nlh) -- 2.30.2