From nobody Thu Sep 18 23:36:26 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 847E2C4332F for ; Fri, 2 Dec 2022 00:16:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232140AbiLBAQj (ORCPT ); Thu, 1 Dec 2022 19:16:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231961AbiLBAQR (ORCPT ); Thu, 1 Dec 2022 19:16:17 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77B84CEFAA for ; Thu, 1 Dec 2022 16:15:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669940119; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=4qYC6XKsXbcd0hRR1gotSuy2C9d5zoYzYBq3xZH4glY=; b=JXLAPEooVOipmNw6eH4T+sA+/HQ1ft7g5P8InaF2rvSw6Onjeaskadm92qzyJNaEJ8aCHj nv4JCiIs5g1j4VmoYVXXWc3gXPkqWaaLO9T4Xl6J3ocz5Gv+bibn+TDkBXNEeyNUmrXKza nlBnz9jiGDoyJsaFOKEDcXW81qJkMi0= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-12-ofMatim6PJi2TSgbaqyS7A-1; Thu, 01 Dec 2022 19:15:16 -0500 X-MC-Unique: ofMatim6PJi2TSgbaqyS7A-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 406C7101A528; Fri, 2 Dec 2022 00:15:16 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.33.36.36]) by smtp.corp.redhat.com (Postfix) with ESMTP id 98CBA111E3F8; Fri, 2 Dec 2022 00:15:15 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 Subject: [PATCH net-next 01/36] rxrpc: Fix checker warning From: David Howells To: netdev@vger.kernel.org Cc: Marc Dionne , linux-afs@lists.infradead.org, dhowells@redhat.com, linux-afs@lists.infradead.org, linux-kernel@vger.kernel.org Date: Fri, 02 Dec 2022 00:15:12 +0000 Message-ID: <166994011276.1732290.15928632785736482421.stgit@warthog.procyon.org.uk> In-Reply-To: <166994010342.1732290.13771061038178613124.stgit@warthog.procyon.org.uk> References: <166994010342.1732290.13771061038178613124.stgit@warthog.procyon.org.uk> User-Agent: StGit/1.5 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix the following checker warning: ../net/rxrpc/key.c:692:9: error: subtraction of different types can't work = (different address spaces) Checker is wrong in this case, but cast the pointers to unsigned long to avoid the warning. Whilst we're at it, reduce the assertions to WARN_ON() and return an error. Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- net/rxrpc/key.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c index 8d2073e0e3da..830eeffe2d5b 100644 --- a/net/rxrpc/key.c +++ b/net/rxrpc/key.c @@ -602,7 +602,8 @@ static long rxrpc_read(const struct key *key, } =20 _debug("token[%u]: toksize=3D%u", ntoks, toksize); - ASSERTCMP(toksize, <=3D, AFSTOKEN_LENGTH_MAX); + if (WARN_ON(toksize > AFSTOKEN_LENGTH_MAX)) + return -EIO; =20 toksizes[ntoks++] =3D toksize; size +=3D toksize + 4; /* each token has a length word */ @@ -679,8 +680,9 @@ static long rxrpc_read(const struct key *key, return -ENOPKG; } =20 - ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, =3D=3D, - toksize); + if (WARN_ON((unsigned long)xdr - (unsigned long)oldxdr =3D=3D + toksize)) + return -EIO; } =20 #undef ENCODE_STR @@ -688,8 +690,10 @@ static long rxrpc_read(const struct key *key, #undef ENCODE64 #undef ENCODE =20 - ASSERTCMP(tok, =3D=3D, ntoks); - ASSERTCMP((char __user *) xdr - buffer, =3D=3D, size); + if (WARN_ON(tok !=3D ntoks)) + return -EIO; + if (WARN_ON((unsigned long)xdr - (unsigned long)buffer !=3D size)) + return -EIO; _leave(" =3D %zu", size); return size; }