From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753019AbcHWPPW (ORCPT ); Tue, 23 Aug 2016 11:15:22 -0400 Received: from mx1.polytechnique.org ([129.104.30.34]:45616 "EHLO mx1.polytechnique.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750812AbcHWPPP (ORCPT ); Tue, 23 Aug 2016 11:15:15 -0400 From: Nicolas Iooss To: Valentina Manea , Shuah Khan , Shuah Khan , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Nicolas Iooss Subject: [PATCH 1/1] usb: usbip: vudc: fix left shift overflow Date: Tue, 23 Aug 2016 17:13:29 +0200 Message-Id: <20160823151329.25813-1-nicolas.iooss_linux@m4x.org> X-Mailer: git-send-email 2.9.3 X-AV-Checked: ClamAV using ClamSMTP at svoboda.polytechnique.org (Tue Aug 23 17:14:13 2016 +0200 (CEST)) X-Spam-Flag: No, tests=bogofilter, spamicity=0.075114, queueID=D26715613B5 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org In v_recv_cmd_submit(), urb_p->urb->pipe has the type unsigned int (which is 32-bit long on x86_64) but 11<<30 results in a 34-bit integer. Therefore the 2 leading bits are truncated and urb_p->urb->pipe &= ~(11 << 30); has the same meaning as urb_p->urb->pipe &= ~(3 << 30); This second statement seems to be how the code was intended to be written, as PIPE_ constants have values between 0 and 3. The overflow has been detected with a clang warning: drivers/usb/usbip/vudc_rx.c:145:27: warning: signed shift result (0x2C0000000) requires 35 bits to represent, but 'int' only has 32 bits [-Wshift-overflow] urb_p->urb->pipe &= ~(11 << 30); ~~ ^ ~~ Fixes: 79c02cb1fd5c ("usbip: vudc: Add vudc_rx") Signed-off-by: Nicolas Iooss --- drivers/usb/usbip/vudc_rx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/usb/usbip/vudc_rx.c b/drivers/usb/usbip/vudc_rx.c index 344bd9473475..e429b59f6f8a 100644 --- a/drivers/usb/usbip/vudc_rx.c +++ b/drivers/usb/usbip/vudc_rx.c @@ -142,7 +142,7 @@ static int v_recv_cmd_submit(struct vudc *udc, urb_p->urb->status = -EINPROGRESS; /* FIXME: more pipe setup to please usbip_common */ - urb_p->urb->pipe &= ~(11 << 30); + urb_p->urb->pipe &= ~(3 << 30); switch (urb_p->ep->type) { case USB_ENDPOINT_XFER_BULK: urb_p->urb->pipe |= (PIPE_BULK << 30); -- 2.9.3