Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp2115ybi; Tue, 18 Jun 2019 16:07:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqy/XCzSuJlmxr1IB1O12w0nqUmaeDlcJE4yVskb3p+r23jw31+/m2+ULVg/6xrJfVbKSO7m X-Received: by 2002:a63:31c7:: with SMTP id x190mr4857545pgx.376.1560899231073; Tue, 18 Jun 2019 16:07:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560899231; cv=none; d=google.com; s=arc-20160816; b=Miym4UEufJtoLxObk/DAgmitJdGF7PH8M2BiOmcZud/3bzovasVBtibEC3vhAad0ws nhCrBOoH/JgNLnbcg8JehQDG9jwwuj2Zf3engYrY1zEsd6jBGJvd2KfWKZw/Y8SoEbJY /h9TBkIvOSJEESFhckTTDSGbwe2igtYGr1O5Q2RUZHvmcDCpBPsV3Vs9Paxw9vz0Hh7E G2p7FABakGEWY2kZKBYEy2KUGb0Y5H5Ft4IKq4VsUSyJGGRf99eYTcqZngmafdABmmup yDiVsXEEtd7o8GSWVpS9JqrPTPoCtOAMRKmQA/2fRu1zMgCT83E8QLwGqP/dzD4kSePm vn4w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=FGnaLCpYant0F2h8DJ+WJRl5NNXPu88p4lDBv5PKqH4=; b=Vgt2BlT2KPLgTeR7MxAI8PF0WLPVqzrLgfPnUD/hPP3/yeKAFERNRENfhVcV6QTrwQ mi+LmFiLrzwTFd/I6anHx6+HQgWPfezHvh9KoMjY4NBBR2aq5OXlxi01VoKxu5vzAnkh KYccaWZUJOfD1m3VQumICrxRBeyDc2cbJ5Ckll3s1Q2o1pBZKAXJI0aicVD58QOlwQUv vSof5wEOC5x94W0KK9qeQVUcbsA2si3PYfXl7SuB/90WGQ212zBcfX2lj8xy2OJmHY+m HhGF0UCsiRgyFW8bWWVqNSuS+IYCklogE2C6B+hbl/RK2vQ1Sq9YCgfgYfP06ngPJ7Cs DB4A== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id z11si3512635pjn.72.2019.06.18.16.06.54; Tue, 18 Jun 2019 16:07:11 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730934AbfFRXGj (ORCPT + 99 others); Tue, 18 Jun 2019 19:06:39 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:34625 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730908AbfFRXGj (ORCPT ); Tue, 18 Jun 2019 19:06:39 -0400 Received: from 162-237-133-238.lightspeed.rcsntx.sbcglobal.net ([162.237.133.238] helo=lindsey) by youngberry.canonical.com with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1hdNAS-0003iA-Kq; Tue, 18 Jun 2019 23:05:33 +0000 Date: Tue, 18 Jun 2019 18:05:28 -0500 From: Tyler Hicks To: Jiri Slaby Cc: Gen Zhang , broonie@kernel.org, lgirdwood@gmail.com, perex@perex.cz, wen.yang99@zte.com.cn, alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] wcd9335: fix a incorrect use of kstrndup() Message-ID: <20190618230527.GE6248@lindsey> References: <20190529015305.GA4700@zhanggen-UX430UQ> <7573d8ce-7160-39b1-8901-be9155c451a1@suse.cz> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7573d8ce-7160-39b1-8901-be9155c451a1@suse.cz> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-06-05 06:57:02, Jiri Slaby wrote: > On 29. 05. 19, 3:53, Gen Zhang wrote: > > In wcd9335_codec_enable_dec(), 'widget_name' is allocated by kstrndup(). > > However, according to doc: "Note: Use kmemdup_nul() instead if the size > > is known exactly." > > Except the size is not known exactly. It is at most 15, not 15. Right? That's my understanding, as well. This change looks incorrect/misguided to me. CVE-2019-12454 was assigned for this but I've requested that MITRE reject it as there doesn't seem to be any security impact and possibly no reason at all for this change. Tyler > > > So we should use kmemdup_nul() here instead of > > kstrndup(). > > > > Signed-off-by: Gen Zhang > > --- > > diff --git a/sound/soc/codecs/wcd9335.c b/sound/soc/codecs/wcd9335.c > > index a04a7ce..85737fe 100644 > > --- a/sound/soc/codecs/wcd9335.c > > +++ b/sound/soc/codecs/wcd9335.c > > @@ -2734,7 +2734,7 @@ static int wcd9335_codec_enable_dec(struct snd_soc_dapm_widget *w, > > char *dec; > > u8 hpf_coff_freq; > > > > - widget_name = kstrndup(w->name, 15, GFP_KERNEL); > > + widget_name = kmemdup_nul(w->name, 15, GFP_KERNEL); > > if (!widget_name) > > return -ENOMEM; > > > > thanks, > -- > js > suse labs