From patchwork Sat Nov 10 00:35:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rasmus Villemoes X-Patchwork-Id: 10676777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 117BB14E2 for ; Sat, 10 Nov 2018 00:35:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ECBCA2F273 for ; Sat, 10 Nov 2018 00:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D84A82F28F; Sat, 10 Nov 2018 00:35:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6EA132F273 for ; Sat, 10 Nov 2018 00:35:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728058AbeKJKSN (ORCPT ); Sat, 10 Nov 2018 05:18:13 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:34491 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727322AbeKJKSN (ORCPT ); Sat, 10 Nov 2018 05:18:13 -0500 Received: by mail-lf1-f68.google.com with SMTP id p6so2589278lfc.1 for ; Fri, 09 Nov 2018 16:35:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rasmusvillemoes.dk; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XMRV2yGipuBF9ApADA+TXAr8hu/aCqxWcuczhrEuTnk=; b=Z4dx80CNV7E4GV/lLdbydT/nIWvd9Zc+mmVKg0sMlYVMm0FffmwURbPkGRHkSDGJUr 1BTkdAeG7rxl4j98rnEOmHHTyXgH2xMP9WgT/n8tZZQ+j/Aq5FWakt+IYXQio1ZceBlV Y5V46rf3LmLN/a6jW3glIBRAPyJj/FjnhvAEI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=XMRV2yGipuBF9ApADA+TXAr8hu/aCqxWcuczhrEuTnk=; b=KXReGr/Fj1uuTTyc/lWAuPOPNXmfxWB7MMU+cybqQoyv++JLfrecbWoPDWZGmdqF/b j+PT2pPcJBaNtyTBIHZF+mEwqwJz0AAu6hIQck9guzId8sbyfqV/M4KJdJzlLXXC2R1d g9KLD493z0umJDgCOAH4a9Q63A0H/UEai2cSzZmLjYJatAXjz/yPEhoRYzqxGWy92eYC nG79sGJ3HSf2lWr5mANemvp0ULpgDivfn7qTxwXy0a4bCV6JX7RhzvZh4lxbNVslC7iL YKSuVKOgvnF0y9iE6o7Avab8Tf3vCFePkJguxj6GJLBw/c6PEFogYl/UmGefX0anOP6H kiIw== X-Gm-Message-State: AGRZ1gLKQVtHP1pi085VznzQi+zw5VxMUAbbSX18OCVI4U4EQDB6cLT/ 2hjOFlKVi0lvBfinFsnM9XzTJA== X-Google-Smtp-Source: AJdET5ctlZnHmch8b2GPiHgQc38ggSn+KTAYLMCVUZVmwe+XIhzO8FIS4QxGr4lSjRfOwREtm5Tdpg== X-Received: by 2002:a19:1365:: with SMTP id j98mr6313453lfi.55.1541810108937; Fri, 09 Nov 2018 16:35:08 -0800 (PST) Received: from prevas-ravi.prevas.se (dhcp-5-186-114-252.cgn.ip.fibianet.dk. [5.186.114.252]) by smtp.gmail.com with ESMTPSA id 26-v6sm2006603lje.18.2018.11.09.16.35.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Fri, 09 Nov 2018 16:35:08 -0800 (PST) From: Rasmus Villemoes To: Arnd Bergmann , Alexander Viro Cc: linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, Rasmus Villemoes Subject: [PATCH] libfs: make all users of simple_attr_open have the format checked Date: Sat, 10 Nov 2018 01:35:04 +0100 Message-Id: <20181110003504.629-1-linux@rasmusvillemoes.dk> X-Mailer: git-send-email 2.19.1.6.gbde171bbf5 MIME-Version: 1.0 Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Almost all uses of simple_attr_open() happen via macros that do a __simple_attr_check_format(__fmt, 0ull). One of the few exceptions actually does not pass a fmt matching an unsigned long long. So move the check into the call of simple_attr_open() by wrapping it in a macro of the same name, and fix the powerpc case while at it. Signed-off-by: Rasmus Villemoes --- arch/powerpc/platforms/cell/spufs/file.c | 2 +- fs/libfs.c | 1 + include/linux/debugfs.h | 1 - include/linux/fs.h | 6 +++++- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/arch/powerpc/platforms/cell/spufs/file.c b/arch/powerpc/platforms/cell/spufs/file.c index 43e7b93f27c7..b75d70f54f12 100644 --- a/arch/powerpc/platforms/cell/spufs/file.c +++ b/arch/powerpc/platforms/cell/spufs/file.c @@ -436,7 +436,7 @@ static int spufs_cntl_open(struct inode *inode, struct file *file) ctx->cntl = inode->i_mapping; mutex_unlock(&ctx->mapping_lock); return simple_attr_open(inode, file, spufs_cntl_get, - spufs_cntl_set, "0x%08lx"); + spufs_cntl_set, "0x%08llx"); } static int diff --git a/fs/libfs.c b/fs/libfs.c index 0fb590d79f30..327ab701d176 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -792,6 +792,7 @@ struct simple_attr { /* simple_attr_open is called by an actual attribute open file operation * to set the attribute specific access operations. */ +#undef simple_attr_open int simple_attr_open(struct inode *inode, struct file *file, int (*get)(void *, u64 *), int (*set)(void *, u64), const char *fmt) diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index 3b0ba54cc4d5..2ddec401343a 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -42,7 +42,6 @@ extern struct dentry *arch_debugfs_dir; #define DEFINE_DEBUGFS_ATTRIBUTE(__fops, __get, __set, __fmt) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ - __simple_attr_check_format(__fmt, 0ull); \ return simple_attr_open(inode, file, __get, __set, __fmt); \ } \ static const struct file_operations __fops = { \ diff --git a/include/linux/fs.h b/include/linux/fs.h index c95c0807471f..cb79b79d2175 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3387,7 +3387,6 @@ void simple_transaction_set(struct file *file, size_t n); #define DEFINE_SIMPLE_ATTRIBUTE(__fops, __get, __set, __fmt) \ static int __fops ## _open(struct inode *inode, struct file *file) \ { \ - __simple_attr_check_format(__fmt, 0ull); \ return simple_attr_open(inode, file, __get, __set, __fmt); \ } \ static const struct file_operations __fops = { \ @@ -3408,6 +3407,11 @@ void __simple_attr_check_format(const char *fmt, ...) int simple_attr_open(struct inode *inode, struct file *file, int (*get)(void *, u64 *), int (*set)(void *, u64), const char *fmt); +#define simple_attr_open(inode, file, get, set, fmt) ({ \ + if (0) \ + __simple_attr_check_format(fmt, 0ull); \ + simple_attr_open(inode, file, get, set, fmt); \ + }) int simple_attr_release(struct inode *inode, struct file *file); ssize_t simple_attr_read(struct file *file, char __user *buf, size_t len, loff_t *ppos);