From patchwork Wed Jan 11 16:42:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Thomas_Wei=C3=9Fschuh?= X-Patchwork-Id: 13096946 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2B47CC5479D for ; Wed, 11 Jan 2023 16:43:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232556AbjAKQnW (ORCPT ); Wed, 11 Jan 2023 11:43:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234628AbjAKQmm (ORCPT ); Wed, 11 Jan 2023 11:42:42 -0500 Received: from todd.t-8ch.de (todd.t-8ch.de [159.69.126.157]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0ECC6164B4; Wed, 11 Jan 2023 08:42:13 -0800 (PST) From: Thomas =?utf-8?q?Wei=C3=9Fschuh?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=weissschuh.net; s=mail; t=1673455331; bh=oPHeqffJWnugBEy5BfA0S5pz/LFEC+mvhbSZ1LgHT58=; h=From:Date:Subject:To:Cc:From; b=uC9H5QXx7fmv+zhsei6EGCF/6P/ONA27ENwGoqmlOvXE491AVx4VG+fYsmyTxdToD smpW96FSWIu3Ql0VweMOclcGL4zNUzBfeQ2rqr1rtqPm+hlwsNk1PIvX15W0QT3a7W rwA3pQ0yLvFXXhGlvdBvGtCP5Ixol6EzzqdQC1mo= Date: Wed, 11 Jan 2023 16:42:07 +0000 Subject: [PATCH RESEND] nsfs: add compat ioctl handler MIME-Version: 1.0 Message-Id: <20221214-nsfs-ioctl-compat-v1-1-3180bf297a02@weissschuh.net> To: Alexander Viro , Andrey Vagin , "Eric W. Biederman" , Serge Hallyn Cc: Karel Zak , Thomas =?utf-8?q?Wei=C3=9Fschuh?= , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org X-Mailer: b4 0.11.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1673455329; l=1998; i=linux@weissschuh.net; s=20221212; h=from:subject:message-id; bh=oPHeqffJWnugBEy5BfA0S5pz/LFEC+mvhbSZ1LgHT58=; b=tzvA9e99k86pJFluK36zg2SRWMLBn1EeQhsLRb6yMGnq59eSxNS8B/XA0kkQdc3HO7R7O5l+XtQA b3I2140ODuPWNtO7N2RYz5akkOlebbCFDv3vLRnsBcIZVTaCd2Wu X-Developer-Key: i=linux@weissschuh.net; a=ed25519; pk=KcycQgFPX2wGR5azS7RhpBqedglOZVgRPfdFSPB1LNw= Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org As all parameters and return values of the ioctls have the same representation on both 32bit and 64bit we can reuse the normal ioctl handler for the compat handler. All nsfs ioctls return a plain "int" filedescriptor which is a signed 4-byte integer type on both 32bit and 64bit. The only parameter taken is by NS_GET_OWNER_UID and is a pointer to a "uid_t" which is a 4-byte unsigned integer type on both 32bit and 64bit. Fixes: 6786741dbf99 ("nsfs: add ioctl to get an owning user namespace for ns file descriptor") Reported-By: Karel Zak Signed-off-by: Thomas Weißschuh --- As all parameters and return values of the ioctls have the same representation on both 32bit and 64bit we can reuse the normal ioctl handler for the compat handler. All nsfs ioctls return a plain "int" filedescriptor which is a signed 4-byte integer type on both 32bit and 64bit. The only parameter taken is by NS_GET_OWNER_UID and is a pointer to a "uid_t" which is a 4-byte unsigned integer type on both 32bit and 64bit. --- To: Alexander Viro To: Andrey Vagin To: "Eric W. Biederman" To: Serge Hallyn Cc: linux-fsdevel@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Karel Zak --- fs/nsfs.c | 1 + 1 file changed, 1 insertion(+) --- base-commit: f9ff5644bcc04221bae56f922122f2b7f5d24d62 change-id: 20221214-nsfs-ioctl-compat-1548bf6581a7 Best regards, diff --git a/fs/nsfs.c b/fs/nsfs.c index 3506f6074288..4d2644507364 100644 --- a/fs/nsfs.c +++ b/fs/nsfs.c @@ -21,6 +21,7 @@ static long ns_ioctl(struct file *filp, unsigned int ioctl, static const struct file_operations ns_file_operations = { .llseek = no_llseek, .unlocked_ioctl = ns_ioctl, + .compat_ioctl = ns_ioctl, }; static char *ns_dname(struct dentry *dentry, char *buffer, int buflen)