Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp2216791imm; Thu, 7 Jun 2018 07:13:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKK4/fiLs2IZdIpjsTP1tjKfRkQWCS70ycgG2Ijb/Doj0sxZIczyiBZN+B71Nl3+2UOpV950 X-Received: by 2002:a65:5c46:: with SMTP id v6-v6mr1742941pgr.127.1528380796664; Thu, 07 Jun 2018 07:13:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528380796; cv=none; d=google.com; s=arc-20160816; b=Nw2Hip3bup4rNNwb6UB/Xy+s/LPvCuYLlRz37fuRRD6rFZCPbibfd7JXAIQYI51Wh8 GlFVXc01a7qvh9KQR9BTY6sMDcEpXQqVKECaXksXO9YdsZmCyn8fHCHwoXRrcrzN6KE7 /AX2WCI53NF5RF3raLMM57uHuqHbN8B+vv/x0E9l3CujHFMXjgwsv3Fb2DnZGaVdmUH6 rwmE+LZ9wupy3+yyRx6A85ybim1DTPxPjMAKS+AxYnA54KhcQoCaS/jfteRulN/7K/Ff R1KK2+B/QZNs7znJOngp5EFcQ/md5RqZcp3EYYjUavhgSZYqlpQpZbfKepolkcCurMCr u3zA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition :arc-authentication-results; bh=9Sv6JNRQXOLC8j8+SjDWN0U2XJXn0x0Xq8neJ7jmy4Q=; b=0aYMRpV82BJf2Vl2nE7YUAWfZaXIEh7lLoqCZ6N6ASNB2ein3xoEWo9yKEzO1GNczI 9HVkyJOB/vKeEHDDs2aQs+pbkI4xM96bJJe4iV1zRfrjXbZIKVMYBV5+50YPvjX9cr3h jQ8202PV3PGbypUKmumz5Jd5P8Cj+EinRDMKccYijJf3fgyIMdJtkPrAPqxTii2JTBHH Pvp2d8JX0zdjvUbGY9kz08/+ADuX17hQGM+zW/C8LUD7kNfUn27+5iXUNXSDt1WRjMB6 Zs9NJ93/nE0QoZZOyM/NcXv6YktNHFBXoye0J2/bayenqW7/oMV+nQBNUj5G24jFnfhC Cp8g== ARC-Authentication-Results: i=1; mx.google.com; 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 y18-v6si6599410pgv.388.2018.06.07.07.13.02; Thu, 07 Jun 2018 07:13:16 -0700 (PDT) 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; 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 S933343AbeFGOL7 (ORCPT + 99 others); Thu, 7 Jun 2018 10:11:59 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:39531 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932875AbeFGOJk (ORCPT ); Thu, 7 Jun 2018 10:09:40 -0400 Received: from [148.252.241.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1fQvbJ-0005Zi-7V; Thu, 07 Jun 2018 15:09:17 +0100 Received: from ben by deadeye with local (Exim 4.91) (envelope-from ) id 1fQvbF-0003Ir-6b; Thu, 07 Jun 2018 15:09:13 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, "David S. Miller" , "Eric Dumazet" , "Alexander Potapenko" Date: Thu, 07 Jun 2018 15:05:21 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.16 397/410] netlink: make sure nladdr has correct size in netlink_connect() In-Reply-To: X-SA-Exim-Connect-IP: 148.252.241.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.57-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Alexander Potapenko commit 7880287981b60a6808f39f297bb66936e8bdf57a upstream. KMSAN reports use of uninitialized memory in the case when |alen| is smaller than sizeof(struct sockaddr_nl), and therefore |nladdr| isn't fully copied from the userspace. Signed-off-by: Alexander Potapenko Fixes: 1da177e4c3f41524 ("Linux-2.6.12-rc2") Reviewed-by: Eric Dumazet Signed-off-by: David S. Miller Signed-off-by: Ben Hutchings --- net/netlink/af_netlink.c | 3 +++ 1 file changed, 3 insertions(+) --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -990,6 +990,9 @@ static int netlink_connect(struct socket if (addr->sa_family != AF_NETLINK) return -EINVAL; + if (alen < sizeof(struct sockaddr_nl)) + return -EINVAL; + if ((nladdr->nl_groups || nladdr->nl_pid) && !netlink_allowed(sock, NL_CFG_F_NONROOT_SEND)) return -EPERM;