Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp3841088ybh; Tue, 17 Mar 2020 07:34:19 -0700 (PDT) X-Google-Smtp-Source: ADFU+vuIfjdsUYWylenGEigXkD+kx8ZSsZqxK18R6gBisB9Vtbq8lhdu6RPRefkHZrXa737tCPAP X-Received: by 2002:a05:6830:1087:: with SMTP id y7mr3871211oto.342.1584455659125; Tue, 17 Mar 2020 07:34:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584455659; cv=none; d=google.com; s=arc-20160816; b=TE9ZBIf16XH4SxGUc4rhfKdu3ZQPHFzzQqy619LY+uWtTLH08ZhxslqkZheht6BicN Mb0AW0Gw7ozeMIKDH8/LZPSFTN94WtBtP/fuxAaUMW+16M0DgFULAsLD8dZy2UEV3ZXz PsxeJOZQzTIArOW0dzKVP+xEvi+GYJPrtIBZ1IjeDCny+IzbOfnni3LotsO1DZ6+juYs 18RxrYwZLyfoGIAk/5jSYs3DWerI57FrA4QWyeKC3vSE40ZVq4psZL9YAAb2XrkqfWZ2 wGcSqQmdYDWLhPR8UetgrEbHuNW2ilEOXXs4uUMjoAwQd8CaYgFBlj7fEQngfX29mLke KUIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=A16GKmGMQWpRq+C/pSuTHqsjWsmIXgAuO5lJtoXiC5Q=; b=gOOWaILJYEYIhMXD/ayLsxvvnly/YQR7VADSXfirQVbZS40QfH+G0+r73VZxEfOMAd drkJ5KaSWpxOslVPnbrMceE1hwG0AuLQxgT1hmlenivo59+kLu4eNGf9LU9orajfHsF7 OMqgf4+DYvZDdsSsL1CQBnic5wOCR/MdJMHvyb2wCLe5SWv9rZjRZR2GDeM39HWkPDdJ jOMBjtAmcH75TAD+Nh1+fNMAeOHHxuCnXKhvWQ5jipp45cRpZK2K6C2BksWLakI9y3oy ZuddJMQkMqSa0DOhjnqaOlMhTjS15rzuWZO7V+mofCR1amOGwVmAeoYu1WgWSLEyZ4+/ n6IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=qqWQiotn; 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 x13si1842818otk.230.2020.03.17.07.34.06; Tue, 17 Mar 2020 07:34:19 -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=@bgdev-pl.20150623.gappssmtp.com header.s=20150623 header.b=qqWQiotn; 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 S1726650AbgCQOdI (ORCPT + 99 others); Tue, 17 Mar 2020 10:33:08 -0400 Received: from mail-il1-f193.google.com ([209.85.166.193]:46681 "EHLO mail-il1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726473AbgCQOdH (ORCPT ); Tue, 17 Mar 2020 10:33:07 -0400 Received: by mail-il1-f193.google.com with SMTP id e8so20248239ilc.13 for ; Tue, 17 Mar 2020 07:33:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=A16GKmGMQWpRq+C/pSuTHqsjWsmIXgAuO5lJtoXiC5Q=; b=qqWQiotn5sHUFeq/EZSUci/cJTumNXaJzM+4NCGpIavzOOC1vtdduNrHZQ+2KeCHq+ zGqz4TZIsNxUBA3xm5dNyOaQYibvZDrs8+bHQW8N/1nzErK42Fnt+6fwdjTX4mUoly9l Mz094tkzcLMYSTKpNWZ8GP68mMOaVy2upg0/U5i/JV1XHS6ovhtOh3ssme9nIogkfqnJ ea72EXipKtu9cFfzXEX3+1gMV6+yit68H0JAzCDxfcguSxOFBkdwPeRp+Ka0c83tfDYV DNzjB1nf3J/0vWH00IP7IfPjng/AbnUAh3gMVCpdhge4xQYnNYSxjJ9RVB1c/9c3p3mT 08rQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=A16GKmGMQWpRq+C/pSuTHqsjWsmIXgAuO5lJtoXiC5Q=; b=t+zcxBRjH33etGgsK04fd7X/zR8wwCYTnnolFNckf2ROX4kX2diC0HwqHwh0rgYT3b lIfDIzm3zBKHzN3YW5+TAnoiQkt+1TQcIhHT2//XllU8YAz7YM/Zoi+TQb1hh6X8k35N DUlYpZO0KSZjMUuZv0DN6HDyGSOYwr4AxUNEH9bHcvSoR8xASBfWOXFDhlwH4DNOeGKJ oPbhusQRY2pSIKnGaSz4JDSvsZMaCq+OGqBql26kx2EN1YHvfVIUU7m66idcqt6nyRiW knyxknZFirj6fY/cHoeUbWSu5XmMk6QPXalJ9Pnmr9yhcK/G/NtfGw45eKBztmpElfOg oRqA== X-Gm-Message-State: ANhLgQ1L+fjghBt4g5C9TcWut5fQnwW2uLZnPnhV2tWsZC9Ibe8mEumt rZ+9McIv/k36AsjUpXWUb90gCyYv86nv1gN2QIjC6g== X-Received: by 2002:a92:d78c:: with SMTP id d12mr5529078iln.287.1584455586881; Tue, 17 Mar 2020 07:33:06 -0700 (PDT) MIME-Version: 1.0 References: <20200317151409.7940926c@endymion> In-Reply-To: <20200317151409.7940926c@endymion> From: Bartosz Golaszewski Date: Tue, 17 Mar 2020 15:32:56 +0100 Message-ID: Subject: Re: VAIO EEPROM support in at24 To: Jean Delvare Cc: LKML , Linux I2C , Bartosz Golaszewski , Arnd Bergmann , Greg Kroah-Hartman Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org wt., 17 mar 2020 o 15:14 Jean Delvare napisa=C5=82(a): > > Hi all, > > As the legacy eeprom driver is being phased out, I am reviewing all its > use cases to ensure that the at24 driver will be a suitable replacement. > > One issue I have found is the handling of specific EEPROMs found on the > SMBus of some Sony VAIO laptops. The legacy eeprom driver would expose > them to user-space, read-only for all users. It would also recognize > them as VAIO EEPROMs and would hide some bytes from non-root users > because these bytes contain the BIOS password in a lightly encoded form. > > In order to keep the same level of functionality, we would have to offer > the same with the at24 driver. At this time, the user has to > instantiate a "24c02" device manually from user-space. By default this > device has permissions 600, which is insufficient for users, and > dangerous for root, so a quick chmod 444 is needed. > > Without the password issue, I would just document the procedure and > live with it. However in order to protect the password from being read > by random users, the driver itself needs to know that it is dealing > with a specific type of EEPROM. It seems that we need to introduce a > new device flavor to the at24 driver for this purpose. > > I see that we already have a number of specific flags (AT24_FLAG_SERIAL > and AT24_FLAG_MAC) so I suppose we could add something similar for > these VAIO EEPROMs. Something like: > > /* Some Sony VAIO laptops have a 24c02 at 0x57 with product info */ > AT24_CHIP_DATA(at24_data_sony_vaio, 2048 / 8, > AT24_FLAG_READONLY | AT24_FLAG_IRUGO | AT24_FLAG_SONY_VAIO); > > Then I suppose it's only a matter of conditionally zeroing a selected > range in at24_read() before it returns, to hide the password from > non-root users. > > Before I start implementing the idea above, I would like to know if > anyone objects to it, or has a better idea? > Sounds good to me in general but isn't it something we could generalize a bit more? For instance we could make at24_chip_data struct look something like this: struct at24_chip_data { u32 byte_len; u8 flags; struct resource masked; }; And we could introduce a new macro called AT24_CHIP_DATA_MASKED that would automacially set the AT24_FLAG_MASKED_RANGE flag and take another argument that would contain the address and size of the masked register range (we'd put it into the "masked" resource)? Other ideas are welcome too. I just think that making it SONY_VAIO-specific may be a bit limiting in the future. Best regards, Bartosz Golaszewski