From patchwork Tue Dec 31 16:15:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xndcn X-Patchwork-Id: 854551 Received: from mail-pl1-f173.google.com (mail-pl1-f173.google.com [209.85.214.173]) (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 EE15413CA93; Tue, 31 Dec 2024 16:16:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735661765; cv=none; b=byUV+4lHl9NdVl553K2UjUCunxeYubAbf3eTJJj2sgRxedZNTQCjq9oNif/okekJRZCBeRK2P2KN/TZYdkR+kyngsmLsHL0P0gfCPwxRxJI19KQa1rDGkXWJvsI5M0bnj4L5sercxEXxPaMsSs+hBsxt6hLU1m3X1arrapcoSTg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735661765; c=relaxed/simple; bh=W4kTj0T2xeb2ObhcKC4lFIIAKhkwPOB0JpHwDkfad94=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=YWCJf9apdJL91TSE0r+kiqF4u/tidJzU4HbiLOKTxjCQv89+i2CeX/rLCnoes/yBEL9kA88ZtRT6m+i35/G3l0QyKRN027uOEmSSdSqnXwQ0pbtn7xlC31Sl5B9ZjX0+GCvNC6ccpTXt2aU9A+Kmjk9lGcoOjoJTFpKjHbil1y8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=nT1WkOar; arc=none smtp.client-ip=209.85.214.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nT1WkOar" Received: by mail-pl1-f173.google.com with SMTP id d9443c01a7336-218c8aca5f1so166029895ad.0; Tue, 31 Dec 2024 08:16:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735661763; x=1736266563; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=cT8p5CykmSBP5JnKJjUZ+uruOmwa0xOEMekmu2iPXpI=; b=nT1WkOarBFmEHYLh/xigE8ReYzcHpjLIgAgRq1hI4m2uUdDNpc52VXGiHwAOVYVEsF MvzwCtPFI+W7LvmMFrG92AC++EZR1Uv0Pz0vSH9os1YBQ+VBobx+B6UEw1TOGUwcpl/Z UlBzwvr4Ccv2APQT0WyG4seP7mWx3lieSPhn0gh3waP1iNtQv2zSHmdADE6AlFoGLYkl x6dD25p/HXh6jRPM/hifNMyhFQKWAj+8qcpzCRh+lphu8hmFyy4EX5/YsmF5B7nPmSY8 T/d/oqFa8AUMuxqBcX0iOSY7e+MRVeHiz0LJVyojU3GnzesDDTy4CTkGEUcuESDJt2mX tMCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735661763; x=1736266563; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cT8p5CykmSBP5JnKJjUZ+uruOmwa0xOEMekmu2iPXpI=; b=XchTtmjzTzj6KJDPLtQ72MCWQm6ZljaW0Gx0Il1tG5Tvk/3CyZPMGwZdvL8Sa5yG0x xGnXE5a5d13LRmDCK4vCN+jxf4eUTyfEfTcgVwD106ImYRJ/u5fPvNVB23rocz4AE4Gf c2B3JpQiIkS0I5+z9C06059Rhwev3+AzrvIrFuUhNoQ5xZK952fh2mAUqA+f92QypjE6 xf+hVDOxOSLtKihIZmj2+cWklXtilD11hpO+2PL0ZHLfBln/AEBmbye4TGLJireR6CSK TESvRIpwmD4J2w24IQXT/6tUE/bKQWuML4FGtVwX+e/zHFD0dOVGbiR1peMWqBBzd4XS eeAA== X-Forwarded-Encrypted: i=1; AJvYcCVEj7g3IWsDPsWNg7rZVyzpYl+/wH0ScEm5ku7o8qUC0opjMj0N6h1PDrXAIIJf1GFhSMiK5MCYFnNw2e8=@vger.kernel.org, AJvYcCWKVfza/bDkw4FC5JQxwEqHayNHbFrDOj5T9Twq2T5FJje6g26Lp47YNoVsojBV6S1+sZtPpbALhxZQ@vger.kernel.org X-Gm-Message-State: AOJu0YyISuy1nIyX6GWiEdUOORW02DNtG8X6FZYaMtGmLXyzeIFdbHlv 8vSaNGlDIfP4dFWs0iuggKk7IgMIpf4fbJUQwLW51Av+by8Woul1 X-Gm-Gg: ASbGnct2pH6rN9UmXSYEb4ym3daBDU6X4WbGzn0OkrGNgIrQMyOMBKx9inrFyqryanm 1QlHphufO2RTRIghiax8uT9WQ4L2kUeokp5Q1GZT1qSK58Zq351FjhJAS/o/y3wzT5WEgsjdf3l AwhAnVzXWmBfYXPoE6hnaJuShAMl/nElbU/59tm4XbGr4Fl7APlLhX2Q0EThF9i/QSeCph0s+ml 1P8kvyDfRH+Tk/jSuj1TPbmGACYGH11UH3CfoQ4EvmG1ddZnC0NRyOCL7TcyGqqhQ== X-Google-Smtp-Source: AGHT+IHzuQAOG3BKFuE5/rRfAasR06E+kx8f63s+JPBGg/qqz/MviPzP8iUucJFnqsFPxdO44LCL5w== X-Received: by 2002:a05:6a21:3a8e:b0:1e0:c6c0:1e08 with SMTP id adf61e73a8af0-1e5e04a0c87mr68107028637.25.1735661763310; Tue, 31 Dec 2024 08:16:03 -0800 (PST) Received: from localhost.localdomain ([221.218.161.56]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-72aad90c2e9sm21791083b3a.180.2024.12.31.08.15.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Dec 2024 08:16:02 -0800 (PST) From: Xiong Nandi To: Valentina Manea , Shuah Khan , Hongren Zheng , Greg Kroah-Hartman Cc: Xiong Nandi , linux-usb@vger.kernel.org (open list:USB OVER IP DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 1/2] usbip: Fix seqnum sign extension issue in vhci_tx_urb Date: Wed, 1 Jan 2025 00:15:37 +0800 Message-Id: <20241231161539.20192-2-xndchn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241231161539.20192-1-xndchn@gmail.com> References: <20241231161539.20192-1-xndchn@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The atomic_inc_return function returns an int, while priv->seqnum is an unsigned long. So we must cast the result to u32 to prevent potential sign extension and size mismatch issues. Signed-off-by: Xiong Nandi --- drivers/usb/usbip/vhci_hcd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c index b03e5021c25b..f3f260e01791 100644 --- a/drivers/usb/usbip/vhci_hcd.c +++ b/drivers/usb/usbip/vhci_hcd.c @@ -675,7 +675,7 @@ static void vhci_tx_urb(struct urb *urb, struct vhci_device *vdev) spin_lock_irqsave(&vdev->priv_lock, flags); - priv->seqnum = atomic_inc_return(&vhci_hcd->seqnum); + priv->seqnum = (u32)atomic_inc_return(&vhci_hcd->seqnum); if (priv->seqnum == 0xffff) dev_info(&urb->dev->dev, "seqnum max\n"); From patchwork Tue Dec 31 16:15:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: xndcn X-Patchwork-Id: 854476 Received: from mail-pl1-f175.google.com (mail-pl1-f175.google.com [209.85.214.175]) (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 DBFFD1A08B1; Tue, 31 Dec 2024 16:16:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.175 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735661779; cv=none; b=Xmr2q3yrkQZRg/mCGsZ9o7dZG+nCWyxD/tFsq5kppPR1SWCSq6wIqXEX++sVaV870R+tCkGKQ3tbqYs43LDYFV7AE4DfvnoQFCZ4MaihU2LqJIdiCFl2B8P0bhTTmMyrdOQE4bFCwbCyTSDnmEeO0lnAFy/po581bGECBq1rQqg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1735661779; c=relaxed/simple; bh=PSdqt7Y/tIwrl3WnVX9IixMIvKpHmDpIHFSEp9o6zzE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=CitljLIN0Q0mGW4vgVUBqFIJMRZt597JlP5PZM86b00qxIjqUxuQRpQAIa2wnVodA3REd+JrEDzI/48KwyU59kNfANIT9dW1Nt+beP7e3UwQXg7T0ky1QTrXcRZULX/kymXW/fSjJHyIx4zWrdMbnRlG4e1QZuF8YuFpG34opeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=htUQxoMS; arc=none smtp.client-ip=209.85.214.175 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="htUQxoMS" Received: by mail-pl1-f175.google.com with SMTP id d9443c01a7336-2161eb95317so139209635ad.1; Tue, 31 Dec 2024 08:16:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1735661777; x=1736266577; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=UgT2qaWJQsuqcHxB3ftyO4fAWw0KLNTkRJ41HpRQi5A=; b=htUQxoMShNFPx/DQ8jYyuDEQ7mFk5NXHFo/ecURy5hg7rvMa0S3h0yNvOWjecW9BL4 44ZvhzU7NQpL8QU62E9ewRTxUYDrKmfoyd4wjvtn8XdApd/DD/k5AJidzsXlKRVoMm6h xNn5b1MUdZVaOp4W0wiW46v4Kq64eZXP+Wp0PavfwA1cBL8i6zabeoWMRBqLI04uTuWz Ulm9ipdMnlKKEj7MHtKmRCqtIQd8FhLKCgNoNvOspteSnItuD9f41HrvU/0+Zi4YvNQD snvOO6Xj0z4qfHfSAqcjgJ74VoEK2DynDi/04uGP4F/YidrF3PlDUHq0ZExhxtrlxGoT xn3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1735661777; x=1736266577; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UgT2qaWJQsuqcHxB3ftyO4fAWw0KLNTkRJ41HpRQi5A=; b=nF1+lzMa+ElyD7TO3AmKngBGgYhPjBiEfkkbMt/tG3LpJ3ZCuiibFH3Q1WiEnmvUVX lX3cHUUVCFqyXOymfRyGqItRfTlbcMagQrLtXATXVl7KxHwkJWawpnvGxzxWaZB8b4b1 89xkj0AfHWuQQXsqi9zlEKfbiXPXNedAN4gspc9N2qfmU1Tm55zP+jaOuO60LHfmEzgV HGTILsadp2Rd33aMFRbI8Y+nvpZGKZOx0cHAhZU9wdCUxGBROC/iPbWnBdgwq4+64pCz oy5fi2t7NKYXlycIkTvM8kDYMryprUV3OTsZL6PbQ5TXzNlucjkutJ/GWNLfkzYgoeef EDnw== X-Forwarded-Encrypted: i=1; AJvYcCUypXTluH0AD4Wb6P8SZxuiI19xnQC514X6MZIjk6QGAD6mOWhgIqQ33c/7p53ieSZr7J2K7bHLiSHk@vger.kernel.org, AJvYcCV2PpBRimxu6SJ5IDsYaAeF5FkfJmSkGjq6Ve+fDlNpmRa82aPcAqzWhxOKdQmf87JXBnyyx/pdeFM69bg=@vger.kernel.org X-Gm-Message-State: AOJu0YxOTghvhouw/MqWCOnKztPexbOMRLiLqZ/bVV3qAPPE5Nvu8qAz 7/dIUioL+VsBABNXbHUoryfu/5/Blc7/kSc+j5zA6cBC1vnB7Xmk X-Gm-Gg: ASbGncsbml+ETyFMZsGgh8zBtTV/73Pq+Mg9EyN2ef7XZs0vKNX5yMGw25+QF7Ex+HK qkC5T/LDBcULp/72LuHyan9KYK9qZRGAmxeSbpu+JumA+6vCdkx6JcCQHtE6UR2NnmKFQ/5gRRg ln+2AGkJyLj+2ira+hvU5i4GvJNcut3bby50ALmwqf7i0C7/Pcrgc3wbvYhoCk6k9zpJuUOEBpM 7Loj6xUpV7ochdkIstN74UFcQAvMHh6AV+hC1qiKUue5N4kUX6DtsMxGdOOfSAWXw== X-Google-Smtp-Source: AGHT+IFWaW7PEJFKy88T2byghRxIxgG/k6/aIZddt13gTDh3PLpybOqL0Slog8quci86fHUAbSdWpA== X-Received: by 2002:a05:6a20:db0a:b0:1e1:ae4a:1d50 with SMTP id adf61e73a8af0-1e5e049f545mr66397028637.25.1735661776947; Tue, 31 Dec 2024 08:16:16 -0800 (PST) Received: from localhost.localdomain ([221.218.161.56]) by smtp.googlemail.com with ESMTPSA id d2e1a72fcca58-72aad90c2e9sm21791083b3a.180.2024.12.31.08.16.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 31 Dec 2024 08:16:16 -0800 (PST) From: Xiong Nandi To: Valentina Manea , Shuah Khan , Hongren Zheng , Greg Kroah-Hartman Cc: Xiong Nandi , linux-usb@vger.kernel.org (open list:USB OVER IP DRIVER), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 2/2] usbip: Correct format specifier for seqnum from %d to %u Date: Wed, 1 Jan 2025 00:15:38 +0800 Message-Id: <20241231161539.20192-3-xndchn@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20241231161539.20192-1-xndchn@gmail.com> References: <20241231161539.20192-1-xndchn@gmail.com> Precedence: bulk X-Mailing-List: linux-usb@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The seqnum field in USBIP protocol is an unsigned value. So we fix the format specifier from %d to %u to correctly display the value. Signed-off-by: Xiong Nandi --- drivers/usb/usbip/stub_rx.c | 2 +- drivers/usb/usbip/stub_tx.c | 2 +- drivers/usb/usbip/vhci_rx.c | 6 +++--- drivers/usb/usbip/vudc_tx.c | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/usb/usbip/stub_rx.c b/drivers/usb/usbip/stub_rx.c index 6338d818bc8b..9aa30ef76f3b 100644 --- a/drivers/usb/usbip/stub_rx.c +++ b/drivers/usb/usbip/stub_rx.c @@ -269,7 +269,7 @@ static int stub_recv_cmd_unlink(struct stub_device *sdev, return 0; } - usbip_dbg_stub_rx("seqnum %d is not pending\n", + usbip_dbg_stub_rx("seqnum %u is not pending\n", pdu->u.cmd_unlink.seqnum); /* diff --git a/drivers/usb/usbip/stub_tx.c b/drivers/usb/usbip/stub_tx.c index b1c2f6781cb3..7eb2e074012a 100644 --- a/drivers/usb/usbip/stub_tx.c +++ b/drivers/usb/usbip/stub_tx.c @@ -201,7 +201,7 @@ static int stub_send_ret_submit(struct stub_device *sdev) /* 1. setup usbip_header */ setup_ret_submit_pdu(&pdu_header, urb); - usbip_dbg_stub_tx("setup txdata seqnum: %d\n", + usbip_dbg_stub_tx("setup txdata seqnum: %u\n", pdu_header.base.seqnum); if (priv->sgl) { diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c index 7f2d1c241559..a75f4a898a41 100644 --- a/drivers/usb/usbip/vhci_rx.c +++ b/drivers/usb/usbip/vhci_rx.c @@ -66,7 +66,7 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev, spin_unlock_irqrestore(&vdev->priv_lock, flags); if (!urb) { - pr_err("cannot find a urb of seqnum %u max seqnum %d\n", + pr_err("cannot find a urb of seqnum %u max seqnum %u\n", pdu->base.seqnum, atomic_read(&vhci_hcd->seqnum)); usbip_event_add(ud, VDEV_EVENT_ERROR_TCP); @@ -162,10 +162,10 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev, * already received the result of its submit result and gave * back the URB. */ - pr_info("the urb (seqnum %d) was already given back\n", + pr_info("the urb (seqnum %u) was already given back\n", pdu->base.seqnum); } else { - usbip_dbg_vhci_rx("now giveback urb %d\n", pdu->base.seqnum); + usbip_dbg_vhci_rx("now giveback urb %u\n", pdu->base.seqnum); /* If unlink is successful, status is -ECONNRESET */ urb->status = pdu->u.ret_unlink.status; diff --git a/drivers/usb/usbip/vudc_tx.c b/drivers/usb/usbip/vudc_tx.c index 3ccb17c3e840..30c11bf9f4e7 100644 --- a/drivers/usb/usbip/vudc_tx.c +++ b/drivers/usb/usbip/vudc_tx.c @@ -107,7 +107,7 @@ static int v_send_ret_submit(struct vudc *udc, struct urbp *urb_p) /* 1. setup usbip_header */ setup_ret_submit_pdu(&pdu_header, urb_p); - usbip_dbg_stub_tx("setup txdata seqnum: %d\n", + usbip_dbg_stub_tx("setup txdata seqnum: %u\n", pdu_header.base.seqnum); usbip_header_correct_endian(&pdu_header, 1);