From patchwork Fri Jun 7 01:59:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Al Viro X-Patchwork-Id: 13689210 Received: from zeniv.linux.org.uk (zeniv.linux.org.uk [62.89.141.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A7E9A14006 for ; Fri, 7 Jun 2024 02:00:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=62.89.141.173 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717725603; cv=none; b=hsML7+IyJ6RSmPhQtCZYwBjlMSSoc6+A93qMeSVfmhLBob7t5vcEDDx/CcBNt/C6QMcZbCp/GZ6Hvnb2c0C/EsM0dWyZSMbpXdbPDaOZN7Mz5eyf67gPsrknc+W6VSzzv6p/RGa/SrDykRzxRWlwNVWnE8ok2gp5ge7TDmGhtzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717725603; c=relaxed/simple; bh=238ITop5zgw47P6cKcj0FJSRnfIHutok/+7yi1YPHQ8=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=tqzdjirfpqaXwNvQHXTG0U6Ojd+XwEzC+3Ss8S90PMhvyqHDLIQa73gKKDA370WC9vheSADMn3Yh7Xmt6dgdTIaBgr43k4iJYiMRo52kTVWB0aGFzrKMAN7z97WlDvl+z16BNrXiJ1wEehIdxxKzXbDUKUve6WgvrlPbqRGq2HE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk; spf=none smtp.mailfrom=ftp.linux.org.uk; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b=QZCVt7qM; arc=none smtp.client-ip=62.89.141.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=zeniv.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; spf=none smtp.mailfrom=ftp.linux.org.uk Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linux.org.uk header.i=@linux.org.uk header.b="QZCVt7qM" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=linux.org.uk; s=zeniv-20220401; h=Sender:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description; bh=MwmcXg7tR969Vt74h171bcBgtB/eO98pk7IcSbDC5Ms=; b=QZCVt7qMMmWmQfL6sVhyjCl8BX 1Vko81HgYIDoB6uFRPLEaSqRieFW1PPaXW7d3U4AKUBrfQ7MSZyNdUS9Q1kmCU7eXjgcMuNkECnyK iJBRKkMGqQ362GWwcMaZw132CPy3cnLA6p4ZKLcVxIYkqc/uO0X4xzVVBpNSxoiZ0alo4rRKXSATB 2Oz1f5O+egbJluPGZ8XmtgUmsbN+UK+G/IfI27VAI4uFk4JWszXLM+a36Yt2QEO8h1IMngLIUuAzB uIMBK+ZFSgFOK+bdnpRS3tW2CkNCh/q4QtQ3x/0EsIYUm0WT12iYqW7lJzYv9H1jhh/2PcdxShqfa Qy6SgkRw==; Received: from viro by zeniv.linux.org.uk with local (Exim 4.96 #2 (Red Hat Linux)) id 1sFOtc-009xCV-0X; Fri, 07 Jun 2024 02:00:00 +0000 From: Al Viro To: linux-fsdevel@vger.kernel.org Cc: brauner@kernel.org, torvalds@linux-foundation.org Subject: [PATCH 14/19] finit_module(): convert to CLASS(fd, ...) Date: Fri, 7 Jun 2024 02:59:52 +0100 Message-Id: <20240607015957.2372428-14-viro@zeniv.linux.org.uk> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240607015957.2372428-1-viro@zeniv.linux.org.uk> References: <20240607015656.GX1629371@ZenIV> <20240607015957.2372428-1-viro@zeniv.linux.org.uk> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Sender: Al Viro Slightly unidiomatic emptiness check; just lift it out of idempotent_init_module() and into finit_module(2) and that's it. Signed-off-by: Al Viro --- kernel/module/main.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/kernel/module/main.c b/kernel/module/main.c index 98fda13fdca7..f2f045b3740d 100644 --- a/kernel/module/main.c +++ b/kernel/module/main.c @@ -3177,7 +3177,7 @@ static int idempotent_init_module(struct file *f, const char __user * uargs, int { struct idempotent idem; - if (!f || !(f->f_mode & FMODE_READ)) + if (!(f->f_mode & FMODE_READ)) return -EBADF; /* See if somebody else is doing the operation? */ @@ -3193,10 +3193,7 @@ static int idempotent_init_module(struct file *f, const char __user * uargs, int SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) { - int err; - struct fd f; - - err = may_init_module(); + int err = may_init_module(); if (err) return err; @@ -3207,10 +3204,10 @@ SYSCALL_DEFINE3(finit_module, int, fd, const char __user *, uargs, int, flags) |MODULE_INIT_COMPRESSED_FILE)) return -EINVAL; - f = fdget(fd); - err = idempotent_init_module(fd_file(f), uargs, flags); - fdput(f); - return err; + CLASS(fd, f)(fd); + if (fd_empty(f)) + return -EBADF; + return idempotent_init_module(fd_file(f), uargs, flags); } /* Keep in sync with MODULE_FLAGS_BUF_SIZE !!! */