From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-11.1 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47745C433EF for ; Thu, 9 Sep 2021 15:54:01 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id DDA1D610CE for ; Thu, 9 Sep 2021 15:54:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org DDA1D610CE Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 573406B006C; Thu, 9 Sep 2021 11:54:00 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 521F36B0072; Thu, 9 Sep 2021 11:54:00 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 41107900002; Thu, 9 Sep 2021 11:54:00 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0108.hostedemail.com [216.40.44.108]) by kanga.kvack.org (Postfix) with ESMTP id 2FA5F6B006C for ; Thu, 9 Sep 2021 11:54:00 -0400 (EDT) Received: from smtpin31.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay02.hostedemail.com (Postfix) with ESMTP id CD21E2310C for ; Thu, 9 Sep 2021 15:53:59 +0000 (UTC) X-FDA: 78568480998.31.E95B6C6 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) by imf29.hostedemail.com (Postfix) with ESMTP id 73FDD90001BC for ; Thu, 9 Sep 2021 15:53:59 +0000 (UTC) Received: by mail-pl1-f180.google.com with SMTP id j2so1349439pll.1 for ; Thu, 09 Sep 2021 08:53:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=PYofzyFCA7QGI20GFVhQ2s4HhAyVr+RWX/4nFmozl0Q=; b=SiEQlxzDF88Y9lsrZ+iQmY4Ap3N/k1ZcPrD2YEd2PMXNRboD2rP11qAZxjpSsyV/2c ElO6f3T+ytv0ZN+L+suLWUovRSTsFfzZq0XNFCpXm95KoRtukUVzIQYyuaOUJExnHqyV EZdNt459xWMB1IAz9JrpTOLzhgRMa2h/jzn6s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=PYofzyFCA7QGI20GFVhQ2s4HhAyVr+RWX/4nFmozl0Q=; b=i4tpUCkaTk2cLRVMJceofTMIEh/mEbt1XWjzUli7cAzRT3bm6smUYaurOLsSMRsJ71 lVSY2H10mrcwJ7RDHDzZKzMOV+qVEzqFHMxgBEFNElefFrsVtkHCPOMbeCUqG06CMo/j lmTE/kx0kIW3F+7drdBNkVeojgV9Rwr2ZvbPSyem7DT6C3bpxCt23FhnN/ETU1k/NQQA D7Zzb/VWPhqHnJhw5nykLacPkh2z4DqY2sTOiAPTekiGsOOiqHdQabMtHvZauHU2RURK woxT33V4Y8G1EvgkTlPPbHHWqw1EOHJZN/RxzLOC0z6x28UhuxZb34zZaiLjjqT5docE Op3A== X-Gm-Message-State: AOAM530VfsPoIQOtA6oUGXsiaCIhTQCqX7mOwDWMGP8JVH9fxNKXMjqn W6gMQZjI2uH4KljRvFyz3TthqQ== X-Google-Smtp-Source: ABdhPJzqhL59pizCNls4DANCyXTe4VckB37ZW2heZlEhP3seUxoOpvTryBWpmPNiY5NfX/LIO5vmvg== X-Received: by 2002:a17:90a:53:: with SMTP id 19mr4265443pjb.159.1631202838456; Thu, 09 Sep 2021 08:53:58 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id l13sm2470481pji.3.2021.09.09.08.53.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 09 Sep 2021 08:53:57 -0700 (PDT) Date: Thu, 9 Sep 2021 08:53:56 -0700 From: Kees Cook To: kernel test robot Cc: kbuild-all@lists.01.org, Linux Memory Management List , Daniel Micay , Andrew Morton Subject: Re: [linux-next:master 12105/12116] include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small Message-ID: <202109090853.369D71E1@keescook> References: <202109091134.FHnRmRxu-lkp@intel.com> <202109090843.9E28C97@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <202109090843.9E28C97@keescook> Authentication-Results: imf29.hostedemail.com; dkim=pass header.d=chromium.org header.s=google header.b=SiEQlxzD; spf=pass (imf29.hostedemail.com: domain of keescook@chromium.org designates 209.85.214.180 as permitted sender) smtp.mailfrom=keescook@chromium.org; dmarc=pass (policy=none) header.from=chromium.org X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 73FDD90001BC X-Stat-Signature: 6fxduknem7iidfyjj11i15pq64i16han X-HE-Tag: 1631202839-974329 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Thu, Sep 09, 2021 at 08:45:56AM -0700, Kees Cook wrote: > On Thu, Sep 09, 2021 at 11:49:55AM +0800, kernel test robot wrote: > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git master > > head: 999569d59a0aa2509ae4a67ecc266c1134e37e7b > > commit: f5b1a5d922d3199e0637349239b43aed6c7656b9 [12105/12116] mm/vmalloc: add __alloc_size attributes for better bounds checking > > config: i386-randconfig-a002-20200329 (attached as .config) > > compiler: gcc-9 (Debian 9.3.0-22) 9.3.0 > > reproduce (this is a W=1 build): > > # https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=f5b1a5d922d3199e0637349239b43aed6c7656b9 > > git remote add linux-next https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git > > git fetch --no-tags linux-next master > > git checkout f5b1a5d922d3199e0637349239b43aed6c7656b9 > > # save the attached .config to linux build tree > > mkdir build_dir > > make W=1 O=build_dir ARCH=i386 SHELL=/bin/bash drivers/rapidio/devices/ > > > > If you fix the issue, kindly add following tag as appropriate > > Reported-by: kernel test robot > > > > All errors (new ones prefixed by >>): > > > > In file included from arch/x86/include/asm/preempt.h:7, > > from include/linux/preempt.h:78, > > from include/linux/spinlock.h:55, > > from include/linux/mm_types.h:9, > > from include/linux/buildid.h:5, > > from include/linux/module.h:14, > > from drivers/rapidio/devices/rio_mport_cdev.c:13: > > In function 'check_copy_size', > > inlined from 'copy_from_user' at include/linux/uaccess.h:191:6, > > inlined from 'rio_mport_transfer_ioctl' at drivers/rapidio/devices/rio_mport_cdev.c:983:6: > > >> include/linux/thread_info.h:213:4: error: call to '__bad_copy_to' declared with attribute error: copy destination size is too small > > 213 | __bad_copy_to(); > > | ^~~~~~~~~~~~~~~ > > > transfer = vmalloc(array_size(sizeof(*transfer), transaction.count)); > if (!transfer) > return -ENOMEM; > > if (unlikely(copy_from_user(transfer, > (void __user *)(uintptr_t)transaction.block, > array_size(sizeof(*transfer), transaction.count)))) { > > Uhhhmm... allocation size and copy size are identical... > > array_size(sizeof(*transfer), transaction.count) > array_size(sizeof(*transfer), transaction.count) This appears to be an optimization(?) bug in GCC 9.3. This warning (correctly) does not appear in later versions. -- Kees Cook