From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753973AbbCYOLm (ORCPT ); Wed, 25 Mar 2015 10:11:42 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:35586 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753416AbbCYOLh (ORCPT ); Wed, 25 Mar 2015 10:11:37 -0400 Message-ID: <5512C213.7030705@roeck-us.net> Date: Wed, 25 Mar 2015 07:11:31 -0700 From: Guenter Roeck User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Wolfram Sang CC: linux-i2c@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] eeprom: at24: Add support for large EEPROMs connected to SMBus adapters References: <20150205002630.GA396@roeck-us.net> <20150205144028.GA4865@katana> <20150205175326.GA26691@roeck-us.net> <20150212040126.GA1691@roeck-us.net> <20150216120951.GA2840@katana> <20150317042049.GA6765@roeck-us.net> <20150318132707.GD3580@katana> <550A4162.8000009@roeck-us.net> <20150319081612.GA900@katana> <20150319174314.GA17329@roeck-us.net> <20150319213937.GA899@katana> In-Reply-To: <20150319213937.GA899@katana> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-CTCH-PVer: 0000001 X-CTCH-Spam: Unknown X-CTCH-VOD: Unknown X-CTCH-Flags: 0 X-CTCH-RefID: str=0001.0A020201.5512C217.0434,ss=1,re=0.001,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 X-CTCH-Score: 0.001 X-CTCH-ScoreCust: 0.000 X-CTCH-Rules: C_4847, X-CTCH-SenderID: linux@roeck-us.net X-CTCH-SenderID-Flags: 0 X-CTCH-SenderID-TotalMessages: 1 X-CTCH-SenderID-TotalSpam: 0 X-CTCH-SenderID-TotalSuspected: 0 X-CTCH-SenderID-TotalConfirmed: 0 X-CTCH-SenderID-TotalBulk: 0 X-CTCH-SenderID-TotalVirus: 0 X-CTCH-SenderID-TotalRecipients: 0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: mailgid no entry from get_relayhosts_entry X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 03/19/2015 02:39 PM, Wolfram Sang wrote: > >> Turns out this is really easy to reproduce. One process reads >> the eeprom over and over again, another runs i2cdump in a loop, >> and voila ... lots of corruptions. Scary, especially considering >> how wide-spread this kind of i2c access is in the kernel. > > A coccinelle script should at least be able to find vulnerable code > paths, maybe even fix it. But not today for me... Thanks for testing and > sharing the results! > Wolfram, just to give you an update: I do have some code, but it is a bit messy, and it doesn't work well for ds2482 (the chip behind it still hangs up if I access it in parallel through i2c-dev). On top of that, it causes pretty significant slow-downs when accessing other devices on the same bus at the same time. Not surprising, I guess, since it expands the scope of the bus lock significantly. I thought about introducing a client lock, but that does not work because of the way i2c-dev is written (creating its own 'shadow' client structure). An address lock (ie a client lock based on instead of one residing in the client structure) seems to be too expensive. So right now I don't really know how to proceed, or if to proceed at all. I'll think about it some more, but given how wide-spread the problem is in the kernel, I might just leave it alone, and keep the at24 changes out of tree. Ultimately, the real problem is how i2c-dev accesses a client, not how i2c client drivers (who assume they have exclusive access to a chip) handle multi-command sequences. Forcing extensive locking on all drivers because of i2c-dev just doesn't seem to be the right thing to do. Guenter