From patchwork Fri Dec 2 00:15:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 28611 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp559720wrr; Thu, 1 Dec 2022 16:22:27 -0800 (PST) X-Google-Smtp-Source: AA0mqf4W5LTDRa9OfgmvWYXPSdytCCq5g4yTyylZHoMuMC+SxNKSfxrFMgW9AMrhu76/+Jayn6L0 X-Received: by 2002:a17:906:52d4:b0:7bc:14e7:cfaf with SMTP id w20-20020a17090652d400b007bc14e7cfafmr30904851ejn.727.1669940547190; Thu, 01 Dec 2022 16:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669940547; cv=none; d=google.com; s=arc-20160816; b=e6mlMJJLLH+ZtG8udRLwKp9B0HqReuwBzuDM/ctWDWcUd1OFP/dfbXFa5cc7LmKMJw SejbeqKsodExoLbAE0hC6Qb9TpnJTjWm8wnvcbIVdimqGR4Lo7ERt7BS+AexOdw9ueCe ZOdSEnrkGzn+vp4S2+e6VmaM3DOfdiREi4VtDGsIHmxPONGeowI4KyBmYxxClP7edQgR Aop605lCW/tqxPrHK34h2MQF1m4cN/bGu+cLFVCfIeTqLTWEcFopYgVBnxqMEB+Cl/Wf lHAfOK068v65pdLWLKCQFqQqieOBnpiioEMTZSw8eyxH7owokfhHwQPi1kBRIPfJp1zr sNNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:cc:to:from :subject:organization:dkim-signature; bh=4qYC6XKsXbcd0hRR1gotSuy2C9d5zoYzYBq3xZH4glY=; b=s0DrIByREGgVOrm03rQRDWWxumvX+e3bDjetaTE1VdcW+y6O144TWz1JK3hQfj/9pT KLPq+MBa6Xu1ofXqEvtJvXTcn9aNlZZs+CAOZRs2TFHS7JeN26QjXcZT1GnHAv4JJ5+e KwwHAWJkBM00Sw49+2W0Od+vP6k7OkC+JfvePTdFkF91lV2Bi7ou1/XY7I0JPDF1pyM+ FpFy7gDeE0Rp5jzOMLXzZKKfd0GSvvhaQnsJ2/2AjZgz3TINr5vYTNYU4NdH5PlHHOjx usdyKjju56QGjStH0hRqt9+IVlnLgEN1u2HI/eJOzWpyWHogwZYw2Y4k6yrHblB+/99U Tblw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JXLAPEoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq14-20020a1709073f0e00b007bf22d4e679si5473669ejc.63.2022.12.01.16.22.03; Thu, 01 Dec 2022 16:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=JXLAPEoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232108AbiLBAQh (ORCPT + 99 others); Thu, 1 Dec 2022 19:16:37 -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 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1751059579185959358?= X-GMAIL-MSGID: =?utf-8?q?1751059579185959358?= 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, } _debug("token[%u]: toksize=%u", ntoks, toksize); - ASSERTCMP(toksize, <=, AFSTOKEN_LENGTH_MAX); + if (WARN_ON(toksize > AFSTOKEN_LENGTH_MAX)) + return -EIO; toksizes[ntoks++] = toksize; size += toksize + 4; /* each token has a length word */ @@ -679,8 +680,9 @@ static long rxrpc_read(const struct key *key, return -ENOPKG; } - ASSERTCMP((unsigned long)xdr - (unsigned long)oldxdr, ==, - toksize); + if (WARN_ON((unsigned long)xdr - (unsigned long)oldxdr == + toksize)) + return -EIO; } #undef ENCODE_STR @@ -688,8 +690,10 @@ static long rxrpc_read(const struct key *key, #undef ENCODE64 #undef ENCODE - ASSERTCMP(tok, ==, ntoks); - ASSERTCMP((char __user *) xdr - buffer, ==, size); + if (WARN_ON(tok != ntoks)) + return -EIO; + if (WARN_ON((unsigned long)xdr - (unsigned long)buffer != size)) + return -EIO; _leave(" = %zu", size); return size; }