From patchwork Thu Oct 17 15:03:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840183 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B3CF51DED65 for ; Thu, 17 Oct 2024 15:04:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177440; cv=none; b=qTawBfcBKb1F7Ela6LW6c52kRRe2QVc19H8jsrYOaddydc6bPC0PSIfD3eIStFSRvvAJENGi6ROAiusTpUx7QEzNPa9mHRhQfQdT/fSoMZybepbTBhzmVFIGgDR5RpHXoRajIMrRcLipLfPuOl33OHCF3SNGDckfqSm/3JSxKeI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177440; c=relaxed/simple; bh=GkvPIInt1TiBXv5GCp/6ODc696Yg0xkMCVC5oOpZx/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TQLhpv78YkwJ8tLGljVJ0aor/TtC5UivdonfJl8st6VSsa6YKcRpe+by6jcQJ0SFL+BvsvzCAEq3gMWtLj0Y/PAYKd86NGrHRTiWK5bp/WOB9QV8Mv1qo7b7jvb3wgPCnNhGF0/3NkKvby4MhkyRoMmzO6CvkqeWJG45qtg5q/Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fDbx38bU; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fDbx38bU" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91330C4CED1; Thu, 17 Oct 2024 15:03:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177440; bh=GkvPIInt1TiBXv5GCp/6ODc696Yg0xkMCVC5oOpZx/0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fDbx38bUHm8vbDJIG05lSF2jfrFe+H/8FN9QjEx7ftQ1dybNHf/Gf0mZzaF2aEp6h uvRJSyEfby2Oru+o/f0ZCSDEPafERShOLhpV1qh0YOEdeMsefg+kBU5cjzkNcelVM5 NMKfk+LzY3dVbUVd2w1Fq5YoKIZiF9KopdEHDgk/M8kornUkGvtcyuojlZujixkkRq g4DkZ9+tkgevM1ZMXPhVElMwEMCEJk22NsD4B0HKZsJFnoLugHcJg7wKMunRoui9nF cZbqVktLV7R+eyTwfYM2AOfcLejWoLqte26eNCUoyF6CpvfydReUTJtNHNKkJFmd9p 1Etv4Jiczmxlw== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 1/6] NFSD: Remove dead code in nfsd4_create_session() Date: Thu, 17 Oct 2024 11:03:51 -0400 Message-ID: <20241017150349.216096-9-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=964; i=chuck.lever@oracle.com; h=from:subject; bh=HiKnVMaySyz6rrdk3Q60xo/GI5a9WaZEM6Y6nxFB3Mo=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdbWG9pIF1HdzWaYvUvQzwzC3pxLRbypPOwe P276PCVkmOJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnWwAKCRAzarMzb2Z/ l9fTD/0aSAytd7kgiKB7ajgTCa718GmVEZGQ6xnozsWSFfrE5+7xbeFMFHx9tq04u+fy8H2anfN nWKz0B2YPGg+IFwgRtgklYpz7Ld07d+aUES6Bbb5IS6ove/+5tGouDpd7DXgqhFmuhWQlEywjGE o5jUTMKPi5QN2clL7XXKuPOxaRwVUCD1XT8CYsPUgkbPQ9iwdKKGFNdgMODrAHo8P2EAOwO4igf kEE4w3BDcNOHAy7iCSEm24P3VcbhMKsRabqOPIGZf5eY+1IV8IuixFaows6gQH3WokQjhdfo+qp n54XQbVoCQkAzqAXAi/a4/AsavLZLCf0NZtwTsIq3fK/3aDdsSW/PypbLRucvXS+rCV+pzP6PKH d7a1hpxTXm/zk3LXRed/5EABwhnyVOKFjNWAm3tmsn5HEw6Vy6JigPNjE/HsUHmy5CAp7CxLBCT qYJqNuUhh9xmNxdcimy18xfI4cg8M5zScELahuFaXfFF6CEXYKpmd9TXKuyBZsdgCJDz1+jmIxs HOQIk4hgSraYThJIIA+tjSfTT3mTSHCsZeiYRliRiH0C4jPzjL7N0+XI9zDsd4nJZTC5kNH3Q98 P8pzP8heae+L7GpkpvjWj3PDJ+KM6e/KTNxVBoRKW5GYnl+MZTSc99wFScWVzFzQyDDf2xa8Fdn sjrbrG3nLCP3T/g== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Clean up. AFAICT, there is no way to reach the out_free_conn label with @old set to a non-NULL value, so the expire_client(old) call is never reached and can be removed. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4state.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 2b21f2113c6e..3b16468ecbe7 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c @@ -3927,7 +3927,6 @@ nfsd4_create_session(struct svc_rqst *rqstp, return status; out_expired_error: - old = NULL; /* * Revert the slot seq_nr change so the server will process * the client's resend instead of returning a cached response. @@ -3942,8 +3941,6 @@ nfsd4_create_session(struct svc_rqst *rqstp, out_free_conn: spin_unlock(&nn->client_lock); free_conn(conn); - if (old) - expire_client(old); out_free_session: __free_session(new); out_release_drc_mem: From patchwork Thu Oct 17 15:03:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840184 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 866611DED6D for ; Thu, 17 Oct 2024 15:04:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177441; cv=none; b=MtMslAvYly0wmOXVx2DEffgNbtv4Wwoa77ROmEygKV7h7TlJq1WSAsU8PI48NnB9kx9LCEQo5XzyAkyaUy0A9Mw9683rIHRZDTUVMtger19S1CJ/P4xuw2eDB7CcLmBMtuWAS9AzOyOolACxx6h4ua1AYi7uvRDw4Z4sd1uZnPM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177441; c=relaxed/simple; bh=OYxx9BDWeo+jHQmDuw1sabm5pu8LTpLF+upjXunWnIA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SCOs3Ty+dFJ5a6YOrPM4bTuEfLTKz/kXzUPGSeqCQyOO+7hemY/gPIDsGlTBELYGhdKG2S4R0qZW/4e6baBc4daVTInp1CBOVXTZUDrMde99b///k4MfCNMWEvzaHOzkZv1K1IHSPNav5lCBRrxNfcRs9q8HrxKeZO105HqrJ7A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GEnJRzv5; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GEnJRzv5" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 79C22C4CEC3; Thu, 17 Oct 2024 15:04:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177441; bh=OYxx9BDWeo+jHQmDuw1sabm5pu8LTpLF+upjXunWnIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GEnJRzv5XRlkyG+j+yBr/rWEqMCwid8ksoMAt4ske0MWFgx3jN8DzOT0nhVZI9f4p 8bzt2A2uoVFYMNyFLqwUZv7qxOkDzwk55F1fhWr9c+JJvcMKMDjoLuK5EvK3KXGY0V rj/zEN9NBonO2DkIL6q5uTFjTEO6Edg32tLf0hwHq/gfyNQ5+8HtuCB2nAOnB1AlXW Xz8pIEaZ0/sjAzminseAKJ/4ClVfZxclPJ8UG3mfqc9gFR2UhMS0J8sVqEPylP9iem 2EK9s9ixNVGIxyQTp8lUWZQ1LNtCHLvE59TsX0vOFd/oBNIzbh6l71JfSC2FMwDkT+ yt9RLwqZAW/WA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 2/6] NFSD: Remove a never-true comparison Date: Thu, 17 Oct 2024 11:03:52 -0400 Message-ID: <20241017150349.216096-10-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=707; i=chuck.lever@oracle.com; h=from:subject; bh=FgFqs/GUCoBBeu6K4CNpdYJOHQzsoTY0ajJm02PuNwQ=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdbUs+qrDCnnv1ATy3Ljc1A+DUpHXk99Zj2t m6DpsynLT2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnWwAKCRAzarMzb2Z/ l83aD/kBcBTfdIPU/ZtyPjpCImyaHpHD58L5lPoKVkYdrL/WLYMdPuIEN9l1ma5DGMhJQDPQHtr TjmCeYg8xM49fDHHR4rDzh8lzMqA8JafMI5t47z2Nc8ncAxHJ1yKsgKeWodoeVhvWzX9v+tMGxd r5mh36rHghj3DGcvMKbM3r3ciM2c+XCpYRu67v0gPLqzd8Hx4ZcAF3KeSlYj/qAIiCgyyBUnS1C qs8gM0EEuJwIgyvzcMXa20VM+DmKGsJwEFk7tpH7LH5ezyoCzAwsf0nIgvjOXlNzZWvaQO1I+Av aIuTyk+L8woom6xQZxcsFeiXFVtpM81ZNBAIhYH8IQSEV6zoXKG02B9i7rtGQUCLx7gFnqPOn3+ US0tiaHQtGxtqDxRVCHKON7/iHcXcgMjUZqHiVg0sdvCDh3WVMFFH6NcIegiKLNkQ8S+FzO3UQ+ 0q8AhjzjbPK5H8yPxuYEGq/ZhGuInXYm6VYAHuLeSWSITff4/tqyCjKpySBLr8vXeUyMcdlkdbd 5cGNpXLQ/hTEO+8ptR/jFolvsYBPvOWc3eIWheXmcQei44X3KEWQAetWydBRxJaHX5eoCS8iymh IS0/ZDrogTWncEPbMfYvh1dKYWOgmHMLEr/Fedk3Gp5uzC5ELwz3FR9PSCDlqYE4zrKBTv9IxWW KspKJokkWyHnacA== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever fh_size is an unsigned int, thus it can never be less than 0. Fixes: d8b26071e65e ("NFSD: simplify struct nfsfh") Signed-off-by: Chuck Lever --- fs/nfsd/nfsfh.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/nfsd/nfsfh.c b/fs/nfsd/nfsfh.c index 4c5deea0e953..641dfe54fb59 100644 --- a/fs/nfsd/nfsfh.c +++ b/fs/nfsd/nfsfh.c @@ -773,7 +773,7 @@ char * SVCFH_fmt(struct svc_fh *fhp) struct knfsd_fh *fh = &fhp->fh_handle; static char buf[2+1+1+64*3+1]; - if (fh->fh_size < 0 || fh->fh_size> 64) + if (fh->fh_size > 64) return "bad-fh"; sprintf(buf, "%d: %*ph", fh->fh_size, fh->fh_size, fh->fh_raw); return buf; From patchwork Thu Oct 17 15:03:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840185 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 38DBE1DE8A4 for ; Thu, 17 Oct 2024 15:04:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177442; cv=none; b=hcbqKXyUzXDTdw/tsZ13Kwbic0spnwYBFuwEphAKe78tBfQzeWeoTJNvDZR7YJpYhYXXHZ4lRSEEmLox46Lr/C0uUBjOSTH8bpiDtBQj7NHxx5oUYHKPq/mhbn0yq33uKJK0F/MLTmTnxUeHHTX9DcbN7eHWYmkgeHvl5oZrjwg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177442; c=relaxed/simple; bh=U9UQzU41z5wHuKSoAlUXFfMTQ3XngxxUC7pDfgH0RCg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ll3hm7vL2Gx9Nsq8D690koITE4m9nZlkZvsJK36m7M7DRRtQ2ZPNXo2BOn17HM1pxPrhlYxPWEkFnY4+zY4iMJzY+tDn2/+M+1+YP9P30cYPjXslUhZDDKcGWQCYhCI9PjzHevLdWtweW93Ay4bd/7bmk67a2Nt/TC3L96il51c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=KqP4tcUw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="KqP4tcUw" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 608E5C4CED1; Thu, 17 Oct 2024 15:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177442; bh=U9UQzU41z5wHuKSoAlUXFfMTQ3XngxxUC7pDfgH0RCg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KqP4tcUwd8wvjcCCQevn8qP0W4Z+Iz2kuRpj1xF3En+ynEWfE5jLNDG9/qWW1XnL6 dvp0HHNJqFyhuLgMPpgq/sN7U25kYlv4haTqHyX/TMxAPiBxUCppo+tw8p05+bUvp0 Z2oOAnU5cciYasZyB5qgO93nRyo6pm3rwJtvV/ulKkt5oqbv0AqZ+b6dHLPOKL5mLG fT4yj1Jh9NUvecCuenpZjPeq0+FG0jhmnhzUWvJK9IQ81fL54opTXgjwXHPahiKlQc w3DOYdnOjcvmgzfvUHkwFbfgaj7M2ZCEqI9AW8OOBqrboBquceOyH/aVzHGXxCI1qO fWPDs7FmpEibg== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 3/6] NFSD: Prevent NULL dereference in nfsd4_process_cb_update() Date: Thu, 17 Oct 2024 11:03:53 -0400 Message-ID: <20241017150349.216096-11-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=768; i=chuck.lever@oracle.com; h=from:subject; bh=SNXmIoW4WxzSMhrWR5Xm4EitRtuKSsFWMVCZYMQJPJ8=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdbyyGZe4NI1jzLACe0lW86O/mfKL3O55I4E sEFHwnYgF+JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnWwAKCRAzarMzb2Z/ l+w1EACpbthCxK0ZuuZigu8WI3EfJ0S/3Gt2vGBvtB7gbck7/0DjNNTTZmzHPVi1ugq+Uk8VFi7 jsk6zOnDsNwGV7JuQQVD/9juNyoLtPlFRH7TlkIrK8XxUi9CA/sNscVJU8w51RIA7SfGzgwFhQC PnySLe3pgcjHJPalr1jS7junkG6PxU6JkZQ6c7V1UBOa2/JyGs4haaqQChDX7V013tziSR6M/o2 FdP8CGFb8oR4aKE6FM3bXhSM1ete9WOXZWa4nxYNhXHHg/26LTWLrVhPfX5axwIiYuSGX08XPf1 XQuj/C2yAXrVf+CLAwS0DgXd1NLT1/oetGKO0sCII3Xc0joTIwbjSovvHf5GSF4P1ZUCy91Tqkx PhtVWNh/W4Y5aNvNz5L6H2bGS0ogKSFHKi/AjzLmnSHk+Fvs1xaG9tGq/js37QZIkOuBDMx+8+T xGjErZCuefSljQ9bpOlagZogMBJxEpHCn8iCPNxaze9MM7/NnSqdO/h01fMYfOUFM+51ECN8tPX vIitoTnvOyTUXHtXlM37dwbVwuJOhyuAvGwm3rTFFtz82XvUTNmIjkCviCV3PufCLol16nzwIHo qLxt2B7lmL+uTEOIr4AlN48KaI95l2DMuXHuFedLaHVK1reoKAhruQXtgtsPgAqXM3stzG8qFKg T3xgx/DAY+T0qjQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever @ses is initialized to NULL. If __nfsd4_find_backchannel() finds no available backchannel session, setup_callback_client() will try to dereference @ses and segfault. Fixes: dcbeaa68dbbd ("nfsd4: allow backchannel recovery") Signed-off-by: Chuck Lever --- fs/nfsd/nfs4callback.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/nfsd/nfs4callback.c b/fs/nfsd/nfs4callback.c index d86a7b983785..2e18f635078f 100644 --- a/fs/nfsd/nfs4callback.c +++ b/fs/nfsd/nfs4callback.c @@ -1500,6 +1500,8 @@ static void nfsd4_process_cb_update(struct nfsd4_callback *cb) ses = c->cn_session; } spin_unlock(&clp->cl_lock); + if (!c) + return; err = setup_callback_client(clp, &conn, ses); if (err) { From patchwork Thu Oct 17 15:03:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840186 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 63BCB1BFE18 for ; Thu, 17 Oct 2024 15:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177443; cv=none; b=VtO53Vz1SD5gPBxzvVx2vOHX5foln8F+m8fnKXua4P5/bZMUTq8zxXUfrm8TlUd9Tdi3xK2mbsWmN7OZEUysUhTWzTTnIqW8m71x6KsRQbjMhU/u+sE0CNr2mCfQPxGZ9b+bp3COyoLBKoMmfMX8945oo5M5hyE4KomD2fHqYPw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177443; c=relaxed/simple; bh=vrhZHDQyud4VCBRJ5vZdNisTRlYabXhblzcG+/VoCOY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eoFwIemd5oVCjV8w7i8Cs0m6pGcPcnTpmHSgWUWPPUH4iIS98E49bSBGO48xP7orjJXu1zsLYec9seppMMV+Lvvp4slZ2YDe7XZdHHoBVSARmIhw8fLPvrnrbPkku9REPt1O2HV9LkJbd+KKOgxsXBr9W8gY08oZSLpTS7lTMm4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=uUoACcnL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="uUoACcnL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 49111C4CECD; Thu, 17 Oct 2024 15:04:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177442; bh=vrhZHDQyud4VCBRJ5vZdNisTRlYabXhblzcG+/VoCOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uUoACcnL1gtgODZ5Qvu5UkLV0U48TeW6UdONxcRzKuVKCd6UAgyWvtvngh5fGbQjU 1v1qlWeh6Uf2RyP05wGAKPNokgBfNCBloiWPP5kpEEijYvvZo4KD/JYA2RILsVPDC+ 7v/wPsX2Bk5rvaogcpEY6yJ2w4ifbsx1hixTZsKJEWo48T1oiEgb0mx/oD/WyGB4Yd 2op5CyOvKVHcmVR2XbcBaVok0Htx5vEfTeqOb+ggER4Z+3UkMuIVJ8alikIdvPY6KO bM9gJeSNvPdCFWnuR3XlhbpZ2ZmGEIBP8c+wu4T8PKUsMtRqssxwStFDUKV7XJnrCs PezESDLzvyXVA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 4/6] NFSD: Remove unused results in nfsd4_encode_pathname4() Date: Thu, 17 Oct 2024 11:03:54 -0400 Message-ID: <20241017150349.216096-12-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=1686; i=chuck.lever@oracle.com; h=from:subject; bh=CxtjWK1DblEC+SxiE8+kgNZWMWN3G7lFrYgWh8x1x3A=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdbCcjrjCeLzHnTya8+Tfm/mPVqrcKx8NRX2 g4XIBwvyGSJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnWwAKCRAzarMzb2Z/ lzP8EACMitgqwOrTnmGuKugfuN8KnV7lqNZHyp/fMPc6yV5KnNmo3RF0JHv0k0pbACO8306gxFj /G7ia7+gNb8eAy8i1DZkIvF2fN0pvdO/1mSApBnkyLT1FSC+dtIVpOQvRm5o2SH9dlvGp3YWqTs n7yOdOtx1Bn6Wmv80CC0cZBh6AxdEArORjns0oRbORV3jEvDJpC93pOhG94osGu1Gm5sUWbbTvv ZyC9krDQqlhekaOrAH1dsHTtMw3Bo6Ur+WRfxalf/+pd1ji34ir5jQjvxOpZie0B6ekvLoNQhg/ MZhJvZFmKJaLDf/FVl+8FVJ1dsB/n/DxWpi9gRQdWcLRkxeRYmIhpgfJ2eSk399zP5K+YqcVnQe 6rI2wHoAIkPYZuFFU2+4IjrAe09UbnNBxV5yl2QUvGsyuNZcXQAOyjl0LsvEQa/GUWLEESDrO73 as8gsntGmcR9wOnshh+RYZrehJuUMlis/QnPS3v2EzXCo2XXJXDrI6k4hcSp6hfwoKEiT7SV2/B i77ykkCAks0tDkNQ4RW2PiUdVmYQqlW/oc+0QFqlB6wkP3/LcJLMi/mYSH2nbMp5NE3VAva0uWe qp/jLbHbyPB0mBURcB27nWDvDwdD98TBkrXCh+tlHDglMeWHk+QCjYuri+CXTJaQLbo0/gjAtD0 KFwLUvUiq8eG1Wg== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Clean up. The result of "*p++" is saved, but is not used before it is overwritten. The result of xdr_encode_opaque() is saved each time through the loop but is never used. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index ff897a368c01..6633fa06bc91 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2720,7 +2720,6 @@ static __be32 nfsd4_encode_pathname4(struct xdr_stream *xdr, const struct path *path) { struct path cur = *path; - __be32 *p; struct dentry **components = NULL; unsigned int ncomponents = 0; __be32 err = nfserr_jukebox; @@ -2751,24 +2750,19 @@ static __be32 nfsd4_encode_pathname4(struct xdr_stream *xdr, components[ncomponents++] = cur.dentry; cur.dentry = dget_parent(cur.dentry); } - err = nfserr_resource; - p = xdr_reserve_space(xdr, 4); - if (!p) - goto out_free; - *p++ = cpu_to_be32(ncomponents); + err = nfserr_resource; + if (xdr_stream_encode_u32(xdr, ncomponents) != XDR_UNIT) + goto out_free; while (ncomponents) { struct dentry *dentry = components[ncomponents - 1]; - unsigned int len; spin_lock(&dentry->d_lock); - len = dentry->d_name.len; - p = xdr_reserve_space(xdr, len + 4); - if (!p) { + if (xdr_stream_encode_opaque(xdr, dentry->d_name.name, + dentry->d_name.len) < 0) { spin_unlock(&dentry->d_lock); goto out_free; } - p = xdr_encode_opaque(p, dentry->d_name.name, len); dprintk("/%pd", dentry); spin_unlock(&dentry->d_lock); dput(dentry); From patchwork Thu Oct 17 15:03:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840187 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 41DFC1BFE18 for ; Thu, 17 Oct 2024 15:04:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177444; cv=none; b=BwhsWA8wbzv59lADP79bj6GV0M7c7gRpXo0GlKOl3iug5NBKq+OLC1bkV8mJDSA38VB2rZVgALzdy5E/2sd6r01a+kLRRd3MaMAc57z1TEw5qMgMJP7rZGX0Rkds/zB6Bt9Jm81vCJQVk3HXT6EbW1Hr9LH7zs0RqgEPWAFu36k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177444; c=relaxed/simple; bh=INOvrRQ2nEStYrTRoT6EBZaxcYt3nHpVbCKTdPVgRoI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lQsNtvNIjfO1tEj2I1Bo35CxOTDxC2jyz1sMlGtKqTwl+OIN2pnQcU6vHn7oVGFr7vR8tdlcrCYeXUxgeZydyf4yxDtRe9S29DFUcNfmZkKBstSK9xITZaESCiwueKSJAwDSdgYl/t5FE4aNgqF2Yz0jP59QvOkPsY6i5F1ykb0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=lUJ1lv3T; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="lUJ1lv3T" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D784C4CEC7; Thu, 17 Oct 2024 15:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177443; bh=INOvrRQ2nEStYrTRoT6EBZaxcYt3nHpVbCKTdPVgRoI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lUJ1lv3TFqyO8AJqBwvVKBunoUMX2vB0RY73ieBHGsoPLv5iwehYuy+572TTaZ0mI C4zgRkcHg0nY0hp01I4E6Q5qPDgODYQRNf4g6EqVrIHcWmCeJFTzQehIcYvl+F5r2z ASFrjpOVissYreYrqChvMjzm0N9DYhcNu6LJk3nszQ5few63kpNJs/YVy+TNaM8/xo 1X9r96eI8AtslgEGtaL3IBhLDduw6YWvAldlmdUwqpr34QjvoXMBQEPaIVMd5JxNTz +8As53+OHgKf5A5sz4jq/SC0guTTodStzY8o4UcI7ZDaeqB5qEyLA0IzApGFo4YIlf zgDGlotFLL7xA== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 5/6] NFSD: Remove unused values from nfsd4_encode_components_esc() Date: Thu, 17 Oct 2024 11:03:55 -0400 Message-ID: <20241017150349.216096-13-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=815; i=chuck.lever@oracle.com; h=from:subject; bh=ZYXV9qGHPRX0N4UmLA6tqeoLkMAw7NxRZLBBKL0Ydy8=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdb84VD6Kf3TYPK/cs3clqYigagNbenx5dPc 74lGWfryr2JAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnWwAKCRAzarMzb2Z/ lwXWD/4t0MduoV0w6F586TVkEseoG+WInjxiJkkB1edwdU88lC9U6gz3ZMS7vO1dZPL1uVUze+z 5I6E1oZPHO9VsrNSaj33e+I2+x4tDgsudipvKkaYdaXegu+jyBaqI9Nw/fIWxRYbfSnTofTCEw/ gfzTL6z/n8N54yGAFdcPetpbSjeR1+olIsQWEnsnZUPuLUu9+of0R/qfGTsMVooJeKl1khW5Sdl Acd3iKSexUny+DXIwLw5pW42FBGfJR/yKH0aGO/BlA1EDKP3gylOGQmvbBi4BR2JKLVSuIVXXfJ GyGaRGo5KuqyMhI7HYXyG8AuHj+IhMrrRlhxGSOnkeSkWmTfudk2SrtovGvL4aR5AisVQ8ur/C+ fjjkGyK32lD9g8guN1DP/W5Vi+uGIoIe0epYNXpBQe5fKdRQAOf8Vw4QcZF/Ihx++VpuOODZDAG n498G3ylRaYel8JXz2lHzbSTVhD0OFwfChCHNC1wbWyTOqvKzg5FakmOh8CGcFw2S18IThZvob3 TdPzEsck2ERfYFyszCiwpKRbVEVxaZZM0J5yolJXbaBQzLnYStQ4ZXIOcWxQ40Jd/IVTB+9LqhZ MkYbJlMWndxE/4Emn2gCbSwauienzbKrZUr1ocwNs0H9w8rccZDEkJIYkGRePAy3SEC0QmT1IJS UIs33mlUz2U9eKQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever Clean up. The computed value of @p is saved each time through the loop but is never used. Signed-off-by: Chuck Lever --- fs/nfsd/nfs4xdr.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/fs/nfsd/nfs4xdr.c b/fs/nfsd/nfs4xdr.c index 6633fa06bc91..59de516edc2d 100644 --- a/fs/nfsd/nfs4xdr.c +++ b/fs/nfsd/nfs4xdr.c @@ -2673,13 +2673,10 @@ static __be32 nfsd4_encode_components_esc(struct xdr_stream *xdr, char sep, strlen = end - str; if (strlen) { - p = xdr_reserve_space(xdr, strlen + 4); - if (!p) + if (xdr_stream_encode_opaque(xdr, str, strlen) < 0) return nfserr_resource; - p = xdr_encode_opaque(p, str, strlen); count++; - } - else + } else end++; if (found_esc) end = next; From patchwork Thu Oct 17 15:03:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chuck Lever X-Patchwork-Id: 13840188 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 28A231BFE18 for ; Thu, 17 Oct 2024 15:04:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177445; cv=none; b=lCL6PZov+dEfqDX4Z+lYsuhXBjOk++50rqSVeKlpoBgpPvI1IvtjrcrLT6PNM3+GFcJ3ZcvXvzWNcOfnwIYmxl2FzpuGcvq3J6AGDeW11z7pMD9GDJUwsNZJzgG7Jd4LkGS2Eebk+BWsmpJ6aem6YEIDDhbrhkUcYO34OOYUA0o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729177445; c=relaxed/simple; bh=dS1Tu/sC6dRXFOkz4tYFtIN4FQBV3436rhwTvzdFNNk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jRenbsnyLy8bRVz48NG5zMvpgsftXuV8JY1CPY5gIfomHf4m4CMwvfN1iRTTmP4hny33Gql+/8UvVjNdiHGnTj46QG3inziFH8t5S0zem90ZlFq3Qpu/YLHAOmbFd3QjhS9ZN4K+lghg5prOcCp5DKDt9AmgxibGE4yXMoGJgHA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ePMTC+1B; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ePMTC+1B" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11128C4CEC3; Thu, 17 Oct 2024 15:04:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1729177444; bh=dS1Tu/sC6dRXFOkz4tYFtIN4FQBV3436rhwTvzdFNNk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ePMTC+1B6D1gXMvfAKJ5FNPz5qd7luDk9FvUZpFSjMD14wfhpzpKN71ZWXou2EGAX EvsZlTiZzIzZ2Y8VlwM7f+DVCTjjDLOgZaRErFQGJRBXWpiKK+fHZpiIT6PS2NgRJ+ 8o5TB4X4UexNY8S1XNMpOiSXHObh4U4MzeEKQ0VkqkdQccZfqHx9rpiypoBFhl+6tg NKUDu4Eb3A7dUU3eHq6Y/BoqstgKPFWEcInGDMMcRZSIOjTu0hX7o611KAf1FqhU/F eJyXHkgJhg+cb3iALAOH1Sv1Vx4PH/VhDUeqawXG/atPU+7QubuK17OptPG7tO597/ C8Q8VRooKmv+g== From: cel@kernel.org To: Neil Brown , Jeff Layton , Olga Kornievskaia , Dai Ngo , Tom Talpey Cc: , Chuck Lever Subject: [RFC PATCH 6/6] NFSD: Cap the number of bytes copied by nfs4_reset_recoverydir() Date: Thu, 17 Oct 2024 11:03:56 -0400 Message-ID: <20241017150349.216096-14-cel@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241017150349.216096-8-cel@kernel.org> References: <20241017150349.216096-8-cel@kernel.org> Precedence: bulk X-Mailing-List: linux-nfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=755; i=chuck.lever@oracle.com; h=from:subject; bh=rX5d4jWyedyE07RaWCkcii2QPArsQrZ8xrqRtPEaTlI=; b=owEBbQKS/ZANAwAIATNqszNvZn+XAcsmYgBnESdcTZhtogTD4MVBbuFY/42pvGBSEp4Pj59x7 WEM0bhu5wKJAjMEAAEIAB0WIQQosuWwEobfJDzyPv4zarMzb2Z/lwUCZxEnXAAKCRAzarMzb2Z/ l1qQD/44sQQG9QvFQ5n1c5rfE3Z7BsPpuaVXuWPQ49hI0lBRo79RvRHR5D/QT5oKoLE5Rn9FF0A 9hQXm1Fhp/EFGM5wyzQ5134y3OX+MWsV8FpeIX5rnibFyJUq9wOUO0yy97yS6o2tcnWSIaAWq14 6umMpqWadifTxMOblsaZcZXUrWdYU5AeVXmfs1svjYfIEFOWwH4tAGdMsSGvEkNd6mXDjhXC1kq rQPgnJ1uWvd+8aeM2vc/9q6twS5xjAGCPXcW6ICtMfRCmXm9wHCdArflpDovKCcK026nqEnjjAI pmlny2Pk/vQyjQlG3/gXy109odooRXL7tEd4bWDIC9PvG86TK0lxopDXYk56POc+RZwCkr1H/kI po/zFiKVVn/6pWnbafpEgK2p4MiwP+TWPbrzYWAjxtkvvs87piu9u3BUJ715Z1t5SAInxNZ/2v/ BlGMwzOVQ4rS6rwrrNL+DX5kYiALIh/KSTFzzDxa4n80selDNFJB1zfDwCs6OUG3yVimiOHopL1 tKDv6S0Mhihh1IdkUm2sUmDOoiC5Qy6vIQYgGr65fFiKCGuB3RdYfbUU0w7DSXoVgId8m9t7CIM MvkGzJjdCCHmmJMmNEeKQofyYy7rIjAWYbHnOY1rWu7whLP7pIV6HszFHgTt128u13SuEFNg42r YO5E0+yCWC0xJtQ== X-Developer-Key: i=chuck.lever@oracle.com; a=openpgp; fpr=28B2E5B01286DF243CF23EFE336AB3336F667F97 From: Chuck Lever It's only current caller already length-checks the string, but let's be safe. Fixes: 0964a3d3f1aa ("[PATCH] knfsd: nfsd4 reboot dirname fix") Signed-off-by: Chuck Lever --- fs/nfsd/nfs4recover.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index b7d61eb8afe9..4a765555bf84 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c @@ -659,7 +659,8 @@ nfs4_reset_recoverydir(char *recdir) return status; status = -ENOTDIR; if (d_is_dir(path.dentry)) { - strcpy(user_recovery_dirname, recdir); + strscpy(user_recovery_dirname, recdir, + sizeof(user_recovery_dirname)); status = 0; } path_put(&path);