Received: by 2002:a05:6602:2086:0:0:0:0 with SMTP id a6csp4423520ioa; Wed, 27 Apr 2022 03:39:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzYX2Lra0Lv7p/Coo+CQRYFRXdHzFYHX0PbL4VadEw8tYzBs1TNojtw6DI6Iu6z1wSKRZZ2 X-Received: by 2002:a63:de53:0:b0:3aa:8b0:b690 with SMTP id y19-20020a63de53000000b003aa08b0b690mr23848266pgi.580.1651055949041; Wed, 27 Apr 2022 03:39:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1651055949; cv=none; d=google.com; s=arc-20160816; b=AzsSXUvs6vlktsl2+eFXC5nEnwGGBU6SD33SXLj3Hsx+Vq7ch+Vx4UqFFzb1xfmvd8 DEiC1SFnPMJ7d4E1/4pHevHmFdgGOBpSek82uB11+f0CWrc1fdZDubDvYckAEi7c9c3F 9c+BIIUUuIM/nz4IESbVO/yFWGaKNkpgjhEy6uhzDPyy1B/BKRYJGL7cHj3gfYaF94xU TM8tOJK1S4fmNCk9/FNAGiBV5mlpbpPkVMLGjmGu040PFT/hf+Lms9Rlnxo8ZSl8l2+n 5mEWH+yL8ewW1v+xBaP10C85MEisxPiUB1vXeXl6RWSrttW1jYsdbeMHqEh7vOxJCouu 3WeA== 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:dkim-signature; bh=7Vd79Y282uj8GnLQRXQvOoxbMKGwuxqHo8kRf4cU958=; b=YswQ4KV9QBTk/U7SNxItRAAaZiUKLRtdgN/0AMMVXj/NncNIhFe5YY8sVeP5IruvDf YEDFB0Wqa3lUWVBD5U06gJPxiz1LqS9sskRHYutUczV8PUBL6UBXXyOAG2/+9oMljuWQ 9eosaWvb08yhWXwVSDYjumPq90bX8K+4guJUF+t2qhgT/8Y93kNbvS+r192vHXHvJkeu 3gxAHi2X8ug9xVSXk/l42Pdo5LX+cyV80+fkF4FTRC2E3gRZE+AMyTIKR/mTNosmka6O YmLFKtoFPxp5m2aM0Kr4VLzSqHNDTAoMCVz3FvySaTl1t/KscuyH6qGI8BBcn4/CGFpZ vnSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iQWMWN8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id j6-20020a170902da8600b00153b2d16415si1503751plx.29.2022.04.27.03.39.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 27 Apr 2022 03:39:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iQWMWN8m; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 494C83D6CDD; Wed, 27 Apr 2022 02:49:54 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1356352AbiD0AA2 (ORCPT + 99 others); Tue, 26 Apr 2022 20:00:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47004 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1356288AbiD0AAU (ORCPT ); Tue, 26 Apr 2022 20:00:20 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68A0F4EA1E for ; Tue, 26 Apr 2022 16:56:54 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id y14so171508pfe.10 for ; Tue, 26 Apr 2022 16:56:54 -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=7Vd79Y282uj8GnLQRXQvOoxbMKGwuxqHo8kRf4cU958=; b=iQWMWN8mblU7AZgtWY+rZW8Z55g8FPr1ZFwzxsYu7RXa3DhTX2weqxgZjDVPTSDBSq hh7q8PIFIzX0UVjbAXwOTyOlQser4taBBwZ6NHC4L85PMu0aMFQbRvWJ2WNnKOwt0CcF ZaefjLWhDq6zS5jp3Ez2IPRw9RevbpBJSVE20= 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=7Vd79Y282uj8GnLQRXQvOoxbMKGwuxqHo8kRf4cU958=; b=TQNOn0y+aB+9WXRMesxjp2iUztFhJzDVHbCHuDl6mTMjn+OiYRQJLc5ANAc42z+hPU um59zEhG88YyV0aQzRG0qt443Z0bYOqUsWdBi3lizTVsGlBsfoFALgDUv9jyRPa53+xd j5YS3ZOM/sUFpLypflLl+CNw2moP56ttK3Okha1Dvkl40rVK/OjUF8WPhouWYiNoXfRf NnM8WPRMyM2UrE/lJevjmeYgw8Lz/he59rXfSegjM6gX2iwPAADvDbqaQQ9XGccX9l3k 5YHhQsgqhUpnh914NT22gBK3u4L4JjezG3q4PReK8AZXO9YrhOJGrueNmg+3ACDm3a+g 2Kkg== X-Gm-Message-State: AOAM530ZlScn9jL/ggx6dnMNZz5XAyLrPv1C3vjF1Ez5cqpZMvar+Q5n r5wpylUt/BJy5lT0v84Xf81VsA== X-Received: by 2002:a05:6a00:1152:b0:4be:ab79:fcfa with SMTP id b18-20020a056a00115200b004beab79fcfamr26844218pfm.3.1651017414417; Tue, 26 Apr 2022 16:56:54 -0700 (PDT) Received: from www.outflux.net (smtp.outflux.net. [198.145.64.163]) by smtp.gmail.com with ESMTPSA id n1-20020a17090a670100b001d96bc27a57sm73410pjj.54.2022.04.26.16.56.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 26 Apr 2022 16:56:53 -0700 (PDT) Date: Tue, 26 Apr 2022 16:56:53 -0700 From: Kees Cook To: Geert Uytterhoeven Cc: Dan Li , kbuild-all@lists.01.org, Linux Kernel Mailing List , kernel test robot Subject: Re: [kees:for-next/lkdtm 6/6] drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size Message-ID: <202204261653.91255EEE0@keescook> References: <202204170710.LwCV5Ec0-lkp@intel.com> <202204181515.FC6649DC81@keescook> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE autolearn=unavailable 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, Apr 26, 2022 at 03:03:33PM +0200, Geert Uytterhoeven wrote: > On Tue, Apr 19, 2022 at 9:20 PM Kees Cook wrote: > > On Sun, Apr 17, 2022 at 07:26:33AM +0800, kernel test robot wrote: > > > tree: https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git for-next/lkdtm > > > head: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 > > > commit: 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 [6/6] lkdtm: Add CFI_BACKWARD to test ROP mitigations > > > config: sparc-randconfig-r026-20220417 (https://download.01.org/0day-ci/archive/20220417/202204170710.LwCV5Ec0-lkp@intel.com/config) > > Just received a failure for m68k-allmodconfig on next-20220426: > > drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of > different size [-Werror=pointer-to-int-cast] > drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of > different size [-Werror=int-to-pointer-cast] > drivers/misc/lkdtm/cfi.c:62:37: error: cast from pointer to integer of > different size [-Werror=pointer-to-int-cast] > drivers/misc/lkdtm/cfi.c:62:10: error: cast to pointer from integer of > different size [-Werror=int-to-pointer-cast] > > > > compiler: sparc-linux-gcc (GCC) 11.2.0 > > > reproduce (this is a W=1 build): > > > wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross > > > chmod +x ~/bin/make.cross > > > # https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git/commit/?id=2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 > > > git remote add kees https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux.git > > > git fetch --no-tags kees for-next/lkdtm > > > git checkout 2e53b877dc1258d4ac3de98f496bb88ec3bf5e25 > > > # save the config file to linux build tree > > > mkdir build_dir > > > COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/misc/lkdtm/ > > > > > > If you fix the issue, kindly add following tag as appropriate > > > Reported-by: kernel test robot > > > > > > All warnings (new ones prefixed by >>): > > > > > > drivers/misc/lkdtm/cfi.c: In function 'set_return_addr_unchecked': > > > >> drivers/misc/lkdtm/cfi.c:62:37: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] > > > 62 | ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET)) > > > | ^ > > > drivers/misc/lkdtm/cfi.c:72:13: note: in expansion of macro 'no_pac_addr' > > > 72 | if (no_pac_addr(*ret_addr) == expected) > > > | ^~~~~~~~~~~ > > > > Hmm. I don't see why this is warning. The macro looks like untagged_addr(): > > > > #define untagged_addr(addr) ({ \ > > u64 __addr = (__force u64)(addr); \ > > __addr &= __untagged_addr(__addr); \ > > (__force __typeof__(addr))__addr; \ > > }) > > The offending macro is: > > #define no_pac_addr(addr) \ > ((__force __typeof__(addr))((__force u64)(addr) | PAGE_OFFSET)) > > On 32-bit, addr is a 32-bit pointer, which is cast to a 64-bit integer first, > then to a 32-bit pointer again. > All of these need intermediate casts to uintptr_t. As in this? #define no_pac_addr(addr) \ ((__force __typeof__(addr))((uintptr_t)(addr) | PAGE_OFFSET)) -- Kees Cook