Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp746822lqh; Thu, 28 Mar 2024 15:27:01 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXkJbPupIqMnQ04RXSO0BgdUBysnDu8W+rrLzZCyHh6iB6optHuiK3/rxq/kLWlGfrH9lv1sO8pRekxKcuriKPQfK6c1bT7B2KQPmUeeA== X-Google-Smtp-Source: AGHT+IEfLJFLquWeqdCmYv8vuE21lmBiv9piXzQtIhH4jxiVESM2ooP7H74s3xcQTbGB8BKKZsrU X-Received: by 2002:a05:6a20:17a7:b0:1a0:d103:7030 with SMTP id bl39-20020a056a2017a700b001a0d1037030mr479603pzb.32.1711664821406; Thu, 28 Mar 2024 15:27:01 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711664821; cv=pass; d=google.com; s=arc-20160816; b=Jv8j08CA6luiSj/aKvTEZGIjaZk08ypC7nkYrz0VLLFABfYBeIy0Vzoh5gyUiIq7yy 9f2Q+1XfXe6vawuADChFgI9ptnnLggRxtoeYOWptCwdOjPBxbuf+PQJpKUj/pLc0jAPk uBUuYSYAKvzSaTaylsIMxKej2d4bkJ1PL+gaA1D+jJLeHgC4wk28xJPxgJgW0unpl4jL ewyMxZ6r3ID0mwAdLvtXEtj0/OIniLd9qFcZHopngzL3YD8BmfymP+OdKcWJQMw/QNZa E1K8c9VmNrxHi0jfEWcVbwHsrqLDd1DMNYKRrnOJ70qZPxBQQmdD2f8AraHOrZPWcYyC 17kg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=F/OjdkXwLEp7mczzswJbuZjPn4dGgroiJ8sIvpa89YE=; fh=AhfMWw5UrLBcOoJveFpX+cW1Z5OJQhDpW5xR4SqOo+k=; b=ejNNWE848jh67HAgVpRdgOgwIdNxp6fUCKTLpJ3LBMeJtPSW72NFvEkQP5wAeMtTVm std4GyKFIGhquUPHrx2qq3Q3iUaB7i252qXVv3RhcaJ65j1ucurfVRoTZJXDrZjuGpdR pxbxcgvpRcWjbCLoTZxyn9LF/L/0OT1QY9qasqF68zSwx5OiT6KMxJKAEBDCUJGbACCS gEyPH4JaW57gl/ATqjLJXIWijqgCEbYYXejRs9uObTZVxuCimhEHuJc9koqw8WHqKfAG FRylcnz9nh+HPz+GOQ24UW80tdMaQS6RJO6TNmhkfwezqIrVh/CHG94En1JWmAGGoP8a V8NA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="j1mhqT/S"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id b1-20020a056a000cc100b006ead14a16dcsi2470984pfv.17.2024.03.28.15.27.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 28 Mar 2024 15:27:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-123772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20230601 header.b="j1mhqT/S"; arc=pass (i=1 spf=pass spfdomain=google.com dkim=pass dkdomain=google.com dmarc=pass fromdomain=google.com); spf=pass (google.com: domain of linux-kernel+bounces-123772-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-123772-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id DF93EB24132 for ; Thu, 28 Mar 2024 22:23:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 319D4132805; Thu, 28 Mar 2024 22:22:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="j1mhqT/S" Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com [209.85.208.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A8F7313A3E7 for ; Thu, 28 Mar 2024 22:22:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.54 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711664552; cv=none; b=EMe+bpWMeCX9Q1zkl1++xXMjTcMwO4KoTiMf5/jc+tiak8i8W/JQDhCbz2Jgn5nmdy73XrahCkDw1CN/M0IdIWnxS5JpH03nbsunWJqzAoKZTOA8V3K8JCENuaweUTFJbHDWJc9nT7OD118opilk17whM6kYY9829QkPQRtY+5Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711664552; c=relaxed/simple; bh=pgT/xSr/q7YOUPevv2EeewjHySxRn4YCFK6IyZ/aNb0=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=OYvrLAPWhh4C0IjGzkqPXhaVl9kMzLjcetLYe9F25ujISD3TgtTmhEt6rwjJn2djSBoWKR07O9RyhcdxqsCQEYtlIorujIDiTO4VyYYIVG2U2rTN40zDAvCQ7Nh2GDedqZ0KD24PakrL2lKtzkondpB6XdQ2zKJnlIxf5lIe5Tk= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=j1mhqT/S; arc=none smtp.client-ip=209.85.208.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Received: by mail-ed1-f54.google.com with SMTP id 4fb4d7f45d1cf-56c147205b9so2594716a12.0 for ; Thu, 28 Mar 2024 15:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20230601; t=1711664548; x=1712269348; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=F/OjdkXwLEp7mczzswJbuZjPn4dGgroiJ8sIvpa89YE=; b=j1mhqT/SyNftpjfNH+zYEEP9coHGcwBWWQy/ZSkTjfvAw3rA19DMTGMJiwNV3HdhUy eNUFWhiedCnTiuIp04Dms8Fr6D7OH5YRFeGZZzUv9ZsuZD4nL+3e/cA4l1MPR2SbezvJ sFLCzZ0OUW56mQaCkqV+wu8GcI8C6+BDQNexgcqbADDnIR5ok3GtzkkMpd5EO4OA3vdA /MQVFKxjI6/3knvDHqZYGsG04bLtLFuCUbrBYRHpPl6T1nN3y4FGLHi2OSOdDKcEZ1lT AgtX/QwNA6h/Esdg4Yh+w2uRRgvWOofOF6YgOawUgg2fvTDA37hsJnIXFTMdwGixGgy7 9TJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711664548; x=1712269348; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=F/OjdkXwLEp7mczzswJbuZjPn4dGgroiJ8sIvpa89YE=; b=Fz7VMBiYsJksfyIJm8N9SjmRSE6btGVdSjz031orH13r3ABBcwARuWFz4lVlgok3SU qA/7U39blwx1vSeRiDs5TilyS4CyLLi2+nAM54IHoMqSCAVlV8q05oE0VJ0R9H/hnGei kjsnmKu6we/Ypiyt3qI+Dbyud/wFVbdY+0PXnl7Ab4uxLqDtATD+ONrid7Fm0NCC7oNy XErKIjBTkMnZmhe5BylOLwjkHdh1v1vQoaSOFUylORFQxJz6CVISzsjiFWR01+GBdgfh q+Nu5FRR2Zw03dw3G0eLkPnsYprvTcNF1huf0XmHBzaZswWM4onfbL3C5qg36XQAeMHt eR3g== X-Gm-Message-State: AOJu0Yy8qBDxje9m1itMEmC0UCfCzQOECnommLtXS4H4T+qPDizAAjyI zHlxLUEMNS4+ABSQ/V0zJ+JCqeudCjRP+jr/GiTRbdcLvaser7I1/Q+I7UVz0ZNNKE+IemtkITc rtFFj92MBPSNVGGyc83sPlP0G9rp749YMHQGJ X-Received: by 2002:a50:9feb:0:b0:56c:53b2:9e32 with SMTP id c98-20020a509feb000000b0056c53b29e32mr527053edf.13.1711664547964; Thu, 28 Mar 2024 15:22:27 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240328143051.1069575-1-arnd@kernel.org> <20240328143051.1069575-5-arnd@kernel.org> In-Reply-To: <20240328143051.1069575-5-arnd@kernel.org> From: Justin Stitt Date: Thu, 28 Mar 2024 15:22:16 -0700 Message-ID: Subject: Re: [PATCH 4/9] kcov: avoid clang out-of-range warning To: Arnd Bergmann Cc: linux-kernel@vger.kernel.org, Nathan Chancellor , Arnd Bergmann , Dmitry Vyukov , Andrey Konovalov , Nick Desaulniers , Bill Wendling , Andrew Morton , kasan-dev@googlegroups.com, llvm@lists.linux.dev Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Thu, Mar 28, 2024 at 7:31=E2=80=AFAM Arnd Bergmann wro= te: > > From: Arnd Bergmann > > The area_size is never larger than the maximum on 64-bit architectutes: > > kernel/kcov.c:634:29: error: result of comparison of constant 11529215046= 06846975 with expression of type '__u32' (aka 'unsigned int') is always fal= se [-Werror,-Wtautological-constant-out-of-range-compare] > if (remote_arg->area_size > LONG_MAX / sizeof(unsigned lo= ng)) > ~~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~= ~~~ > > The compiler can correctly optimize the check away and the code appears > correct to me, so just add a cast to avoid the warning. > > Signed-off-by: Arnd Bergmann Reviewed-by: Justin Stitt > --- > kernel/kcov.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/kernel/kcov.c b/kernel/kcov.c > index f9ac2e9e460f..c3124f6d5536 100644 > --- a/kernel/kcov.c > +++ b/kernel/kcov.c > @@ -627,7 +627,8 @@ static int kcov_ioctl_locked(struct kcov *kcov, unsig= ned int cmd, > mode =3D kcov_get_mode(remote_arg->trace_mode); > if (mode < 0) > return mode; > - if (remote_arg->area_size > LONG_MAX / sizeof(unsigned lo= ng)) > + if ((unsigned long)remote_arg->area_size > > + LONG_MAX / sizeof(unsigned long)) > return -EINVAL; > kcov->mode =3D mode; > t->kcov =3D kcov; > -- > 2.39.2 >