From: Jerry Zhang <jerry@skydio.com>
To: unlisted-recipients:; (no To-header on input)
Cc: embedded@skydio.com, Jerry Zhang <Jerry@skydio.com>,
Chuck Lever <chuck.lever@oracle.com>,
Jeff Layton <jlayton@kernel.org>,
Trond Myklebust <trond.myklebust@hammerspace.com>,
Anna Schumaker <anna@kernel.org>, NeilBrown <neilb@suse.de>,
"J. Bruce Fields" <bfields@redhat.com>,
linux-nfs@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] sunrpc: Fix incorrect parsing of expiry time
Date: Tue, 7 Mar 2023 14:05:25 -0800 [thread overview]
Message-ID: <20230307220525.54895-1-Jerry@skydio.com> (raw)
The expiry time field is mean to be expressed in seconds since boot.
The get_expiry() function parses a relative time value in seconds.
In order to get the absolute time of seconds since boot that the given
message will expire, the right thing is to add seconds_since_boot()
to the given relative value.
Previously this logic was subtracting boot.tv_sec from the relative
value, which was causing some confusing behavior. The return type of
time64_t could possibly underflow if time since boot is greater than
the passed in relative argument. Also several checks in nfs code compare
the return value to 0 to indicate failure, and this could spuriously
be tripped if seconds since boot happened to match the argument.
Fixes: c5b29f885afe ("sunrpc: use seconds since boot in expiry cache")
Signed-off-by: Jerry Zhang <Jerry@skydio.com>
---
include/linux/sunrpc/cache.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/include/linux/sunrpc/cache.h b/include/linux/sunrpc/cache.h
index ec5a555df96f..b96b1319c93d 100644
--- a/include/linux/sunrpc/cache.h
+++ b/include/linux/sunrpc/cache.h
@@ -301,16 +301,14 @@ static inline int get_time(char **bpp, time64_t *time)
}
static inline time64_t get_expiry(char **bpp)
{
time64_t rv;
- struct timespec64 boot;
if (get_time(bpp, &rv))
return 0;
if (rv < 0)
return 0;
- getboottime64(&boot);
- return rv - boot.tv_sec;
+ return rv + seconds_since_boot();
}
#endif /* _LINUX_SUNRPC_CACHE_H_ */
--
2.37.3
next reply other threads:[~2023-03-07 22:05 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-07 22:05 Jerry Zhang [this message]
2023-03-07 22:30 ` NeilBrown
2023-03-07 22:52 ` Jerry Zhang
2023-03-07 23:20 ` NeilBrown
2023-03-07 23:56 ` Jerry Zhang
2023-03-08 0:27 ` NeilBrown
2023-03-08 1:53 ` Jerry Zhang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230307220525.54895-1-Jerry@skydio.com \
--to=jerry@skydio.com \
--cc=anna@kernel.org \
--cc=bfields@redhat.com \
--cc=chuck.lever@oracle.com \
--cc=embedded@skydio.com \
--cc=jlayton@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neilb@suse.de \
--cc=trond.myklebust@hammerspace.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®