From nobody Tue Dec 16 12:42:13 2025 Received: from mout-p-102.mailbox.org (mout-p-102.mailbox.org [80.241.56.152]) (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 9FC532233B; Wed, 31 Jul 2024 13:18:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722431912; cv=none; b=d7T6871mJrI35rEE4Vh7m+6tXeV4xwVBTpX9LCau8XWm4g3L7fgqy621H2iMBR/9vfqMJKzQviaJ57K55oFRm9lpPfioS6q2rwCMBicb+L6R2I+eZOY0eZ++l5Vn7YJeA0GwE8TWAqUehV3ld/k0rNl07NNAmiWwSdFjAqcBKq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722431912; c=relaxed/simple; bh=/VEJGnSWOSqDnDdrzEuu/8iETN3Z7ba7UQDPiaLQA8E=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=mBRyk2o4KC4A7FrpIDA9O+ppCOMWKd7A7JtXRyWsvjWFvhCyRYlHw5hZefrQR1WkdDtCoLt/Ib2ZvwOR8GkhT6iHhQtDTlGkj2wVOtLpYNL0AvsQNBEEV7p3JmnZmuPLECy4fJA4GMfv3Ya6FsPtr+FDh6d6qj7H+zEyis1++RU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cyphar.com; spf=pass smtp.mailfrom=cyphar.com; dkim=pass (2048-bit key) header.d=cyphar.com header.i=@cyphar.com header.b=ih7psWOs; arc=none smtp.client-ip=80.241.56.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cyphar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cyphar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cyphar.com header.i=@cyphar.com header.b="ih7psWOs" Received: from smtp2.mailbox.org (smtp2.mailbox.org [10.196.197.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-102.mailbox.org (Postfix) with ESMTPS id 4WYst339Njz9sdW; Wed, 31 Jul 2024 15:11:07 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyphar.com; s=MBO0001; t=1722431467; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=UoyUMOZouuzF91cuExshplUZTqo7hVxyZamaN+f7aVY=; b=ih7psWOsbTyFlQ5ybfru88YNQybHXeRobEAMQOWOYxZ8P4FYmozGNu+K6vPx3H/PxBFksy j83mo7cl8rfQ90vZcl2WESDe/uUqOLQhIVGZBBcV0ajpkUydoUU8pn0fnevwyrkJ6MXFg/ ovbNCmF78tsbtgwsCki9DTIvi1RK5s1DAKTXKsuDtJZA7hxg9iFtWq8gsiEmbBSA4BfeZA A0OtYsHyvEFRZ5KbO8ddXr+3xxaLWwEKOZOALYjevekqJ9Yf8Lh5DL9K8HEXihucyE4gF/ GtjFTFpxZ46aYqNiI4NqunLV6FgWpjS2GEiwbBrUoUqr/ywQYh9N46aPNddwhA== From: Aleksa Sarai Date: Wed, 31 Jul 2024 23:10:27 +1000 Subject: [PATCH v2 1/2] autofs: fix missing fput for FSCONFIG_SET_FD Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240731-fsconfig-fsparam_fd-fixes-v2-1-e7c472224417@cyphar.com> References: <20240731-fsconfig-fsparam_fd-fixes-v2-0-e7c472224417@cyphar.com> In-Reply-To: <20240731-fsconfig-fsparam_fd-fixes-v2-0-e7c472224417@cyphar.com> To: Ian Kent , Bill O'Donnell , Christian Brauner , Jan Harkes , coda@cs.cmu.edu, Eric Sandeen , David Howells Cc: autofs@vger.kernel.org, linux-kernel@vger.kernel.org, codalist@coda.cs.cmu.edu, Aleksa Sarai X-Developer-Signature: v=1; a=openpgp-sha256; l=810; i=cyphar@cyphar.com; h=from:subject:message-id; bh=/VEJGnSWOSqDnDdrzEuu/8iETN3Z7ba7UQDPiaLQA8E=; b=owGbwMvMwCWmMf3Xpe0vXfIZT6slMaStMr/94vuiyZM363xQ7bwUsDxywRnGV95PQz5I+U14J T3XX81wZkcpC4MYF4OsmCLLNj/P0E3zF19J/rSSDWYOKxPIEAYuTgGYiIckI8OkBc6HDomlc6VJ OaaI7Wb3+RZ3a8uF1g7J3m12IdfbcgIZGQ59kbGL5fKJOaFZUvbga/6JJcl+W63mevVMCZ93XvG KBh8A X-Developer-Key: i=cyphar@cyphar.com; a=openpgp; fpr=C9C370B246B09F6DBCFC744C34401015D1D2D386 If you pass an fd using FSCONFIG_SET_FD, autofs_parse_fd() "steals" the param->file and so the fs_context infrastructure will not do fput() for us. Fixes: e6ec453bd0f0 ("autofs: convert autofs to use the new mount api") Signed-off-by: Aleksa Sarai --- fs/autofs/inode.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/autofs/inode.c b/fs/autofs/inode.c index cf792d4de4f1..64faa6c51f60 100644 --- a/fs/autofs/inode.c +++ b/fs/autofs/inode.c @@ -172,8 +172,7 @@ static int autofs_parse_fd(struct fs_context *fc, struc= t autofs_sb_info *sbi, ret =3D autofs_check_pipe(pipe); if (ret < 0) { errorf(fc, "Invalid/unusable pipe"); - if (param->type !=3D fs_value_is_file) - fput(pipe); + fput(pipe); return -EBADF; } =20 --=20 2.45.2 From nobody Tue Dec 16 12:42:13 2025 Received: from mout-p-202.mailbox.org (mout-p-202.mailbox.org [80.241.56.172]) (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 3FF9F1B1425; Wed, 31 Jul 2024 13:11:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=80.241.56.172 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722431484; cv=none; b=M17WVeejz15RhGh88M/Qq6hyxIJ4yO1kJk4tr9Kx8trrr40pjLrXgz6IFMqyhbeccHUgo5E+klqQzTSQf8JEU+l2v4OQ9g7Cq0RS53sbGg2+fnIY06Xpf7aihIZpweVFW5O5EXM7jeU/lC3GYZgqEZYj0Jra5JeQgkzj4oFQmFA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1722431484; c=relaxed/simple; bh=nwwox7wiK60TjQf4dnqdHdDLigJoZ2vLTf1McgQxlUk=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=EWwfL2zrDJRwvhpGDv5FZnfQZr12hVlAOsR2WF0P1ld2S95tlxgrvromoYmQB7UwkpF7ymCUkRpejAtmFkPvRkG2IMeKMMGDgpX5GYqI05azksoaun6v5mTGTIppZzRer3S04yltJ6eQMrqfjrUAbY6ClYwNDrADm/Lug25gmvk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cyphar.com; spf=pass smtp.mailfrom=cyphar.com; dkim=pass (2048-bit key) header.d=cyphar.com header.i=@cyphar.com header.b=wi3lp5NS; arc=none smtp.client-ip=80.241.56.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=cyphar.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=cyphar.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=cyphar.com header.i=@cyphar.com header.b="wi3lp5NS" Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:b231:465::2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-202.mailbox.org (Postfix) with ESMTPS id 4WYst83HGXz9sbh; Wed, 31 Jul 2024 15:11:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cyphar.com; s=MBO0001; t=1722431472; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=QQ64E/5nYDkIveNsG21KEe7BJushDixGGpF55h3Bonk=; b=wi3lp5NSpCLCDDduDAlP6r5I00LJflSASHMSR2aqTReEs24dzJNh2t1dF5Pf3TiW4G7IsL R7dcXwiVTh/24sOyUUTihJDOr52Sl7ZJmthd7S9kIQxujRHVKzK7C8kT4PfA5FOwKdupU+ vk+lkSkYAGWN27x/knFWfEiF/2t+NwcjViPD1kaTOwF4jCDg8gBs8UkT54nFyy0gWUg6qc +uc1wQC7R3Tz7CRL+J+9bfZPVnV6nWif0waspS0as9nSAIuTJx8ImYM1t9BWvQ08M1DYpo CvR64xRGX0n7jACdxctZRo+sodLqZoMd0mgXCH9k72RAq7WZxlbR6scfOZEheg== From: Aleksa Sarai Date: Wed, 31 Jul 2024 23:10:28 +1000 Subject: [PATCH v2 2/2] coda: use param->file for FSCONFIG_SET_FD Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20240731-fsconfig-fsparam_fd-fixes-v2-2-e7c472224417@cyphar.com> References: <20240731-fsconfig-fsparam_fd-fixes-v2-0-e7c472224417@cyphar.com> In-Reply-To: <20240731-fsconfig-fsparam_fd-fixes-v2-0-e7c472224417@cyphar.com> To: Ian Kent , Bill O'Donnell , Christian Brauner , Jan Harkes , coda@cs.cmu.edu, Eric Sandeen , David Howells Cc: autofs@vger.kernel.org, linux-kernel@vger.kernel.org, codalist@coda.cs.cmu.edu, Aleksa Sarai X-Developer-Signature: v=1; a=openpgp-sha256; l=2629; i=cyphar@cyphar.com; h=from:subject:message-id; bh=nwwox7wiK60TjQf4dnqdHdDLigJoZ2vLTf1McgQxlUk=; b=owGbwMvMwCWmMf3Xpe0vXfIZT6slMaStMr/NMrdn2aTmilCz9wvy+Lm/p8Yyzdie9257pCPTb ZZ7pxzLO0pZGMS4GGTFFFm2+XmGbpq/+Eryp5VsMHNYmUCGMHBxCsBE7p5h+MPx+Ufhr7e7gx3c Wd1m5BtMWBJm823/rNWZcryNdXsONBUy/K/gOGSzJbTmw09Nh2XiV1yZWmeIbc15JxTdVmZ6Si5 LlAkA X-Developer-Key: i=cyphar@cyphar.com; a=openpgp; fpr=C9C370B246B09F6DBCFC744C34401015D1D2D386 X-Rspamd-Queue-Id: 4WYst83HGXz9sbh While the old code did support FSCONFIG_SET_FD, there's no need to re-get the file the fs_context infrastructure already grabbed for us. Signed-off-by: Aleksa Sarai --- fs/coda/inode.c | 43 ++++++++++++++++++++++++++++++------------- 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/fs/coda/inode.c b/fs/coda/inode.c index 6898dc621011..6896fce122e1 100644 --- a/fs/coda/inode.c +++ b/fs/coda/inode.c @@ -119,31 +119,43 @@ static const struct fs_parameter_spec coda_param_spec= s[] =3D { {} }; =20 -static int coda_parse_fd(struct fs_context *fc, int fd) +static int coda_set_idx(struct fs_context *fc, struct file *file) { struct coda_fs_context *ctx =3D fc->fs_private; - struct fd f; struct inode *inode; int idx; =20 - f =3D fdget(fd); - if (!f.file) - return -EBADF; - inode =3D file_inode(f.file); + inode =3D file_inode(file); if (!S_ISCHR(inode->i_mode) || imajor(inode) !=3D CODA_PSDEV_MAJOR) { - fdput(f); - return invalf(fc, "code: Not coda psdev"); + return invalf(fc, "coda: Not coda psdev"); } - idx =3D iminor(inode); - fdput(f); - if (idx < 0 || idx >=3D MAX_CODADEVS) return invalf(fc, "coda: Bad minor number"); ctx->idx =3D idx; return 0; } =20 +static int coda_parse_fd(struct fs_context *fc, struct fs_parameter *param, + struct fs_parse_result *result) +{ + struct file *file; + int err; + + if (param->type =3D=3D fs_value_is_file) { + file =3D param->file; + param->file =3D NULL; + } else { + file =3D fget(result->uint_32); + } + if (!file) + return -EBADF; + + err =3D coda_set_idx(fc, file); + fput(file); + return err; +} + static int coda_parse_param(struct fs_context *fc, struct fs_parameter *pa= ram) { struct fs_parse_result result; @@ -155,7 +167,7 @@ static int coda_parse_param(struct fs_context *fc, stru= ct fs_parameter *param) =20 switch (opt) { case Opt_fd: - return coda_parse_fd(fc, result.uint_32); + return coda_parse_fd(fc, param, &result); } =20 return 0; @@ -167,6 +179,7 @@ static int coda_parse_param(struct fs_context *fc, stru= ct fs_parameter *param) */ static int coda_parse_monolithic(struct fs_context *fc, void *_data) { + struct file *file; struct coda_mount_data *data =3D _data; =20 if (!data) @@ -175,7 +188,11 @@ static int coda_parse_monolithic(struct fs_context *fc= , void *_data) if (data->version !=3D CODA_MOUNT_VERSION) return invalf(fc, "coda: Bad mount version"); =20 - coda_parse_fd(fc, data->fd); + file =3D fget(data->fd); + if (file) { + coda_set_idx(fc, file); + fput(file); + } return 0; } =20 --=20 2.45.2