From patchwork Fri May 9 13:39:22 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yuvaraj CD X-Patchwork-Id: 4143441 Return-Path: X-Original-To: patchwork-linux-mmc@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6E2CA9F1E1 for ; Fri, 9 May 2014 13:39:43 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A0646201DD for ; Fri, 9 May 2014 13:39:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 951F6201E7 for ; Fri, 9 May 2014 13:39:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750780AbaEINjk (ORCPT ); Fri, 9 May 2014 09:39:40 -0400 Received: from mail-pa0-f47.google.com ([209.85.220.47]:45200 "EHLO mail-pa0-f47.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753305AbaEINjj (ORCPT ); Fri, 9 May 2014 09:39:39 -0400 Received: by mail-pa0-f47.google.com with SMTP id lf10so1898961pab.34 for ; Fri, 09 May 2014 06:39:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=Iu3vMWubvIlZW7Kb186rjwXwIU+C5IK5cHN01yIV/0Y=; b=gBUZAgr0/8fFFH1wvjq+yLkj3mgsj9mE4WtYYossUi52p5uMLquQv+mlqwqbXR+fzh NJ/liSQavs8cFSGnEIyah7M34b22xfxx25glEIL09GECS2px64HEIqJLs30uRx3fIz51 LyKhqKInn5zVBhWc8LBGeubMlbdmkwoojjUBYd3rYWmiXK7MlcEI9uLN8zKaPyJjZFcX jOHoDePPIiXRnTS7IBt/6ONMiMCHZuSbEp33W5PPtCGie9T2gzGJxNK5U23sb5x59bQy tyTDcwyYINIXh4cfGBTHWBLldsLg+8h0SVwNECHPtlNw5IHOhNjm3ol/gD6SPn19ODOK AT1w== X-Received: by 10.66.122.101 with SMTP id lr5mr20602237pab.130.1399642779240; Fri, 09 May 2014 06:39:39 -0700 (PDT) Received: from localhost.localdomain ([14.140.216.146]) by mx.google.com with ESMTPSA id x5sm7717893pbw.26.2014.05.09.06.39.34 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 09 May 2014 06:39:38 -0700 (PDT) X-Google-Original-From: Yuvaraj Kumar C D From: Yuvaraj Kumar C D To: grundler@chromium.org, linux-samsung-soc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, jh80.chung@samsung.com, cjb@laptop.org, tgih.jun@samsung.com, linux-mmc@vger.kernel.org, sonnyrao@chromium.org, kgene.kim@samsung.com, joshi@samsung.com Cc: t.figa@samsung.com, Andrew Bresticker , Yuvaraj Kumar C D Subject: [PATCH] mmc: card: restrict access to RPMB partition Date: Fri, 9 May 2014 19:09:22 +0530 Message-Id: <1399642762-11149-1-git-send-email-yuvaraj.cd@samsung.com> X-Mailer: git-send-email 1.7.10.4 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Andrew Bresticker The RPMB partition should only be accessed through the RPMB ioctls and not through read()/write(). This patch makes mmc_blk_open() reject open attempts to the RPMB partition in read or write mode. Signed-off-by: Andrew Bresticker Signed-off-by: Yuvaraj Kumar C D --- drivers/mmc/card/block.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/mmc/card/block.c b/drivers/mmc/card/block.c index 452782b..fd59090 100644 --- a/drivers/mmc/card/block.c +++ b/drivers/mmc/card/block.c @@ -297,7 +297,15 @@ static int mmc_blk_open(struct block_device *bdev, fmode_t mode) check_disk_change(bdev); ret = 0; - if ((mode & FMODE_WRITE) && md->read_only) { + /* + * Reject read/write access to the RPMB partition. It should + * only be accessed through ioctls. + */ + if ((mode & (FMODE_READ | FMODE_WRITE)) && + md->area_type & MMC_BLK_DATA_AREA_RPMB) { + mmc_blk_put(md); + ret = -EACCES; + } else if ((mode & FMODE_WRITE) && md->read_only) { mmc_blk_put(md); ret = -EROFS; }