Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp773833ybb; Sat, 28 Mar 2020 09:44:29 -0700 (PDT) X-Google-Smtp-Source: ADFU+vsdfC4bcFYIXQ51o+zLy1qNRQigCZHPtc8GqclprDSIdwUbBwjvgiwv52sGJ5Lyr+SxT5FS X-Received: by 2002:a9d:4ee:: with SMTP id 101mr3142742otm.301.1585413869020; Sat, 28 Mar 2020 09:44:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585413869; cv=none; d=google.com; s=arc-20160816; b=CDLcoq1Zwrj+jOZ6ajxOUwYYosTFypDKTdecvqX83rRXcIkrRftd3JtbEA6cuxWEHD n1egUHTNkwBvJiVHvovQTeYn6+CHKElbSjV+KxDwQVbIyzA1rqj/4bFOvvloCW/sTwcS 4+PVvNIF4n6NkMtm+HgS5r91ufkqpyil9tdFFD56zFa5J6WXvtALJFaLFtpSyZT4/k0r QBULTZvq/MvxuHx7rE5jO/62wFD2ZtI/6x+GlFTT2regBi5zE68C75gfMaagcdaWQvQB 7G8lNmHflWPt0f0oZR7ol+Nl7XEUPiMy9fKun8m1prJp6EdgQsbi0uQP6FSxVKjjwPLl 30JQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:date:from:message-id; bh=JzO7+QTovsBTpBdhhatQBkEtHvpVp0oZ6yURBez4wJI=; b=jooKNkGyiQ9MbP+MV6ZrwhyEHb78himbHtkyeQ/XPmNdcrJF9E9GUrrJlwBuym7yuD 9gVy+pAqbx/1RCUm73O/BRzfODiAfYyqrPjDfP+IVBSKvUvrNSIrpk7JK17XKu2qeT9a /mH2RTJrLJU+8L3X+vsGgAdWs2OLAedjx7lrdqYljsjVo/3Rx29d71c+q/pLEZjcu+db E21Pd5z+N7ntLzGQinuJQBTqRJR76cDKOLsJQhQ5QIN61NYR+avoOFPLIBEbE2CWrp5O 4tYEd79osfyo7MmFWWTOWdchHGjCeuM9vpJV77br0U0t8m+Qe9ry1wPs9rkc7UZw4KWX hUSQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p203si3893490oic.214.2020.03.28.09.44.16; Sat, 28 Mar 2020 09:44:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727793AbgC1Qnl (ORCPT + 99 others); Sat, 28 Mar 2020 12:43:41 -0400 Received: from mx.sdf.org ([205.166.94.20]:50129 "EHLO mx.sdf.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727591AbgC1QnY (ORCPT ); Sat, 28 Mar 2020 12:43:24 -0400 Received: from sdf.org (IDENT:lkml@sdf.lonestar.org [205.166.94.16]) by mx.sdf.org (8.15.2/8.14.5) with ESMTPS id 02SGhKRh017492 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256 bits) verified NO); Sat, 28 Mar 2020 16:43:21 GMT Received: (from lkml@localhost) by sdf.org (8.15.2/8.12.8/Submit) id 02SGhKg2024958; Sat, 28 Mar 2020 16:43:20 GMT Message-Id: <202003281643.02SGhKg2024958@sdf.org> From: George Spelvin Date: Sun, 8 Mar 2020 05:04:08 -0400 Subject: [RFC PATCH v1 35/50] USB: serial: iuu_phoenix: Use pseudorandom for xmas mode To: linux-kernel@vger.kernel.org, lkml@sdf.org Cc: Johan Hovold Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org I also fixed a couple of buffer overrun bugs in iuu_led_activity_on, based on code not expecting the "*buf_ptr++" to have been incremented. - In xmas mode, the final setting of the period byte to 1 was done to buf_ptr[7], which was past the end of the buffer. - In non-xmas mode, iuu_rgbf_fill_buffer() fills in 8 bytes starting with the IUU_SET_LED command. The net result is duplicating the command and writing an extra byte off the end of the buffer. I rewrote the code to omit the ++, which is more legible. Not tested because I don't have the hardware, but I don't think this code has been exercised much anyway. Signed-off-by: George Spelvin Cc: Johan Hovold --- drivers/usb/serial/iuu_phoenix.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index d5bff69b1769b..7aeea7b5ba8db 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c @@ -353,10 +353,11 @@ static void iuu_led_activity_on(struct urb *urb) struct usb_serial_port *port = urb->context; int result; char *buf_ptr = port->write_urb->transfer_buffer; - *buf_ptr++ = IUU_SET_LED; + if (xmas) { - get_random_bytes(buf_ptr, 6); - *(buf_ptr+7) = 1; + buf_ptr[0] = IUU_SET_LED; + prandom_bytes(buf_ptr+1, 6); + buf_ptr[7] = 1; } else { iuu_rgbf_fill_buffer(buf_ptr, 255, 255, 0, 0, 0, 0, 255); } -- 2.26.0