Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp7739485rwp; Tue, 18 Jul 2023 22:32:55 -0700 (PDT) X-Google-Smtp-Source: APBJJlFjvXRXKDVbx1GaXeGRNXXK3xrn7ElSnVjosNd2jTMJE/PV1B3EInL0eJbNxeeVUnEkBesz X-Received: by 2002:a05:6a00:23c2:b0:680:fa5f:4ed6 with SMTP id g2-20020a056a0023c200b00680fa5f4ed6mr19775978pfc.27.1689744775048; Tue, 18 Jul 2023 22:32:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689744775; cv=none; d=google.com; s=arc-20160816; b=WhilBFGmqh8Vq/N8TmuVSJ1ZKK/ZuRJltXEQNCpjesGeFdGi0bJbd4rCHkmlJ7xtHx Zmxrc+T/gScXPZK1hP3+JJ2D6IJqkDJsUg6nPYbbfhba2Gubgn8+fZyZzR9KOPFV8PP+ f1ciyD2ITyywlVs+K2uelmIjaIYSXIB1458Os+F1FC/gAoXCEqY9wVLyqGQwAmjwbgtL gcDsh9H0P6TSMpYVZ9RN4yI+3QY76dz2V3hu7vJYJe9p9/xiBshBgqlcGDeAI76xUSxy watrX9LbyhCrv0t8ltTIka4vdEElz8nvusascPwdy/bawwBdiudaNyr21siRD1ZeZOz9 Hzug== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:organization:in-reply-to :content-transfer-encoding:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=xwW5M+quIG3YYPOtrpngr8AZk/V/DCOdqxzF/f8aiuU=; fh=h3KMI+TgbhpHnD/O+ZmPUnLmX222ZUuyhFWVQw8aw60=; b=FkmZIWGK8NUNcw7mzv1xyaSgZdF7t7ddfkATmgdHy9/i0S/d7Nf3FZ+GM5MrDtTgqa ViUgNDoMAVGidOCjdRBizWGk/qSKE5JBEBajISgTJ3AeBGOe1Tn9pfl+gOXa//dJZDP1 tb+134BYpTRjpKIoASiFs3sYbmvsc7uQwFI6MJEQbEBGxvCKbN8uSdrOHXfpBdLG4pHv 12tA3YcjPAJnGJAVZ+VBgU6KPwhpsGgaPJqbQVpY33rO2l9iW9yyukvqPtVPhJ2AxBtu DMMW0WjOQnLpLL6u2iT2QT2G5zqsTJMYtI95eyfkv8IftLFsw3lxMIBfOLHlHRGD6soi hPIw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="arii/z8v"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p26-20020a056a000a1a00b006785d3c33e9si2865244pfh.340.2023.07.18.22.32.42; Tue, 18 Jul 2023 22:32:55 -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; dkim=pass header.i=@intel.com header.s=Intel header.b="arii/z8v"; 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=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229731AbjGSF1I (ORCPT + 99 others); Wed, 19 Jul 2023 01:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229825AbjGSF1G (ORCPT ); Wed, 19 Jul 2023 01:27:06 -0400 Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 262AA1FF6 for ; Tue, 18 Jul 2023 22:26:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1689744422; x=1721280422; h=date:from:to:cc:subject:message-id:references: mime-version:content-transfer-encoding:in-reply-to; bh=7XPVa2B9jBhfsmExj6J5l6vD5LjQjir0Va+s/j090YU=; b=arii/z8vC1Ii+mKfKU7g4syaPJ6+gYzDNBOdpjiPp99+BdgLbGXziguW rNjaaUmQyURfZQMnEwV4wbX7KBPcIEgCES0RwsFjCqeZylDQSHq2cbbMM msToX7xdCc6BZvSa2mHVL/wA9DVxE4Vj6bxGCaOqnsHHph3+fCzZj63xY qM1FhKGO/qBjcd8wDw0+0iS4l7XUBejtrj3yK7nKz8DpJZGSJrWpcBNig 2NmBZDa0FBrQfg0vHhUe490gSa48eA+KJdi6j0SmIrpled+xIDqtofGVQ 2gBPsEJaG8qHr4o3FmEX5NufvSZ4E+/bJBxmyDJd8DMgeBrQytgaUIKPT w==; X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="430141128" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="430141128" Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jul 2023 22:26:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6600,9927,10775"; a="793882577" X-IronPort-AV: E=Sophos;i="6.01,215,1684825200"; d="scan'208";a="793882577" Received: from smile.fi.intel.com ([10.237.72.54]) by fmsmga004.fm.intel.com with ESMTP; 18 Jul 2023 22:26:57 -0700 Received: from andy by smile.fi.intel.com with local (Exim 4.96) (envelope-from ) id 1qLziC-00D4M4-0o; Wed, 19 Jul 2023 08:26:56 +0300 Date: Wed, 19 Jul 2023 08:26:56 +0300 From: Andy Shevchenko To: Kees Cook Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 1/1] seq_file: Replace strncpy()+nul by strscpy() Message-ID: References: <20230717093332.54236-1-andriy.shevchenko@linux.intel.com> <168963536094.1395996.315062356944871422.b4-ty@chromium.org> <202307182147.A5B81B67D@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <202307182147.A5B81B67D@keescook> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 Tue, Jul 18, 2023 at 10:00:24PM -0700, Kees Cook wrote: > On Mon, Jul 17, 2023 at 04:09:23PM -0700, Kees Cook wrote: > > On Mon, 17 Jul 2023 12:33:32 +0300, Andy Shevchenko wrote: > > > Privided seq_show_option_n() macro breaks build with -Werror > > > and W=1, e.g.: > > > > > > In function ‘strncpy’, > > > inlined from ‘ocfs2_show_options’ at fs/ocfs2/super.c:1520:3: > > > include/linux/fortify-string.h:68:33: error: ‘__builtin_strncpy’ output may be truncated copying 4 bytes from a string of length 4 [-Werror=stringop-truncation] > > > 68 | #define __underlying_strncpy __builtin_strncpy > > > | ^ > > > include/linux/fortify-string.h:151:16: note: in expansion of macro ‘__underlying_strncpy’ > > > 151 | return __underlying_strncpy(p, q, size); > > > | ^~~~~~~~~~~~~~~~~~~~ > > > cc1: all warnings being treated as errors > > > > > > [...] > > > > Applied, thanks! > > > > [1/1] seq_file: Replace strncpy()+nul by strscpy() > > https://git.kernel.org/kees/c/c30417b20f49 > > Gah, I dropped this from my tree since it was actually wrong[1]. This is an > ugly corner case with strscpy vs strncpy: the cast be32 from hfs/hfsplus[2] > looks unterminated to strscpy, so it would return -E2BIG, but really > FORTIFY noticed the over-read (strscpy is correctly checking the 5th > byte for NUL). > > So... I think we need to fix seq_show_option_n() using memcpy+NUL, drop > the ocfs2 usage, and clarify that the seq_show_option_n() docs mean > "n means _exactly_ n bytes"... Sounds like a plan! Please go ahead with that. My intention is to make eventually build kernel with `make W=1` when CONFIG_WERROR=y. > [1] https://lore.kernel.org/lkml/0000000000000a88cb0600ccef54@google.com/ > [2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/fs/hfsplus/options.c?h=v6.4#n221 -- With Best Regards, Andy Shevchenko