Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751521AbdFGBE5 (ORCPT ); Tue, 6 Jun 2017 21:04:57 -0400 Received: from shards.monkeyblade.net ([184.105.139.130]:44372 "EHLO shards.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751437AbdFGBE4 (ORCPT ); Tue, 6 Jun 2017 21:04:56 -0400 Date: Tue, 06 Jun 2017 21:04:27 -0400 (EDT) Message-Id: <20170606.210427.2001413617170270195.davem@davemloft.net> To: fw@strlen.de Cc: glider@google.com, dvyukov@google.com, kcc@google.com, edumazet@google.com, stephen@networkplumber.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Subject: Re: [PATCH v4] net: don't call strlen on non-terminated string in dev_set_alias() From: David Miller In-Reply-To: <20170606215735.GA18283@breakpoint.cc> References: <20170606135654.111884-1-glider@google.com> <20170606.163639.1246601020260541080.davem@davemloft.net> <20170606215735.GA18283@breakpoint.cc> X-Mailer: Mew version 6.7 on Emacs 25.2 / 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]); Tue, 06 Jun 2017 17:23:16 -0700 (PDT) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 950 Lines: 26 From: Florian Westphal Date: Tue, 6 Jun 2017 23:57:35 +0200 > David Miller wrote: >> From: Alexander Potapenko >> Date: Tue, 6 Jun 2017 15:56:54 +0200 >> >> > KMSAN reported a use of uninitialized memory in dev_set_alias(), >> > which was caused by calling strlcpy() (which in turn called strlen()) >> > on the user-supplied non-terminated string. >> > >> > Signed-off-by: Alexander Potapenko >> >> We should not be allowing non-NULL terminated strings for the >> IFLA_IFALIAS attribute. It's defined as type NLA_STRING in >> the ifla_policy[] array. > > Unfortunately NLA_STRING doesn't check for NUL byte, only > NLA_NUL_STRING does this. > > So unless you think we can change kernel and make NLA_STRING > behave like NLA_NUL_STRING I think patch is correct. Ok, I missed that, thanks for the clarification. I'll apply this and queue it up for -stable, thanks.