Received: by 2002:ac0:aed5:0:0:0:0:0 with SMTP id t21csp3125353imb; Tue, 5 Mar 2019 01:20:22 -0800 (PST) X-Google-Smtp-Source: APXvYqxR3bmClKz5o2fxIbdq0Q9ClcEtgqi6mFwq3+4/CmBt/4pAbUMCl88a+0CvBqjnIAPTIC8U X-Received: by 2002:a63:fe58:: with SMTP id x24mr538707pgj.255.1551777622387; Tue, 05 Mar 2019 01:20:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1551777622; cv=none; d=google.com; s=arc-20160816; b=Dh7BuJTTXbP+cJu8bDiMXLs8t0JgxpBxD7Oe1ilpWQta1z3xPRpHATXosVK0JQ+wnr cVwYomA+Sf/AUy29yaiSqQ+n2mV/wkwnB/9eV7i7WfvSqI6EgVVSQGJvS8nYo5+rmM39 iwGwz4yAhU/p91W5LbFOiGK2rQCS0D9obwWnJSqlyw6Xp/5EMqdInzRiNUO/tUcDMFPA 90XWwC1WkViXqdeZfZei6aWN/v3pfGn/VeP5DA1fpqku1nzhgpxVW/PKyvBGBjB0t6fa 6i5sngDaMfZPFuITvugT47+d/ZQkHjDmMvHDfK7KIbKBWMvRrY+tWmdAe1bqFcgp4SV1 mnrQ== 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 :in-reply-to:references:mime-version; bh=6KWSQPdEAOEqKIAwJE+G/lhn/QeIrYHYHAUihUgH74c=; b=SeAL9J3yb5NXNNYkTuoBydL2wnC0nDt/atKoxb36sSrXBjePEeA7o5oSnFuUSLTYKl vKhtD5k06NYye90ZBJP8byecGe7bNP+k1s2mJPt8uU4VrUoTA2EIUgpgiH0iRSYiFrIB Ci0l4DLHzWhUm8XUw604RifFNFZX0Qcr8B3EEkfcXeJGMPEtvSOg9stZQ/J1F8RA9jTf NksRIpkXOxIwu/H6E0RIsJzEXuP3vQM4f36r2iTJbPfVO9c5KEtfKIN0jDTI/+dCglsl ZMi24d3Lh+M65D3xnysTGO94rv+O9BvOmi6mDGSFzi/JSB0FKhZbw6TRvf3oWCyXo06q ikyA== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k1si7465189pgg.215.2019.03.05.01.20.06; Tue, 05 Mar 2019 01:20:22 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726657AbfCEJDz (ORCPT + 99 others); Tue, 5 Mar 2019 04:03:55 -0500 Received: from mail-ua1-f68.google.com ([209.85.222.68]:45967 "EHLO mail-ua1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726069AbfCEJDz (ORCPT ); Tue, 5 Mar 2019 04:03:55 -0500 Received: by mail-ua1-f68.google.com with SMTP id u1so7060525uae.12 for ; Tue, 05 Mar 2019 01:03:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=6KWSQPdEAOEqKIAwJE+G/lhn/QeIrYHYHAUihUgH74c=; b=fvdtC+/22XgjgQfjAZWZTkAGv0Z9IjcYtmdtliV0F9LuMovA2sS3vE+pLMLR5Y+HaR LM6eWaUk4X6ZewiS7KRk5WpyG6KbN51AgxLQXLGdBcspqCLCtn5M8pMhXc/Neywgo3As C/7MCjq/kgBkhOgs7+2kBgF64g04i9RBKn1LrXpOV4dAy60Iio31DXdlLPRQys4/JVSs 678+iP/49EMbyqmrZ7fseXQ/QI2yDC61hMrbXr/+Ru5WhoS8sDoVoJWECYcaX6dzhgWb jgBqOz9R34YgnF0VMopNtQSitkZZ0R2uRuR1HWhmbTNZIx8dHRrhx1Q8/+4lSzrzYYYs JYFw== X-Gm-Message-State: APjAAAXv5bf/0x2chlCpkH/drZCtu7ohuFfJ5mHKHNEb9Hyg1vHp6llu VfOHfJBMhKSehVfyfsLKF1GBLz+g+wgtZD1dwOU= X-Received: by 2002:a67:8588:: with SMTP id h130mr572690vsd.11.1551776633545; Tue, 05 Mar 2019 01:03:53 -0800 (PST) MIME-Version: 1.0 References: <201903042049.npxcZzps%fengguang.wu@intel.com> In-Reply-To: From: Geert Uytterhoeven Date: Tue, 5 Mar 2019 10:03:41 +0100 Message-ID: Subject: Re: [m68k:master 1174/1174] arch/m68k/include/asm/string.h:72:25: warning: '__builtin_memcpy' forming offset 8 is out of the bounds [0, 7] To: Finn Thain Cc: kbuild test robot , kbuild-all@01.org, linux-m68k , Arnd Bergmann , Linux Kernel Mailing List 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 Hi Finn, On Tue, Mar 5, 2019 at 9:58 AM Finn Thain wrote: > On Tue, 5 Mar 2019, Geert Uytterhoeven wrote: > > On Tue, Mar 5, 2019 at 3:58 AM Finn Thain wrote: > > > On Tue, 5 Mar 2019, Finn Thain wrote: > > > > Looks bogus to me. > > > > > > > > If you change memcpy to __builtin_memcpy, then we avoid the macro and the > > > > warning changes to, > > > > > > > > ./include/linux/string.h:456:3: warning: '__builtin_memcpy' forming offset [7, 8] is out of the bounds [0, 6] [-Warray-bounds] > > > > __builtin_memcpy(dest, src, dest_len); > > > > > > > > The compiler has nothing to complain about here. dest is known to be > > > > id->fr and dest_len is known to be sizeof(id->fr). > > > > > > > > The error message indicates that gcc has applied the bounds [0, 6] to dest > > > > when in fact those are the bounds for src. > > > > > > > > > > My mistake. GCC is right, it seems memcpy will read past the end of > > > "5.0.0+". > > > > But only if the else branch is taken, which is not the case. > > > > You and I know that, because we can see what values get passed to > memcpy_and_pad(). But how is gcc to know that? Gcc also sees (partly) what values get passed, else it would not give that warning. Still, should gcc give warnings based on branches that may or may not be taken? I guess there are lots of cases in the kernel where this could lead to false positives. Gr{oetje,eeting}s, Geert -- Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds