Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752574AbdLLKTW (ORCPT ); Tue, 12 Dec 2017 05:19:22 -0500 Received: from smtp-out6.electric.net ([192.162.217.181]:63341 "EHLO smtp-out6.electric.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752307AbdLLKTU (ORCPT ); Tue, 12 Dec 2017 05:19:20 -0500 From: David Laight To: "'Andrey Ryabinin'" , Kees Cook , Dmitry Vyukov CC: Eryu Guan , LKML , "Andrew Morton" , Chris Metcalf , Alexander Potapenko , Linus Torvalds Subject: RE: [PATCH] lib/string: avoid reading beyond src buffer in strscpy Thread-Topic: [PATCH] lib/string: avoid reading beyond src buffer in strscpy Thread-Index: AQHTcp7d/61K3kzOfky3+ce3ZlifIqM/f2Ig Date: Tue, 12 Dec 2017 10:19:34 +0000 Message-ID: <2a9ca72e28ba44198f07f4e412970ad9@AcuMS.aculab.com> References: <20171207113324.24388-1-eguan@redhat.com> <9f0a9cf6-51f7-cd1f-5dc6-6d510a7b8ec4@virtuozzo.com> <46584b52-f2f2-a602-1ae6-cfa0e321324a@virtuozzo.com> In-Reply-To: <46584b52-f2f2-a602-1ae6-cfa0e321324a@virtuozzo.com> Accept-Language: en-GB, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-exchange-transport-fromentityheader: Hosted x-originating-ip: [10.202.205.33] Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 X-Outbound-IP: 156.67.243.126 X-Env-From: David.Laight@ACULAB.COM X-Proto: esmtps X-Revdns: X-HELO: AcuMS.aculab.com X-TLS: TLSv1.2:ECDHE-RSA-AES256-SHA384:256 X-Authenticated_ID: X-PolicySMART: 3396946, 3397078 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by nfs id vBCAJRAU012567 Content-Length: 526 Lines: 15 From: Andrey Ryabinin > Sent: 11 December 2017 16:44 ... > I suppose that depends on which one strscpy() caller you'd want to test. > Briefly looking at all current users, it doesn't look like they process huge amounts > of data through strscpy(), thus we shouldn't suffer from a slight > performance degradation of strscpy(). Don't most of the fast string functions use the same kind of optimisations. strlen() is very likely to do 64 bit reads and then shifts (etc) to determine whether any of the bytes are zero. David