Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752787AbdCIHMO (ORCPT ); Thu, 9 Mar 2017 02:12:14 -0500 Received: from shards.monkeyblade.net ([184.105.139.130]:60412 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750784AbdCIHML (ORCPT ); Thu, 9 Mar 2017 02:12:11 -0500 Date: Wed, 08 Mar 2017 23:12:08 -0800 (PST) Message-Id: <20170308.231208.1651420232093147373.davem@davemloft.net> To: glider@google.com Cc: dvyukov@google.com, kcc@google.com, keescook@chromium.org, edumazet@google.com, paul@paul-moore.com, sds@tycho.nsa.gov, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, selinux@tycho.nsa.gov Subject: Re: [PATCH v2] selinux: check for address length in selinux_socket_bind() From: David Miller In-Reply-To: <20170306184614.20056-1-glider@google.com> References: <20170306184614.20056-1-glider@google.com> X-Mailer: Mew version 6.7 on Emacs 25.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.5.12 (shards.monkeyblade.net [149.20.54.216]); Wed, 08 Mar 2017 23:12:10 -0800 (PST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 863 Lines: 21 From: Alexander Potapenko Date: Mon, 6 Mar 2017 19:46:14 +0100 > KMSAN (KernelMemorySanitizer, a new error detection tool) reports use of > uninitialized memory in selinux_socket_bind(): ... > (the line numbers are relative to 4.8-rc6, but the bug persists upstream) > > , when I run the following program as root: ... > (for different values of |size| other error reports are printed). > > This happens because bind() unconditionally copies |size| bytes of > |addr| to the kernel, leaving the rest uninitialized. Then > security_socket_bind() reads the IP address bytes, including the > uninitialized ones, to determine the port, or e.g. pass them further to > sel_netnode_find(), which uses them to calculate a hash. > > Signed-off-by: Alexander Potapenko Are the SELINUX folks going to pick this up or should I?