Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp2731234rdb; Mon, 4 Dec 2023 06:11:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IGEZT/8W8JRWntD/GgS58IHou8Bw3vUlrboYKQIFBak82uPevFobXoMgz2alE1smTupt+P4 X-Received: by 2002:a17:902:b107:b0:1d0:700b:3f88 with SMTP id q7-20020a170902b10700b001d0700b3f88mr3086632plr.66.1701699105265; Mon, 04 Dec 2023 06:11:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701699105; cv=none; d=google.com; s=arc-20160816; b=iJpMjrh8ijL+U0t1nCNIpn0gd25rkpJ0LjBYWs2H0DA2zsUErNJcOAHeRwk1N50S2n ySEeyLmEViB4hb3oWV+VMy8XKrgoMh2pUERR+zf5eXG+baWl/m5Q/mvovQE3g7MQkpHp CO3Io9S0+p/MFU//gro19DS6kG/PblxOBCL4+mcPAFe/CixJPAWk1S5+td23BJF3KbMn W2KDykhYankvwXOUgqubf23okyKrRQATiuz0taR0Pulz7YuVhQ+5fKDsrx9e9DzhRapf gSVXR8fSTBgP4sRlHeHO+JaWYYFXAVwvXplQKKhiGPoIS2J54FRYe8VrdBzqh2pe8Ry4 0KQg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=n+CNgXbjWH2kxfDAmh0IKJtDCMFJFs6O6UkiVzukbkc=; fh=X3bGwHQtBGvTVwdEmsxq7nOcwKbPqjj2dFq1MHRn7vo=; b=KZOF9Sq3cs2xFfVj6al0gm3dQx681R7SEuVtRAu9TKRYn0xQvPJKuvlC2fkVY/qAgl IKiwZ+VDUz4xsdBtyJmAV6y9AV8D+L0b4Jh45gyvnClAY031tQ5oJoeUNnO2GCSD5Sm4 PR5Fe4uLqcyP3ixao080SOQ9uL+2q/9ZE3eHJptK4zMLNzdw3GE/zcTZDiMjR15r+b9d Nn2TlHdq2kjxH9/eZcPc9IMcn5suUcl/DCx6MtNW83rio2ZqULus+2CfAxpGh0hsCZDN lKSs58ZyCpJMF71BWdFxC9eiG7GoTiHdcqQGaMGQs7ykGitnTVMtMoLVXG9FWBwSLVJQ iHPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qW9ttmgJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id iz21-20020a170902ef9500b001d0a9fdd8besi1483298plb.628.2023.12.04.06.11.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Dec 2023 06:11:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=qW9ttmgJ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id D60738054BEE; Mon, 4 Dec 2023 06:11:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234450AbjLDOL1 (ORCPT + 99 others); Mon, 4 Dec 2023 09:11:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54320 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231801AbjLDOL0 (ORCPT ); Mon, 4 Dec 2023 09:11:26 -0500 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECC99AA for ; Mon, 4 Dec 2023 06:11:32 -0800 (PST) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 60460C433C7; Mon, 4 Dec 2023 14:11:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1701699092; bh=pZhSxzLDzMwLZSfKGfa6FYFeoHxIe+AuaBCdsEgSWVk=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=qW9ttmgJAe2sgcaGpxz/Sox+kGWSziuO6ntnuQksxQfiD6B2ZimW1Rd0k2PDgfmaA aqtLe6wElfihVrxd0buHMlcDAZXIOZjIOSF4u8FUlPTG2boYnjV3OzCkRu2Lsyv4oZ 6C70WhJBgwiVfcGoVEGZ2qSC3k5UV/P03pBKdmROoS4pJlKh+7EO9hPwZWe9iuFizq xcDh2hhhu7HUtUJqq1EW4+rt6RwGSyttvMewlFs4l/ZkAt1JS1VxU8k9QuQevrHCM9 qLcom1jzpiFwUeTUuKx+63WL79fCUTkfQ+SJYxmRH6k2PKcHe+60Zhrx9N5+k0EThg Vb+sIYAO5NqgQ== Received: from johan by xi.lan with local (Exim 4.96.2) (envelope-from ) id 1rA9gE-0003ez-07; Mon, 04 Dec 2023 15:12:14 +0100 Date: Mon, 4 Dec 2023 15:12:14 +0100 From: Johan Hovold To: Ayush Singh Cc: greybus-dev@lists.linaro.org, elder@kernel.org, gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org, jkridner@beagleboard.org, kernel test robot Subject: Re: [PATCH V3] greybus: gb-beagleplay: Ensure le for values in transport Message-ID: References: <20231204131008.384583-1-ayushdevel1325@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20231204131008.384583-1-ayushdevel1325@gmail.com> X-Spam-Status: No, score=-1.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 04 Dec 2023 06:11:42 -0800 (PST) On Mon, Dec 04, 2023 at 06:40:06PM +0530, Ayush Singh wrote: > Ensure that the following values are little-endian: > - header->pad (which is used for cport_id) > - header->size > > Fixes: ec558bbfea67 ("greybus: Add BeaglePlay Linux Driver") > Reported-by: kernel test robot > Closes: https://lore.kernel.org/r/202311072329.Xogj7hGW-lkp@intel.com/ > Signed-off-by: Ayush Singh > --- > V3: > - Fix endiness while sending. > V2: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/thread/L53UN5ROSG4M6OE7CU5Y3L5F44T6ZPCC/ > - Ensure endianess for header->pad > V1: https://lists.linaro.org/archives/list/greybus-dev@lists.linaro.org/message/K7UJ6PEAWBLNDMHLT2IO6OP5LQISHRUO/ > > drivers/greybus/gb-beagleplay.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > diff --git a/drivers/greybus/gb-beagleplay.c b/drivers/greybus/gb-beagleplay.c > index 43318c1993ba..8b21c3e1e612 100644 > --- a/drivers/greybus/gb-beagleplay.c > +++ b/drivers/greybus/gb-beagleplay.c > @@ -93,9 +93,9 @@ static void hdlc_rx_greybus_frame(struct gb_beagleplay *bg, u8 *buf, u16 len) > memcpy(&cport_id, hdr->pad, sizeof(cport_id)); > > dev_dbg(&bg->sd->dev, "Greybus Operation %u type %X cport %u status %u received", > - hdr->operation_id, hdr->type, cport_id, hdr->result); > + hdr->operation_id, hdr->type, le16_to_cpu(cport_id), hdr->result); > > - greybus_data_rcvd(bg->gb_hd, cport_id, buf, len); > + greybus_data_rcvd(bg->gb_hd, le16_to_cpu(cport_id), buf, len); This looks broken; a quick against mainline (and linux-next) check shows cport_id to be u16. I think you want get_unaligned_le16() or something instead of that memcpy() above. But that just begs the question: why has this driver repurposed the pad bytes like this? The header still says that these shall be set to zero. > } > > static void hdlc_rx_dbg_frame(const struct gb_beagleplay *bg, const char *buf, u16 len) > @@ -340,14 +340,15 @@ static int gb_message_send(struct gb_host_device *hd, u16 cport, struct gb_messa > { > struct gb_beagleplay *bg = dev_get_drvdata(&hd->dev); > struct hdlc_payload payloads[2]; > + __le16 cport_id = cpu_to_le16(cport); > > dev_dbg(&hd->dev, "Sending greybus message with Operation %u, Type: %X on Cport %u", > msg->header->operation_id, msg->header->type, cport); > > - if (msg->header->size > RX_HDLC_PAYLOAD) > + if (le16_to_cpu(msg->header->size) > RX_HDLC_PAYLOAD) > return dev_err_probe(&hd->dev, -E2BIG, "Greybus message too big"); > > - memcpy(msg->header->pad, &cport, sizeof(cport)); > + memcpy(msg->header->pad, &cport_id, sizeof(cport_id)); put_unaligned_le16(), if the driver should be messing with the pad bytes like this at all... > > payloads[0].buf = msg->header; > payloads[0].len = sizeof(*msg->header); Johan