Received: by 2002:a25:824b:0:0:0:0:0 with SMTP id d11csp399809ybn; Tue, 1 Oct 2019 23:22:28 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaQ9+QV8tDSVfrIar4tgb66aCDaOBza5359VlthhQ9UOMWooHWgnMYNjZegjTRHEsZJHyr X-Received: by 2002:a17:906:6848:: with SMTP id a8mr1677658ejs.104.1569997348727; Tue, 01 Oct 2019 23:22:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1569997348; cv=none; d=google.com; s=arc-20160816; b=AshHX4XoB73Wf21EAaJPW465Tse7f6PvSrCY97sgqtXJ48vvu7YciDv5Flj147mCTB cPAlIQgA875e8pnqh5C8cWUNEH2roxSTLAevYkOogOynR+ppIvZr+4895zfd4zYgOWOT LzgEUDp/ckuuVi4sMxhTStvftn9y+VLD/Jxz6S3Z9tV+t+VhsmcvDxmYgc5bRci4rZnS 9fn2AJgmZ5OD8oTZLprGJUBS4UeI9CDzExNVKZGti0NL++bmhS9Bow+fAxfcSkpS2cw2 AZbapM57qhjMNgYyfLKMgTObgvMQPitOSbaqmLpqBvbM7CifC5BRztJa9/J5bD+1uObV Uzmw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:date :content-transfer-encoding:references:in-reply-to:cc:to:from:subject :message-id; bh=sO4m+7UdGVWOXQm5locJAKfFmzHl5QPqGdr2Vw0RpSI=; b=UAUJegC+nWWvPPsP7LbWlCXbl1ioKq1jMWmS1LHl8z9FeFFQLac3Xwwoot5hSRmxhi tZAXBr76z1JERJNZVqoL6SpNaTIqjL+O/spwGZQBQaxrBHt0C61tJH62QsvtFcnFhnnk cpm/2ooEbbdMyFmx5d9RYG5TWXG2r/8OEL33OR0ftbVj47T9S5BvLmsyLiqlTwtCR+rr ZA14KiWor4ZY56uUJ/djBFerI3LP3tyM+taKLjSKicCWMUjpaApRBQk+6tNSOB+Kpt0o BLG0wPQxe7jA0DiuXW6TKAm9adzdjLVXqdbdy0oCwJhkVtCe0eukBvrpEyf7FJoY1NNN aiOQ== 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=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h17si11527727edb.89.2019.10.01.23.22.04; Tue, 01 Oct 2019 23:22:28 -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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729146AbfJBAww convert rfc822-to-8bit (ORCPT + 99 others); Tue, 1 Oct 2019 20:52:52 -0400 Received: from mga02.intel.com ([134.134.136.20]:47189 "EHLO mga02.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726931AbfJBAwv (ORCPT ); Tue, 1 Oct 2019 20:52:51 -0400 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Oct 2019 17:52:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,572,1559545200"; d="scan'208";a="194707403" Received: from unknown (HELO ubuntu) ([10.226.248.111]) by orsmga003.jf.intel.com with SMTP; 01 Oct 2019 17:52:50 -0700 Received: by ubuntu (sSMTP sendmail emulation); Wed, 02 Oct 2019 08:52:50 +0800 Message-ID: <1569977550.9826.7.camel@intel.com> Subject: Re: [PATCH] nios2: force the string buffer NULL-terminated From: Ley Foon Tan To: Wang Xiayang Cc: rppt@linux.vnet.ibm.com, linux-kernel@vger.kernel.org In-Reply-To: <20190805101712.22580-1-xywang.sjtu@sjtu.edu.cn> References: <20190805101712.22580-1-xywang.sjtu@sjtu.edu.cn> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT Date: Wed, 02 Oct 2019 08:52:30 +0800 Mime-Version: 1.0 X-Mailer: Evolution 3.18.5.2-0ubuntu3.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2019-08-05 at 18:17 +0800, Wang Xiayang wrote: > strncpy() does not ensure NULL-termination when the input string > size equals to the destination buffer size COMMAND_LINE_SIZE. > Besides, grep under arch/ with 'boot_command_line' shows > no other arch-specific code uses strncpy() when copying > boot_command_line. > > Use strlcpy() instead. > > This issue is identified by a Coccinelle script. > > Signed-off-by: Wang Xiayang Merged to v5.4-rc1. Thanks. Acked-by: Ley Foon Tan > --- >  arch/nios2/kernel/setup.c | 6 +++--- >  1 file changed, 3 insertions(+), 3 deletions(-) > > diff --git a/arch/nios2/kernel/setup.c b/arch/nios2/kernel/setup.c > index 6bbd4ae2beb0..4cf35b09c0ec 100644 > --- a/arch/nios2/kernel/setup.c > +++ b/arch/nios2/kernel/setup.c > @@ -123,7 +123,7 @@ asmlinkage void __init nios2_boot_init(unsigned > r4, unsigned r5, unsigned r6, >                 dtb_passed = r6; > >                 if (r7) > -                       strncpy(cmdline_passed, (char *)r7, > COMMAND_LINE_SIZE); > +                       strlcpy(cmdline_passed, (char *)r7, > COMMAND_LINE_SIZE); >         } >  #endif > > @@ -131,10 +131,10 @@ asmlinkage void __init nios2_boot_init(unsigned > r4, unsigned r5, unsigned r6, > >  #ifndef CONFIG_CMDLINE_FORCE >         if (cmdline_passed[0]) > -               strncpy(boot_command_line, cmdline_passed, > COMMAND_LINE_SIZE); > +               strlcpy(boot_command_line, cmdline_passed, > COMMAND_LINE_SIZE); >  #ifdef CONFIG_NIOS2_CMDLINE_IGNORE_DTB >         else > -               strncpy(boot_command_line, CONFIG_CMDLINE, > COMMAND_LINE_SIZE); > +               strlcpy(boot_command_line, CONFIG_CMDLINE, > COMMAND_LINE_SIZE); >  #endif >  #endif > > -- > 2.11.0 > > > ________________________________ > > Confidentiality Notice. > This message may contain information that is confidential or > otherwise protected from disclosure. If you are not the intended > recipient, you are hereby notified that any use, disclosure, > dissemination, distribution, or copying of this message, or any > attachments, is strictly prohibited. If you have received this > message in error, please advise the sender by reply e-mail, and > delete the message and any attachments. Thank you.