Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3353213rwa; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) X-Google-Smtp-Source: AA6agR5+NS0GvzcDteVQZHvNL9XBb72ahTxNWqV70w38RVuX7vtVbNiEcVHUNpdkeJGZ4TfsDZNh X-Received: by 2002:a05:6402:11cb:b0:43c:c7a3:ff86 with SMTP id j11-20020a05640211cb00b0043cc7a3ff86mr3089382edw.383.1661250306562; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661250306; cv=none; d=google.com; s=arc-20160816; b=DuMGWNlTwsdjfcbYzRp+5VOEta8w9LY8I+0ysBaVeOG9tN01Zrh1sdge5GokfQjBkR 4G86qnwGPJ1U1/Cp7Ejib11JC56otCY8jKwnmHvWxE6AnnUOA/fpOmBrIISN2W9tOsHj GUgjo0WwFOVBCqetsoazcEQp7dmZp3X462LzTfeCRml3ErjtasKcTE75D7XWWCyA3bxs KdZjpGJWT8T1274ROFftpmxuVWnCTkewhOBRQVQN6+mUjYwUsI79ISBP/yuXwpPPW3Ma C/CgOPRJ6iT/J3D5Ij06qUrx6YurLvPaU7ZsS5y2sn7sKga8eJvPmfspPY4rvXPh/rAi dHCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=Xg+nFnuqRTxXCQ/Pxya3Fb30kFvg1Ei1z6Q6BCOMjvM=; b=LItJ47ipT3cS55B8lKtvDyeOUp+OGZIVRjeriggYv4xVXYXHMVCPiDRFAQmuc39zOg o7NTogp69tO114uRnWAW0GC4P72ri8HC0UP2NWGR+bLGp/5IdIsm1gO6u5FsJtpdUkov h5jIM8mOV8qQkIZBD8OeQU/iIP/MfrB/BoT3TNi9KdTG8eVLNKoa8YbwIRjp1eaADG/p sSpr/6RDw5ImFTol3SWt7IzfXy3GCpH0fxjIGUXiMNcILBi9VJL8yKPW5bZnOsRt2dUZ DBrsY9RWXj6ma5+uSd5EJaRQJKp+bt4Rhr0Xp/Xrl/ETT7xydI043n2zYzHSIZai+C/u X0qA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id qk34-20020a1709077fa200b0073d6472b3ccsi8849394ejc.214.2022.08.23.03.24.40; Tue, 23 Aug 2022 03:25:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=arm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354947AbiHWKWd (ORCPT + 99 others); Tue, 23 Aug 2022 06:22:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35350 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353260AbiHWKLI (ORCPT ); Tue, 23 Aug 2022 06:11:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D8E87E829; Tue, 23 Aug 2022 01:56:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id B0507B81C28; Tue, 23 Aug 2022 08:56:15 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D8700C433D7; Tue, 23 Aug 2022 08:56:12 +0000 (UTC) Date: Tue, 23 Aug 2022 09:56:12 +0100 From: Catalin Marinas To: Linus Torvalds Cc: Steve French , CIFS , LKML , linux-arch Subject: Re: strlcpy() notes (was Re: [GIT PULL] smb3 client fixes) Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-6.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, Aug 21, 2022 at 11:13:28AM -0700, Linus Torvalds wrote: > It's also worth pointing out that the kernel implementation of > 'strscpy()' will not do the chunk-sized accesses across an unaligned > page boundary. So it won't actually take a page fault past the > terminating NUL character, but if you pass it an 'N' that is bigger > than the source buffer, and you have sub-page faults in the kernel, we > might need to do some further work in this are. Catalin? We can probably hit sub-page faults if the function reads past the end of a string. Strange that we haven't hit any so far (well, it needs KASAN_HW_TAGS enabled, it doesn't get as much coverage). With load_unaligned_zeropad(), the arm64 implementation disables tag checking temporarily. We could do the same with read_word_at_a_time() (there is a kasan_check_read() in this function but it wrongly uses a size of 1). I'll send a patch but most likely next week (I'm still on holiday). -- Catalin