Received: by 10.223.185.116 with SMTP id b49csp824300wrg; Sat, 10 Feb 2018 21:15:34 -0800 (PST) X-Google-Smtp-Source: AH8x224T29wPbPGhR8qo0lSwAZ+waFt6Bz2ldzq356O0SJPwoo9wdxWJGTxgWa6/Km3sFiqnrlgf X-Received: by 10.101.82.68 with SMTP id q4mr6291615pgp.369.1518326134696; Sat, 10 Feb 2018 21:15:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518326134; cv=none; d=google.com; s=arc-20160816; b=k95vI2G/OEHDd4yGI07/ec4ZXz31MdxVyca179G+TvBHgGhaPDPF7hzmr/zUJbiwJY uH1kSiEyZ0SKYfx5Il1KND6VbSV64rqxqnqKhXEcznfY78gJvqJQ+LvSYUB3boMK/ODC omb6A8PS0GAvG2TY7cm6VQgLc2FHJ1t5Li95BDxiYx23QuzomYGs/TN2K5BwGVoiYAcL T2V+NYLq5DIEOfKWhi6TvJSCeW+wWEPl+vuDz9ykOIiObuqtLoKfn19R5pU9HfBPH/5E vgD6FdqWG/2lGZP+ln9b2Np04W/8aSj6F3ig0boWJoIcRkFGFCl+k2oAIl1JumPkS2Yp nY0g== 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=9Eo+tRbBG9D/RuIhUUCPF4yibKWZ+nW7fbLI0tnqluE=; b=YKsqLTpYzcdHb/aSrGRZOxKWdKuMQHygtqOqV/92jO0WbFBfkJjIgD3Ba+wNRqbHch oJoIldTodf/q/nTyvMg9dp9H4AWbSjM2f1kZbolW28v8BvOUhuOuhpcDhrldTJmE/xnY 42AdU4Cwdqgu4fBD5j2kG1beDf1jfMmNvwTHkY8j4t/S9SMUxN45/pFBrd23BnCdHnfR XTKyGnY0mFUgjju9WOtDVzFnNlxZeYnwc4u8YMjGZCJ1cFfYJd2nR9eghLkcUbgvBLjc bktiItMdwhcPcp4QcA7UxylGbZk67BHXEcLqNwMLIclwacJaMnLABL4oGEzBgH9hg7iT EvHw== 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 x81si3619879pgx.402.2018.02.10.21.15.20; Sat, 10 Feb 2018 21:15:34 -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; 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 S1753943AbeBKFM1 (ORCPT + 99 others); Sun, 11 Feb 2018 00:12:27 -0500 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:41423 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752639AbeBKEdl (ORCPT ); Sat, 10 Feb 2018 23:33:41 -0500 Received: from [2a02:8011:400e:2:6f00:88c8:c921:d332] (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 1ekjKe-0002hI-5z; Sun, 11 Feb 2018 04:33:40 +0000 Received: from ben by deadeye with local (Exim 4.90) (envelope-from ) id 1ekjKY-0004Ut-4v; Sun, 11 Feb 2018 04:33:34 +0000 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" , "Alexander Potapenko" , "Eric W. Biederman" Date: Sun, 11 Feb 2018 04:20:06 +0000 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) Subject: [PATCH 3.2 43/79] net/sctp: Always set scope_id in sctp_inet6_skb_msgname In-Reply-To: X-SA-Exim-Connect-IP: 2a02:8011:400e:2:6f00:88c8:c921:d332 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.2.99-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: "Eric W. Biederman" commit 7c8a61d9ee1df0fb4747879fa67a99614eb62fec upstream. Alexandar Potapenko while testing the kernel with KMSAN and syzkaller discovered that in some configurations sctp would leak 4 bytes of kernel stack. Working with his reproducer I discovered that those 4 bytes that are leaked is the scope id of an ipv6 address returned by recvmsg. With a little code inspection and a shrewd guess I discovered that sctp_inet6_skb_msgname only initializes the scope_id field for link local ipv6 addresses to the interface index the link local address pertains to instead of initializing the scope_id field for all ipv6 addresses. That is almost reasonable as scope_id's are meaniningful only for link local addresses. Set the scope_id in all other cases to 0 which is not a valid interface index to make it clear there is nothing useful in the scope_id field. There should be no danger of breaking userspace as the stack leak guaranteed that previously meaningless random data was being returned. Fixes: 372f525b495c ("SCTP: Resync with LKSCTP tree.") History-tree: https://git.kernel.org/pub/scm/linux/kernel/git/tglx/history.git Reported-by: Alexander Potapenko Tested-by: Alexander Potapenko Signed-off-by: "Eric W. Biederman" Signed-off-by: David S. Miller [bwh: Backported to 3.2: - Adjust context - Add braces] Signed-off-by: Ben Hutchings --- --- a/net/sctp/ipv6.c +++ b/net/sctp/ipv6.c @@ -781,6 +781,8 @@ static void sctp_inet6_skb_msgname(struc if (ipv6_addr_type(&addr->v6.sin6_addr) & IPV6_ADDR_LINKLOCAL) { struct sctp_ulpevent *ev = sctp_skb2event(skb); addr->v6.sin6_scope_id = ev->iif; + } else { + addr->v6.sin6_scope_id = 0; } }