Received: by 10.223.185.116 with SMTP id b49csp3165594wrg; Sun, 18 Feb 2018 16:03:07 -0800 (PST) X-Google-Smtp-Source: AH8x225OUckKa6LHgKkuV9FCfxLRV+H7aNL1d2hWe3GVhikIy6oQH1otr17RgQc2jC4BpLitZ+/l X-Received: by 10.98.79.65 with SMTP id d62mr12893291pfb.138.1518998587258; Sun, 18 Feb 2018 16:03:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518998587; cv=none; d=google.com; s=arc-20160816; b=fo2VLxUt4gKjUrJ33yr7CLkwUo7tZdH6+6ult5Zla6RNMLbQyf/WXTS+MstIBvGuvg eP20CO5AzwjDh6jKFgVkQyR9+OeRnSRkDWiPe5vmcQuHyeOIHLD/u3YaUr/LieimWqC1 /aeS7CI9m3+9pN0Y+les/bTVpReC6MLS7/d8/Y5Su4eMWHwkDUgCk9LFPa1fTEz/OA3Z AI42U8ti6Rt4XFstbyoszQFg4XWOFFitNziPmG6DGeVuC8+/MdtRmAbz8BirPaAYJMz1 oSVbj+Q/RVwZAEdO0FcczVqoEBOSe+EzIr6mwVknTXHC5lPuEGgzyEXlMoFQpXsSHakR gj1g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=tbXZOFa9IEQ6K6z3Yxsyb1sIM/BVA6Qe2xJNYiedYC0=; b=o91bc/dpImARtl74FdbC1LJcr24o1EuoAUwTWnzTeDXyQBzXwZub1Bc0ckLKOE/MQn 0Bc7yI36bljpFLmRmJ0S/eBr7J3FbeXd4xxfBLE5gI5i/Z6US0nEZ9WSwau4ZUJHMXRj tr27lNs52UvFR1/CTh5Jb419NohmuFmPWOKRud0dsioBYfftejO6xNpAhLJlQ1YA1qiR y7hxZaoMmuyTHnDXqU/sW3H36Me+UV3WV0huChwujVMifvzgAwd2bsM7TNwN8JHhGSrh rMlI66iDk6wYq78g7JrOUKlHrzzzRK/TqBMR0v9fQnmNeyv5fmpcMwWr87zf3rpP/uC9 IdxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NKQYiGL5; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p7-v6si2548689pls.41.2018.02.18.16.02.50; Sun, 18 Feb 2018 16:03:07 -0800 (PST) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NKQYiGL5; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751922AbeBSACN (ORCPT + 99 others); Sun, 18 Feb 2018 19:02:13 -0500 Received: from mail-qk0-f193.google.com ([209.85.220.193]:36244 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751652AbeBSACL (ORCPT ); Sun, 18 Feb 2018 19:02:11 -0500 Received: by mail-qk0-f193.google.com with SMTP id 15so10351599qkl.3 for ; Sun, 18 Feb 2018 16:02:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=tbXZOFa9IEQ6K6z3Yxsyb1sIM/BVA6Qe2xJNYiedYC0=; b=NKQYiGL5RduFEJdn3WyOfjgIjkNKdrpGSCbE/TZL+SYgmm/i27xcy5WIQGc2u/X8uD ywK13u2sDowAUAmV4a6tl/pdjkC7W+y+ilo0fnXNgGsu6BD4piXGZDlUv7xx6st2yqJQ /MgZJRsrTU//bdIhrBmC8bllyBN3jSPqXYy2j8tEfsbuAGZ4Spl1qYmq7Zbzuewbn5Iw Mdhq29LmbPtXnhTdDVR0J17EdHh7JyoOLH1bg05aHDTPwBfWFClebr8wgAqNCk6lhjEZ kDGcmqlc+OqtwsfJZtHOUPsqQyKi5/xE+lrAlL+GXTlE3Sap4IgNa8LVoLSlRmqRjVGg o4MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=tbXZOFa9IEQ6K6z3Yxsyb1sIM/BVA6Qe2xJNYiedYC0=; b=OeVxW0Y5/sC7j6z2LQkbICitqIoJMjpRvFm5upvyLf+LvRN+XzzQ5LNIZ1/oIW4PIu Q4IjvmNur+cyNtvNchgd6wnWnmTmKQRwSXwwkgbRlCfM1g8CEVidpwCfiSxYmZaB1VP0 HvW/nQQ2aLZFyRJpAkLQpSoGgl/vDYvzZZvy3P4eVAYkPrvwmPwnJmP4pLCl3zZGh8jB DDRfLuo39kWC9H7QRMZmw3r0kfGhwkTH2iVvEE0A2dKO7wdh0tjwCVmzf4Xbs6bagviH 9BzMGu/Oa8zdnNWFfoBSBGMNsHOYsPfeI7dLaMLuEDb3vJIxPZvpikj94UPzU0evwiHf 0d/g== X-Gm-Message-State: APf1xPDANlODn+kV7H/Z+T2MOH8+8T/rnpK3ReIDqCvJGkUExIEwQNx8 +zIwHnK28+/FxXJYlNRKYgCuL4Tnw/aYtm0O20I= X-Received: by 10.55.49.74 with SMTP id x71mr21702480qkx.133.1518998531125; Sun, 18 Feb 2018 16:02:11 -0800 (PST) MIME-Version: 1.0 Received: by 10.200.52.247 with HTTP; Sun, 18 Feb 2018 16:01:50 -0800 (PST) In-Reply-To: References: <20180217191035.gol4woxsgzpo4bfq@gmail.com> From: Miguel Ojeda Date: Mon, 19 Feb 2018 01:01:50 +0100 Message-ID: Subject: Re: [PATCH] Support the nonstring variable attribute (gcc >= 8) To: David Rientjes Cc: mingo@kernel.org, jpoimboe@redhat.com, Kees Cook , Andrew Morton , Thomas Gleixner , Geert Uytterhoeven , Greg KH , thomas.lendacky@amd.com, will.deacon@arm.com, linux-kernel , Willy Tarreau , Xiongfeng Wang , Arnd Bergmann Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 19, 2018 at 12:20 AM, David Rientjes wrote: > On Sat, 17 Feb 2018, Miguel Ojeda wrote: > >> From the GCC manual: >> >> The nonstring variable attribute specifies that an object or member >> declaration with type array of char or pointer to char is intended to >> store character arrays that do not necessarily contain a terminating NUL >> character. This is useful in detecting uses of such arrays or pointers >> with functions that expect NUL-terminated strings, and to avoid warnings >> when such an array or pointer is used as an argument to a bounded string >> manipulation function such as strncpy. >> >> https://gcc.gnu.org/onlinedocs/gcc/Common-Variable-Attributes.html >> >> Some reports are already coming to the LKML regarding these >> warnings. When they are false positives, we can use __nonstring to let >> gcc know a NUL character is not required; like in this case: >> >> https://lkml.org/lkml/2018/1/16/135 >> >> Signed-off-by: Miguel Ojeda >> Cc: Ingo Molnar >> Cc: Josh Poimboeuf >> Cc: Kees Cook >> Cc: Andrew Morton >> Cc: Geert Uytterhoeven >> Cc: Will Deacon >> Cc: Greg Kroah-Hartman >> Cc: David Rientjes > > I would have expected to have seen __nonstring used somewhere as part of > this patch. Do you mean to expand the commit message with an actual code example instead of the links to the docs and the discussion about the report? Otherwise, if you mean in the actual commit, I think in that case it should be a patch series, not a single commit. In any case, the key point here is to agree on the short-term policy: i.e. whether we want to disable the upcoming warning or try to take advantage of it (which not *necessarily* implies using __nonstring, there are other workarounds; though where applicable, __nonstring is probably the right thing to use). [By the way, CC'ing Xiongfeng, Willy and Arnd, since they were involved in the example report; sorry guys!]. Cheers, Miguel