From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E02AC4338F for ; Wed, 28 Jul 2021 08:39:12 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4E6FC60F9D for ; Wed, 28 Jul 2021 08:39:12 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 4E6FC60F9D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=ACULAB.COM Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:In-Reply-To:References: Message-ID:Date:Subject:CC:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=olpnV3uYe9PpCQM/b+4ot5jAFNMwelct+KFv9neS3bc=; b=sEv7oaoQ2LxBE/ qH2FblWvZz7nLv/Bt8mlCEYTHgCNMhbdmHdMbPi42hsdL4cBy/wjtG8Mbq76kq2z6j8mm/4bWnbMn XI16yFQHRweJir2SFbHjYs9I4BCoPBmKA+wr6joy4ZV5MqfJGInLZ3sh5OhnC2dGlhqXyyuRilnah Wka2iM9XBcGSME+lEsMtSdJmFQDij8uQi7iv01nJ8t4IVf5l4JTLvLL0S/76EO3tZcwWRNFt2vQPs JEX38Bi9P48okfZONniCn9x0+z6gwdmeK9AEMHKxpBo/5rrWj7Uid1rcMVCGAqgIyqqGMgBGYTmJB ZBEmZoyTYoliHBNLtKDg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8f3e-00HZoh-KE; Wed, 28 Jul 2021 08:36:54 +0000 Received: from eu-smtp-delivery-151.mimecast.com ([185.58.86.151]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1m8f3a-00HZna-9g for linux-arm-kernel@lists.infradead.org; Wed, 28 Jul 2021 08:36:52 +0000 Received: from AcuMS.aculab.com (156.67.243.121 [156.67.243.121]) (Using TLS) by relay.mimecast.com with ESMTP id uk-mta-175-gJF64QSnPY6TlszXg-ZCaA-1; Wed, 28 Jul 2021 09:36:46 +0100 X-MC-Unique: gJF64QSnPY6TlszXg-ZCaA-1 Received: from AcuMS.Aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) by AcuMS.aculab.com (fd9f:af1c:a25b:0:994c:f5c2:35d6:9b65) with Microsoft SMTP Server (TLS) id 15.0.1497.23; Wed, 28 Jul 2021 09:36:44 +0100 Received: from AcuMS.Aculab.com ([fe80::994c:f5c2:35d6:9b65]) by AcuMS.aculab.com ([fe80::994c:f5c2:35d6:9b65%12]) with mapi id 15.00.1497.023; Wed, 28 Jul 2021 09:36:44 +0100 From: David Laight To: 'Geert Uytterhoeven' , Len Baker CC: Kees Cook , Andy Gross , "Bjorn Andersson" , Magnus Damm , Santosh Shilimkar , "linux-hardening@vger.kernel.org" , linux-arm-msm , Linux Kernel Mailing List , Linux-Renesas , Linux ARM Subject: RE: [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy() Thread-Topic: [PATCH] drivers/soc: Remove all strcpy() uses in favor of strscpy() Thread-Index: AQHXgfS6PeASd7OmzkqPc7xYqoccEatYEvhA Date: Wed, 28 Jul 2021 08:36:44 +0000 Message-ID: <80f4574c9f6c4c6780735b0fffd83363@AcuMS.aculab.com> References: <20210725151434.7122-1-len.baker@gmx.com> In-Reply-To: Accept-Language: en-GB, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.107] MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=C51A453 smtp.mailfrom=david.laight@aculab.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: aculab.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210728_013650_648445_A643B87E X-CRM114-Status: GOOD ( 22.07 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Geert Uytterhoeven > Sent: 26 July 2021 09:03 > > Hi Len, > > On Sun, Jul 25, 2021 at 5:15 PM Len Baker wrote: > > strcpy() performs no bounds checking on the destination buffer. This > > could result in linear overflows beyond the end of the buffer, leading > > to all kinds of misbehaviors. The safe replacement is strscpy(). > > > > Signed-off-by: Len Baker > > Thanks for your patch! > > > --- > > This is a task of the KSPP [1] > > > > [1] https://github.com/KSPP/linux/issues/88 > > Any chance the almost one year old question in that ticket can be > answered? > > > drivers/soc/renesas/rcar-sysc.c | 6 ++++-- > > Reviewed-by: Geert Uytterhoeven > > But please see my comments below... > > > --- a/drivers/soc/renesas/r8a779a0-sysc.c > > +++ b/drivers/soc/renesas/r8a779a0-sysc.c > > @@ -404,19 +404,21 @@ static int __init r8a779a0_sysc_pd_init(void) > > for (i = 0; i < info->num_areas; i++) { > > const struct r8a779a0_sysc_area *area = &info->areas[i]; > > struct r8a779a0_sysc_pd *pd; > > + size_t area_name_size; > > I wouldn't mind a shorter name, like "n". > > > > > if (!area->name) { > > /* Skip NULLified area */ > > continue; > > } > > > > - pd = kzalloc(sizeof(*pd) + strlen(area->name) + 1, GFP_KERNEL); > > + area_name_size = strlen(area->name) + 1; > > + pd = kzalloc(sizeof(*pd) + area_name_size, GFP_KERNEL); > > if (!pd) { > > error = -ENOMEM; > > goto out_put; > > } > > > > - strcpy(pd->name, area->name); > > + strscpy(pd->name, area->name, area_name_size); You can just use memcpy(). David - Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales) _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel