Received: by 2002:ac8:3b51:0:b0:3f3:9eb6:4eb6 with SMTP id r17csp1146601qtf; Wed, 17 May 2023 11:24:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ66nwfnZNiXmoDqqp6SbZgMJSfPnCsJ8GOAnq9h96oFA/vjPxQH/CQsvOha3Ulboe9coafe X-Received: by 2002:a17:902:b403:b0:1ac:8ad0:1703 with SMTP id x3-20020a170902b40300b001ac8ad01703mr29610192plr.35.1684347851670; Wed, 17 May 2023 11:24:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684347851; cv=none; d=google.com; s=arc-20160816; b=lwGDfdfACjxUZFwcbYVeZpyv8GKbZzbSxR2Ay5AcdlKbmFWr32nam+nwmqbmVbZIv1 1cyepkOkBEpVf44yFzCjQvfw91v/YVLREoUnSSyR3unD2Ucps8pPquSW2jBF2qwpvZ2a qJONlyDGq/H0JXRKq8ZHK0GzfmSK/Oq4vlsPIrGjh/x1+8qB5vEXcd2j6QTXaH3uIpeE HqxkFDLWAcl0DSAipIzP9lrv6S1sSQn/gfy+jU7Qd/7ErP969TFqc5vw071nGa/R/NuC /ctAf7Pw2gOILUug3ru6QhtQ3Pd8Qyq45zCaqAXoLPPlktdHS7g4Y6m1wI43ULBRw14v uKhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:cc:to:from :dkim-signature; bh=L4QygZnsbOUPK7E7vLPerRHsg5Kt1xx+cSpKL8h6YOg=; b=HK4TGnsp3w3T0oZrnqHkipNnvfUbD+TAVMR3c13lZy/XVOQVQBDgT4bQ7lgg9I3g5Y p9dSitmsa6kmjoQBgI79PLVusbRsUceXxnubcdPVB6n28vt0tsJ6YePY/CsU7I+QMMDd FGPtDycc0SqILx88UbZOAjsf0TyKUAmdgjAy59RobTpKRXhoN0XyyeaXZ8AvA1w3zQMc NTGZwf6FqQeYAtb9Tc+8/nsAR/1mxGThMFOAvzDfWWcGrZ/w3dETVFqS/NyBiQ4FEb6a kQHBZRSEvaJB701cSld8vF6Fg4qqrCVd5OHI2+lSnSbUykc4y2pUl3bbJFkmrIOMG7Wl 3Eww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b=VWiA9Y60; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t3-20020a170902bc4300b001ae21cd0fafsi6797729plz.38.2023.05.17.11.23.58; Wed, 17 May 2023 11:24:11 -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=@broadcom.com header.s=google header.b=VWiA9Y60; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230052AbjEQSO1 (ORCPT + 99 others); Wed, 17 May 2023 14:14:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229720AbjEQSOY (ORCPT ); Wed, 17 May 2023 14:14:24 -0400 Received: from mail-pl1-x62e.google.com (mail-pl1-x62e.google.com [IPv6:2607:f8b0:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F31567D9C for ; Wed, 17 May 2023 11:14:12 -0700 (PDT) Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1ae52ce3205so7468045ad.3 for ; Wed, 17 May 2023 11:14:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1684347252; x=1686939252; h=mime-version:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to; bh=L4QygZnsbOUPK7E7vLPerRHsg5Kt1xx+cSpKL8h6YOg=; b=VWiA9Y60DudNFO0jMJul+tY+Y1RXISdEN+2jdhYZxquBjnPI4GbrE880tZlu7kSiB3 xCnIgZTFZHqLFMC+GLgdqCMXUdRc3tFTmos8q0Xj7zInJjpNqENTChqoeaDAaXDhDEhF QqZ/a2FRJ+XvVtcDfWpE4nTi4zk+/JuW3UqUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684347252; x=1686939252; h=mime-version:message-id:date:subject:cc:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=L4QygZnsbOUPK7E7vLPerRHsg5Kt1xx+cSpKL8h6YOg=; b=Wu63Eh3AXRPSCiAb+kMShW2cqEA69ixtU5MypkjFm6swdJf269SmSrr6+ZJCBfQ+qr i/gotf4Syce12aCx2GgCVG4zvcjWO4GuTb8ntq5cD1w8gGNBZ+IYGkeyTvGAQJ/MMfr+ +iXCmU/vaPgjAqpgFBnwYX6vSH7HG1p/wOufvbh/BOPiYmozIs47YC7LWoa8TsnvcMtm fHR7kHNoac/UzeWQszA5etDTLtlhLrFFf5XacpyZlckhRZyUMXVFL3b0GEtWtCwpRWrd J6rAuCBuQDm7F204YI9IK+6yB9nN+V2bqpMIdbs7S4tq/nCuKDxui1A48jmo95QqLPcU dzQQ== X-Gm-Message-State: AC+VfDwjao+NmZcGb4PByHq+L2UoIq5FqYRYIhTguG1D5OEg/HIHjVX2 whgf2e2dfmUMuvHAdF/6iu3huw== X-Received: by 2002:a17:903:234f:b0:1ae:bf5:7b5 with SMTP id c15-20020a170903234f00b001ae0bf507b5mr15915501plh.34.1684347252392; Wed, 17 May 2023 11:14:12 -0700 (PDT) Received: from bld-lvn-bcawlan-30.lvn.broadcom.net ([192.19.161.250]) by smtp.gmail.com with ESMTPSA id w3-20020a1709027b8300b001ae626d051bsm205400pll.70.2023.05.17.11.14.11 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2023 11:14:11 -0700 (PDT) From: Kursad Oney To: linux-arm-kernel@lists.infradead.org Cc: BCM Kernel Feedback , Kursad Oney , Russell King , linux-kernel@vger.kernel.org Subject: [PATCH] ARM: memset: cast the constant byte to unsigned char Date: Wed, 17 May 2023 14:13:52 -0400 Message-Id: <20230517181353.381073-1-kursad.oney@broadcom.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 Content-Type: multipart/signed; protocol="application/pkcs7-signature"; micalg=sha-256; boundary="000000000000ad6c6905fbe7a79d" X-Spam-Status: No, score=-0.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MIME_NO_TEXT, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=no 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 --000000000000ad6c6905fbe7a79d Content-Transfer-Encoding: 8bit memset() description in ISO/IEC 9899:1999 (and elsewhere) says: The memset function copies the value of c (converted to an unsigned char) into each of the first n characters of the object pointed to by s. The kernel's arm32 memset does not cast c to unsigned char. This results in the following code to produce erroneous output: char a[128]; memset(a, -128, sizeof(a)); This is because gcc will generally emit the following code before it calls memset() : mov r0, r7 mvn r1, #127 ; 0x7f bl 00000000 r1 ends up with 0xffffff80 before being used by memset() and the 'a' array will have -128 once in every four bytes while the other bytes will be set incorrectly to -1 like this (printing the first 8 bytes) : test_module: -128 -1 -1 -1 test_module: -1 -1 -1 -128 The change here is to 'and' r1 with 255 before it is used. Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2") Signed-off-by: Kursad Oney --- arch/arm/lib/memset.S | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm/lib/memset.S b/arch/arm/lib/memset.S index d71ab61430b2..de75ae4d5ab4 100644 --- a/arch/arm/lib/memset.S +++ b/arch/arm/lib/memset.S @@ -17,6 +17,7 @@ ENTRY(__memset) ENTRY(mmioset) WEAK(memset) UNWIND( .fnstart ) + and r1, r1, #255 @ cast to unsigned char ands r3, r0, #3 @ 1 unaligned? mov ip, r0 @ preserve r0 as return value bne 6f @ 1 -- 2.37.3 --000000000000ad6c6905fbe7a79d Content-Type: application/pkcs7-signature; name="smime.p7s" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smime.p7s" Content-Description: S/MIME Cryptographic Signature MIIQagYJKoZIhvcNAQcCoIIQWzCCEFcCAQExDzANBglghkgBZQMEAgEFADALBgkqhkiG9w0BBwGg gg3BMIIFDTCCA/WgAwIBAgIQeEqpED+lv77edQixNJMdADANBgkqhkiG9w0BAQsFADBMMSAwHgYD VQQLExdHbG9iYWxTaWduIFJvb3QgQ0EgLSBSMzETMBEGA1UEChMKR2xvYmFsU2lnbjETMBEGA1UE AxMKR2xvYmFsU2lnbjAeFw0yMDA5MTYwMDAwMDBaFw0yODA5MTYwMDAwMDBaMFsxCzAJBgNVBAYT AkJFMRkwFwYDVQQKExBHbG9iYWxTaWduIG52LXNhMTEwLwYDVQQDEyhHbG9iYWxTaWduIEdDQyBS MyBQZXJzb25hbFNpZ24gMiBDQSAyMDIwMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA vbCmXCcsbZ/a0fRIQMBxp4gJnnyeneFYpEtNydrZZ+GeKSMdHiDgXD1UnRSIudKo+moQ6YlCOu4t rVWO/EiXfYnK7zeop26ry1RpKtogB7/O115zultAz64ydQYLe+a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