Received: by 10.192.165.148 with SMTP id m20csp350522imm; Thu, 3 May 2018 22:05:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqwaLVx0uiOLgRL+9qMw7j06M2ut5I+GpumDVkgOXRyeDQqNKU5qDEBC4HwGdccwsjxZw10 X-Received: by 2002:a17:902:700a:: with SMTP id y10-v6mr26716230plk.265.1525410318045; Thu, 03 May 2018 22:05:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525410317; cv=none; d=google.com; s=arc-20160816; b=fzloBjZXVUFaUorpgVX/U4eiiRcxngvsFNCb5YKBT54QyL3p3uGuYHIrcZtdugV0rn fruf8/hw3yrW4RJesORFg+OpBl+iiOTy7MkVSLWr/jw3RTsrHAMM4g4bEYSnU8Qc6Q6g 0hltOqaFulbt5OOv5NZBkMRFhybHyUZzqKpt2oXNRgzqN9AlZ1Z84yaGRgWV3MUT2WV2 JEH6q0eBDI3iADqCnXVrjCZPg/oUMsCgZ8bqrOXizWxQs6nvPe9GFGGPBAknKhXmFNgw wpAQx4UfMD539gmkOrOe4dXvTGT4Oz1hhocuAw/ipdfAd2nMEGN+b+9PnuzJalmXvIgT fwMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:spamdiagnosticmetadata :spamdiagnosticoutput:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:organization :from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=6xExsAsghMVEHfYDxn7unFNseyVyIXkzQ5Uj9LChcac=; b=cMMObDwMWNKZ/7TaPjEplPVNAh2CQEgOgYfBc6azv8c0JKQp6lTJPmqirGhCDE4/4W Bmn7B/WBGCfvp/dYXgW0Ffn2Io6IOM47hRBK5MjKCYCaNqYrlkFCJcOiXUii6AKFyH/K p4FtA3rF/OJkYfqCJykLuwKfmHLkh57Uq3OwwXBdtQQsyo3AlK4zVFa3CiJFYcIBd/rj qgt2B4+HozI8mH29T/BlWFNm8etRiYtlB8HjcLde+pEWNM/VW62fiyI1l8jxjbwcM4WP SVPAd60XmphXibc0dXagIYkuzdKtpfFdb3Da5B7fP8IfmSbEscOU/ycBXXyAajJL/59L mWmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@axentia.se header.s=selector1 header.b=nI0PVm7X; 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 x4-v6si12272153pgc.411.2018.05.03.22.05.03; Thu, 03 May 2018 22:05:17 -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; dkim=pass header.i=@axentia.se header.s=selector1 header.b=nI0PVm7X; 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 S1751275AbeEDFEt (ORCPT + 99 others); Fri, 4 May 2018 01:04:49 -0400 Received: from mail-eopbgr00112.outbound.protection.outlook.com ([40.107.0.112]:4159 "EHLO EUR02-AM5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750866AbeEDFEr (ORCPT ); Fri, 4 May 2018 01:04:47 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axentia.se; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=6xExsAsghMVEHfYDxn7unFNseyVyIXkzQ5Uj9LChcac=; b=nI0PVm7XzkxBW1QQ6mpheYTINvemuL9LF5EKv076YVCIk0LcmxQvcG03jfAqOO33BtI3JrbVv1jfscrPzpcRBFZ7AhYfoQol/+RHuKe740/qX1Hls4IBKZKDmJZZyvJeoxoL+Eu8etZPVdNcLtgklQPUW9xTCqYZQQVjVGwrwP4= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=peda@axentia.se; Received: from [192.168.13.3] (85.226.244.23) by DB6PR0202MB2775.eurprd02.prod.outlook.com (2603:10a6:4:a8::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.715.23; Fri, 4 May 2018 05:04:44 +0000 Subject: Re: [PATCH] i2c: core-smbus: fix a potential uninitialization bug To: Wenwen Wang Cc: Kangjie Lu , Wolfram Sang , "open list:I2C SUBSYSTEM" , open list References: <1525300581-27217-1-git-send-email-wang6495@umn.edu> <4390a69e-a297-313d-044d-abf846eff1d1@axentia.se> From: Peter Rosin Organization: Axentia Technologies AB Message-ID: <82973b7b-b6ef-6d42-df5c-be3ea72212fa@axentia.se> Date: Fri, 4 May 2018 07:04:41 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [85.226.244.23] X-ClientProxiedBy: DB6P189CA0023.EURP189.PROD.OUTLOOK.COM (2603:10a6:6:2e::36) To DB6PR0202MB2775.eurprd02.prod.outlook.com (2603:10a6:4:a8::21) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(7021125)(5600026)(4534165)(7022125)(4603075)(4627221)(201702281549075)(7048125)(7024125)(7027125)(7028125)(7023125)(2017052603328)(7153060)(7193020);SRVR:DB6PR0202MB2775; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;3:fkmNrEEKUJ0siZOoSpvT0rrVzeMp1gqOzd485TB1bn7DfydgSel1QDb36ePCIKNBSk6sl90Tv+Dgybz3CDEtDxxAWhSCkWD/7EE6MIySjxQk7+5ji8OBhthVUH3QhYFDeWmCOpb1+/y6CfKqmYgK+9uwG85/OCINVZag7UOOtifolU2NE4YkkW7liUNcIC6BZgykPNFD4W/n0usXmzzjAhPYKY1mkAAdAdEUL0nYcDdIc7xiE9cWLamqYz/OIuL8;25:Av19edpc6vwZ3h+pSirnT+q3X1YgMKJavKdDQ77HdKMDoDXNYq6uFzGXRg8/ulM/AgRUDVASFZKryWLxVGSEXYky7qs8SbLfmk9CESB8n+ko0IhBRZwaSMlQCtDXV0cy1gDjSrAFHeW6VM/XVvACMgday6lRJrmIPmxCGxAZ6CM/dBHT74Je02GkVdCi56HPKSktYlfgKF9UDy8JCu+XecPEWHr4xINelY1ZmWf0aGq+Le3SV6WQZiDP7gyGeyFMoHkhLPZ27Rov6Xfda8M7BdYX0IDgVYYsQaXo26fJvBW2re6PhpnH8Va+Wi2PTCVzWmidFJD1r890R04OfUSm+A==;31:km1Jmy4z9+ORFV6HAipDdV8tsHrdzIsStVRSM88Hdetj4bESfxB9T3Nmh/+QoixDCG/YCo7bpifnBnGNWmWI2FsNQedyYmryIX8/0XFw5tkso3qOZpf4eRPhQfBDe0BVaVt6MPiUgsVG+gdEJwq5m9KqbmzjGdhysu1Ny/tMYh+ZMWl+eh/hxnq1UFndtHAmjz5lXg4FAD5sO6763Mgya+LPm8zQ11+NA7TYcLJqq+c= X-MS-TrafficTypeDiagnostic: DB6PR0202MB2775: X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192374486261705)(8104003914727); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(93001095)(3231254)(944501410)(52105095)(6041310)(20161123560045)(20161123562045)(20161123564045)(2016111802025)(20161123558120)(6043046)(6072148)(201708071742011);SRVR:DB6PR0202MB2775;BCL:0;PCL:0;RULEID:;SRVR:DB6PR0202MB2775; X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;4:eFNR58z8sBCA1Z9VzYQaOCILu64Z3rJoA0mHcDId1K7Ynszo7P38m0SWAzPG/aXPx/A5TP4AcofzDgxWd1nX523A3+nz0/7ARRyEw9IEzuV93HIEnM0uXI2Wd0YD1ap3ROoudH6EPlK1EDVFenSE1Ay9aS4zz3zsDR7mwB2Wso3zwgEV5lWIV47NWv57fuDI/7Vg5iuGfoLpGO7aVRgKdcrmou3M9lzpN5ckyOesLcrfUEdVLivOXO/dmVTnQivEk9dmzDB+2NlDc/GegnC9cR0cVbhEPYFJ7js6FoEj93rp2h/7eF4DV/WYBBYz87ywqL/BAFBVS5arZ86pBpSg2jccEthXW7lCcaYvFr3CPGY= X-Forefront-PRVS: 06628F7CA4 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(6049001)(346002)(376002)(39380400002)(366004)(39830400003)(396003)(377424004)(189003)(199004)(81156014)(68736007)(86362001)(52146003)(6916009)(31696002)(77096007)(26005)(50466002)(54906003)(478600001)(97736004)(47776003)(81166006)(25786009)(3260700006)(36916002)(486006)(5660300001)(476003)(11346002)(956004)(316002)(6666003)(58126008)(66066001)(2616005)(65956001)(59450400001)(23676004)(117156002)(65826007)(53546011)(52116002)(186003)(65806001)(16526019)(16576012)(386003)(446003)(105586002)(8936002)(3846002)(305945005)(230700001)(6116002)(8676002)(7736002)(2486003)(2906002)(76176011)(74482002)(36756003)(106356001)(6486002)(2171002)(6246003)(229853002)(64126003)(31686004)(53936002)(4326008)(42262002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB6PR0202MB2775;H:[192.168.13.3];FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;MX:1;A:1; Received-SPF: None (protection.outlook.com: axentia.se does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?utf-8?B?MTtEQjZQUjAyMDJNQjI3NzU7MjM6WG52RDF2QjZMcnYvVFVwVWR3bkk2Znlt?= =?utf-8?B?VDJWN2M2RDNja3grazhRSmlFQlZNRVVsSGNUUmhFTXpMaklQY0ZZe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tkw186wSk+1FdQHpC60i6XW5NLWhSPEUw==;5:cVfTNi1XkQN91T0nvmH7/axzQzixFXkIb8FJvtuqLHW/x7v+xBDWOeyi+b4R+dK8B2NnZl7dvR6idrq00sgWPGDGGZiDOE9/jQnRgyBOQzZ22pcJEcJfKHpE1MfoBlarHxZui6OzNxkqZ68IXTAFmuYB0N2H8dREYCWeGq50lmQ=;24:NXl87mqDF3ii43sKubCjOCJluVQ0b1FTv4HHKHZMrpY54ANh6RVOu6mStWjxydRW2YKLjrqpUEG53tNMery624SFKP3SFZSQEPPYYXLJR24= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;DB6PR0202MB2775;7:4MCQtHLc6Co0qzjNSwV77NMiB2mP1nzqycrDi+fffRU8V7+FCeEK3oxdhmnGTtgf/wHhm2p8SbenCW8CTqAaz5wPYhvkv7Ac7syckelGNuXV9Dd8bvDOFmw6lU4sCH8kJxYjlh+Jd//wKSn9/1UC9PXT+yWmr9bPm4zCD9G1oOUggqt9qXDxXGL3Mgju5sYZk+eq1/Vvub66yL1dwb5IG5zSidEfRtclGc9qBOP/QcX0R4pXgak4mEX18ZR+dXbe X-MS-Office365-Filtering-Correlation-Id: 538953df-ec66-4c8c-ab51-08d5b17c8d11 X-OriginatorOrg: axentia.se X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 May 2018 05:04:44.0474 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 538953df-ec66-4c8c-ab51-08d5b17c8d11 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 4ee68585-03e1-4785-942a-df9c1871a234 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR0202MB2775 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2018-05-04 06:08, Wenwen Wang wrote: > On Thu, May 3, 2018 at 3:34 PM, Peter Rosin wrote: >> On 2018-05-03 00:36, Wenwen Wang wrote: >>> In i2c_smbus_xfer_emulated(), there are two buffers: msgbuf0 and msgbuf1, >>> which are used to save a series of messages, as mentioned in the comment. >>> According to the value of the variable "size", msgbuf0 is initialized to >>> various values. In contrast, msgbuf1 is left uninitialized until the >>> function i2c_transfer() is invoked. However, mgsbuf1 is not always >>> initialized on all possible execution paths (implementation) of >>> i2c_transfer(). Thus, it is possible that mgsbuf1 may still not be >> >> double negation here >> >>> uninitialized even after the invocation of the function i2c_transfer(). In >>> the following execution, the uninitialized msgbuf1 will be used, such as >>> for security checks. Since uninitialized values can be random and >>> arbitrary, this will cause undefined behaviors or even check bypass. For >>> example, it is expected that if the value of "size" is >>> I2C_SMBUS_BLOCK_PROC_CALL, the value of data->block[0] should not be larger >>> than I2C_SMBUS_BLOCK_MAX. But, at the end of i2c_smbus_xfer_emulated(), the >>> value read from msgbuf1 is assigned to data->block[0], which can >>> potentially lead to invalid block write size, as demonstrated in the error >>> message. >>> >>> This patch simply initializes the buffer msgbuf1 with 0 to avoid undefined >>> behaviors or security issues. >>> >>> Signed-off-by: Wenwen Wang >>> --- >>> drivers/i2c/i2c-core-smbus.c | 2 +- >>> 1 file changed, 1 insertion(+), 1 deletion(-) >>> >>> diff --git a/drivers/i2c/i2c-core-smbus.c b/drivers/i2c/i2c-core-smbus.c >>> index b5aec33..0fcca75 100644 >>> --- a/drivers/i2c/i2c-core-smbus.c >>> +++ b/drivers/i2c/i2c-core-smbus.c >>> @@ -324,7 +324,7 @@ static s32 i2c_smbus_xfer_emulated(struct i2c_adapter *adapter, u16 addr, >>> * somewhat simpler. >>> */ >>> unsigned char msgbuf0[I2C_SMBUS_BLOCK_MAX+3]; >>> - unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2]; >>> + unsigned char msgbuf1[I2C_SMBUS_BLOCK_MAX+2] = {0}; >> >> I think this will result in the whole of msgbuf1 being filled with zeroes. >> It might be cheaper to do this with code proper rather than with an >> initializer? > > Thanks for your comment, Peter! How about using a memset() only when > i2c_smbus_xfer_emulated() emulates reading commands, since msgbuf1 is > used only in that case? I was thinking that an assignment of msgbuf1[0] = 0; would be enough in the I2C_SMBUS_BLOCK_DATA and I2C_SMBUS_BLOCK_PROC_CALL cases before the i2c_transfer call. However, this will only kick in if the call to kzalloc fails (and it most likely will not) in the call to the i2c_smbus_try_get_dmabuf helper. So, this thing that you are trying to fix seems like a non-issue to me. However, while looking I think the bigger problem with that function is that it considers all non-negative return values from i2c_transfer as good. IMHO, it should barf on any return values <> num. Or at the very least describe why a partial result is considered OK... Cheers, Peter >> >> Cheers, >> Peter >> >>> int num = read_write == I2C_SMBUS_READ ? 2 : 1; >>> int i; >>> u8 partial_pec = 0; >>> >>