Received: by 2002:a05:6358:5282:b0:b5:90e7:25cb with SMTP id g2csp3409911rwa; Tue, 23 Aug 2022 04:25:47 -0700 (PDT) X-Google-Smtp-Source: AA6agR5XteAxF51FZ44+0xnyFsves+FeynNcZc/YJXcq9sF6NJK8OxjJbU+wcxq0iBGMCANIRSVi X-Received: by 2002:a17:90b:3889:b0:1f5:88cd:350d with SMTP id mu9-20020a17090b388900b001f588cd350dmr2880333pjb.9.1661253946815; Tue, 23 Aug 2022 04:25:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661253946; cv=none; d=google.com; s=arc-20160816; b=ROtpi++4A7jDofBYF91HeJ6OplqkGeCB/gKu1987bGKhSFcF9+tRGOmahmGJ3Bkvme eJvVwn27qQxCPJN17UEs61eu/RXHCCfyr8R0xoj37dXLRkmG2CsXaNs4z2R+WIyQaCfJ 4GesxKmKd5VxOJs2jqXeFProzFtiV/YBjfD53HiLY3sj3N1WS7tk9bRKGyTKzvRs7Sr9 pfF3piCYTAFtMN+hYVG+CvrDsa3felD94DXeh0VJ+Ivl3A2KSgKLNbGDRFZ2hgT9tkdc YJtFBIgYIIrse87hAfP7kOKzFKvf5Qb/CisOm2Uw9Ef43X46qb+nq4orqwSejxUPaaNj bGnQ== 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:subject:cc:to :from:dkim-signature; bh=sZbWwtphPJS6C5BKDHCRQrMoQaMAoI6F+n8IJSj9q4E=; b=HpjEMQM4bBezR2X47J6gpyiTA1WnzWTL2+71eip79d5tRHdhkLnPtSzGcNZfYeGgM1 h1LxmxJNW7CgMdzdla8g8basyJTAeohN8y6p/xSyyLbi/PlOtWpAh2dTKo/DUZ8TrRTP yk6UOInNRxK7hSEs9WGPx4sql3JAPJmcVzdE7/+E7rJebf0HnepiFiN/Pvw0XjpHBpwD N8GvsEFCb/roeOW7Mn+WqIqWWjgX7EporYvKt2yBWqHE4x3XLhegvaGOz7MQK3cFXCls d1C4VRCxBkfbuJp91GDztw2LysUuMiFsa9IgcidAGSCi2k6huZ9Nxv9v+rdGMltzc995 FIhQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1ndqCl6W; 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=linuxfoundation.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id v13-20020a056a00148d00b005107cf64e1dsi13846796pfu.212.2022.08.23.04.25.35; Tue, 23 Aug 2022 04:25:46 -0700 (PDT) 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=@linuxfoundation.org header.s=korg header.b=1ndqCl6W; 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351684AbiHWKDZ (ORCPT + 99 others); Tue, 23 Aug 2022 06:03:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1352460AbiHWJ46 (ORCPT ); Tue, 23 Aug 2022 05:56:58 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4381CA1A77; Tue, 23 Aug 2022 01:47:39 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D88B5B81C35; Tue, 23 Aug 2022 08:47:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 334D1C433C1; Tue, 23 Aug 2022 08:47:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1661244453; bh=w0p436ssZfj/lQdy31bDOBkJyI06WCHkjyGiFQ8EqOQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1ndqCl6W+nIih8vE6fAXd8KbgmZ4NmDjcgPgFhV9YcgLysd43meI2vTnKSFr2CCgE RsHx875my14uPutC80DZLkO/44mzgPn5KFnxwI8fnpSyLKD6dm6ymJkPKQRzp/V42Y agYgiSEvxkQQ/aQkePNrqIgo0KQvH15FKcBjY+6o= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Dan Carpenter , Oleksandr Tyshchenko , Juergen Gross Subject: [PATCH 5.15 096/244] xen/xenbus: fix return type in xenbus_file_read() Date: Tue, 23 Aug 2022 10:24:15 +0200 Message-Id: <20220823080102.226698313@linuxfoundation.org> X-Mailer: git-send-email 2.37.2 In-Reply-To: <20220823080059.091088642@linuxfoundation.org> References: <20220823080059.091088642@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham 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 From: Dan Carpenter commit 32ad11127b95236dfc52375f3707853194a7f4b4 upstream. This code tries to store -EFAULT in an unsigned int. The xenbus_file_read() function returns type ssize_t so the negative value is returned as a positive value to the user. This change forces another change to the min() macro. Originally, the min() macro used "unsigned" type which checkpatch complains about. Also unsigned type would break if "len" were not capped at MAX_RW_COUNT. Use size_t for the min(). (No effect on runtime for the min_t() change). Fixes: 2fb3683e7b16 ("xen: Add xenbus device driver") Signed-off-by: Dan Carpenter Reviewed-by: Oleksandr Tyshchenko Link: https://lore.kernel.org/r/YutxJUaUYRG/VLVc@kili Signed-off-by: Juergen Gross Signed-off-by: Greg Kroah-Hartman --- drivers/xen/xenbus/xenbus_dev_frontend.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/xen/xenbus/xenbus_dev_frontend.c +++ b/drivers/xen/xenbus/xenbus_dev_frontend.c @@ -128,7 +128,7 @@ static ssize_t xenbus_file_read(struct f { struct xenbus_file_priv *u = filp->private_data; struct read_buffer *rb; - unsigned i; + ssize_t i; int ret; mutex_lock(&u->reply_mutex); @@ -148,7 +148,7 @@ again: rb = list_entry(u->read_buffers.next, struct read_buffer, list); i = 0; while (i < len) { - unsigned sz = min((unsigned)len - i, rb->len - rb->cons); + size_t sz = min_t(size_t, len - i, rb->len - rb->cons); ret = copy_to_user(ubuf + i, &rb->msg[rb->cons], sz);