mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-11 13:04:03 +08:00
b537a3c217
AFS-3 has two data fetch RPC variants, FS.FetchData and FS.FetchData64, and
Linux's afs client switches between them when talking to a non-YFS server
if the read size, the file position or the sum of the two have the upper 32
bits set of the 64-bit value.
This is a problem, however, since the file position and length fields of
FS.FetchData are *signed* 32-bit values.
Fix this by capturing the capability bits obtained from the fileserver when
it's sent an FS.GetCapabilities RPC, rather than just discarding them, and
then picking out the VICED_CAPABILITY_64BITFILES flag. This can then be
used to decide whether to use FS.FetchData or FS.FetchData64 - and also
FS.StoreData or FS.StoreData64 - rather than using upper_32_bits() to
switch on the parameter values.
This capabilities flag could also be used to limit the maximum size of the
file, but all servers must be checked for that.
Note that the issue does not exist with FS.StoreData - that uses *unsigned*
32-bit values. It's also not a problem with Auristor servers as its
YFS.FetchData64 op uses unsigned 64-bit values.
This can be tested by cloning a git repo through an OpenAFS client to an
OpenAFS server and then doing "git status" on it from a Linux afs
client[1]. Provided the clone has a pack file that's in the 2G-4G range,
the git status will show errors like:
error: packfile .git/objects/pack/pack-5e813c51d12b6847bbc0fcd97c2bca66da50079c.pack does not match index
error: packfile .git/objects/pack/pack-5e813c51d12b6847bbc0fcd97c2bca66da50079c.pack does not match index
This can be observed in the server's FileLog with something like the
following appearing:
Sun Aug 29 19:31:39 2021 SRXAFS_FetchData, Fid = 2303380852.491776.3263114, Host 192.168.11.201:7001, Id 1001
Sun Aug 29 19:31:39 2021 CheckRights: len=0, for host=192.168.11.201:7001
Sun Aug 29 19:31:39 2021 FetchData_RXStyle: Pos 18446744071815340032, Len 3154
Sun Aug 29 19:31:39 2021 FetchData_RXStyle: file size 2400758866
...
Sun Aug 29 19:31:40 2021 SRXAFS_FetchData returns 5
Note the file position of 18446744071815340032. This is the requested file
position sign-extended.
Fixes: b9b1f8d593
("AFS: write support fixes")
Reported-by: Markus Suvanto <markus.suvanto@gmail.com>
Signed-off-by: David Howells <dhowells@redhat.com>
Reviewed-by: Marc Dionne <marc.dionne@auristor.com>
Tested-by: Markus Suvanto <markus.suvanto@gmail.com>
cc: linux-afs@lists.infradead.org
cc: openafs-devel@openafs.org
Link: https://bugzilla.kernel.org/show_bug.cgi?id=214217#c9 [1]
Link: https://lore.kernel.org/r/951332.1631308745@warthog.procyon.org.uk/
177 lines
4.9 KiB
C
177 lines
4.9 KiB
C
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
|
/* YFS protocol bits
|
|
*
|
|
* Copyright (C) 2018 Red Hat, Inc. All Rights Reserved.
|
|
* Written by David Howells (dhowells@redhat.com)
|
|
*/
|
|
|
|
#define YFS_FS_SERVICE 2500
|
|
#define YFS_CM_SERVICE 2501
|
|
|
|
#define YFSCBMAX 1024
|
|
|
|
enum YFS_CM_Operations {
|
|
YFSCBProbe = 206, /* probe client */
|
|
YFSCBGetLock = 207, /* get contents of CM lock table */
|
|
YFSCBXStatsVersion = 209, /* get version of extended statistics */
|
|
YFSCBGetXStats = 210, /* get contents of extended statistics data */
|
|
YFSCBInitCallBackState3 = 213, /* initialise callback state, version 3 */
|
|
YFSCBProbeUuid = 214, /* check the client hasn't rebooted */
|
|
YFSCBGetServerPrefs = 215,
|
|
YFSCBGetCellServDV = 216,
|
|
YFSCBGetLocalCell = 217,
|
|
YFSCBGetCacheConfig = 218,
|
|
YFSCBGetCellByNum = 65537,
|
|
YFSCBTellMeAboutYourself = 65538, /* get client capabilities */
|
|
YFSCBCallBack = 64204,
|
|
};
|
|
|
|
enum YFS_FS_Operations {
|
|
YFSFETCHACL = 64131, /* YFS Fetch file AFS3 ACL */
|
|
YFSFETCHSTATUS = 64132, /* YFS Fetch file status */
|
|
YFSSTOREACL = 64134, /* YFS Store file AFS3 ACL */
|
|
YFSSTORESTATUS = 64135, /* YFS Store file status */
|
|
YFSREMOVEFILE = 64136, /* YFS Remove a file */
|
|
YFSCREATEFILE = 64137, /* YFS Create a file */
|
|
YFSRENAME = 64138, /* YFS Rename or move a file or directory */
|
|
YFSSYMLINK = 64139, /* YFS Create a symbolic link */
|
|
YFSLINK = 64140, /* YFS Create a hard link */
|
|
YFSMAKEDIR = 64141, /* YFS Create a directory */
|
|
YFSREMOVEDIR = 64142, /* YFS Remove a directory */
|
|
YFSGETVOLUMESTATUS = 64149, /* YFS Get volume status information */
|
|
YFSSETVOLUMESTATUS = 64150, /* YFS Set volume status information */
|
|
YFSSETLOCK = 64156, /* YFS Request a file lock */
|
|
YFSEXTENDLOCK = 64157, /* YFS Extend a file lock */
|
|
YFSRELEASELOCK = 64158, /* YFS Release a file lock */
|
|
YFSLOOKUP = 64161, /* YFS lookup file in directory */
|
|
YFSFLUSHCPS = 64165,
|
|
YFSFETCHOPAQUEACL = 64168, /* YFS Fetch file YFS ACL */
|
|
YFSWHOAMI = 64170,
|
|
YFSREMOVEACL = 64171,
|
|
YFSREMOVEFILE2 = 64173,
|
|
YFSSTOREOPAQUEACL2 = 64174,
|
|
YFSINLINEBULKSTATUS = 64536, /* YFS Fetch multiple file statuses with errors */
|
|
YFSFETCHDATA64 = 64537, /* YFS Fetch file data */
|
|
YFSSTOREDATA64 = 64538, /* YFS Store file data */
|
|
YFSUPDATESYMLINK = 64540,
|
|
};
|
|
|
|
struct yfs_xdr_u64 {
|
|
__be32 msw;
|
|
__be32 lsw;
|
|
} __packed;
|
|
|
|
static inline u64 xdr_to_u64(const struct yfs_xdr_u64 x)
|
|
{
|
|
return ((u64)ntohl(x.msw) << 32) | ntohl(x.lsw);
|
|
}
|
|
|
|
static inline struct yfs_xdr_u64 u64_to_xdr(const u64 x)
|
|
{
|
|
return (struct yfs_xdr_u64){ .msw = htonl(x >> 32), .lsw = htonl(x) };
|
|
}
|
|
|
|
struct yfs_xdr_vnode {
|
|
struct yfs_xdr_u64 lo;
|
|
__be32 hi;
|
|
__be32 unique;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_YFSFid {
|
|
struct yfs_xdr_u64 volume;
|
|
struct yfs_xdr_vnode vnode;
|
|
} __packed;
|
|
|
|
|
|
struct yfs_xdr_YFSFetchStatus {
|
|
__be32 type;
|
|
__be32 nlink;
|
|
struct yfs_xdr_u64 size;
|
|
struct yfs_xdr_u64 data_version;
|
|
struct yfs_xdr_u64 author;
|
|
struct yfs_xdr_u64 owner;
|
|
struct yfs_xdr_u64 group;
|
|
__be32 mode;
|
|
__be32 caller_access;
|
|
__be32 anon_access;
|
|
struct yfs_xdr_vnode parent;
|
|
__be32 data_access_protocol;
|
|
struct yfs_xdr_u64 mtime_client;
|
|
struct yfs_xdr_u64 mtime_server;
|
|
__be32 lock_count;
|
|
__be32 abort_code;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_YFSCallBack {
|
|
__be32 version;
|
|
struct yfs_xdr_u64 expiration_time;
|
|
__be32 type;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_YFSStoreStatus {
|
|
__be32 mask;
|
|
__be32 mode;
|
|
struct yfs_xdr_u64 mtime_client;
|
|
struct yfs_xdr_u64 owner;
|
|
struct yfs_xdr_u64 group;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_RPCFlags {
|
|
__be32 rpc_flags;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_YFSVolSync {
|
|
struct yfs_xdr_u64 vol_creation_date;
|
|
struct yfs_xdr_u64 vol_update_date;
|
|
struct yfs_xdr_u64 max_quota;
|
|
struct yfs_xdr_u64 blocks_in_use;
|
|
struct yfs_xdr_u64 blocks_avail;
|
|
} __packed;
|
|
|
|
enum yfs_volume_type {
|
|
yfs_volume_type_ro = 0,
|
|
yfs_volume_type_rw = 1,
|
|
};
|
|
|
|
#define yfs_FVSOnline 0x1
|
|
#define yfs_FVSInservice 0x2
|
|
#define yfs_FVSBlessed 0x4
|
|
#define yfs_FVSNeedsSalvage 0x8
|
|
|
|
struct yfs_xdr_YFSFetchVolumeStatus {
|
|
struct yfs_xdr_u64 vid;
|
|
struct yfs_xdr_u64 parent_id;
|
|
__be32 flags;
|
|
__be32 type;
|
|
struct yfs_xdr_u64 max_quota;
|
|
struct yfs_xdr_u64 blocks_in_use;
|
|
struct yfs_xdr_u64 part_blocks_avail;
|
|
struct yfs_xdr_u64 part_max_blocks;
|
|
struct yfs_xdr_u64 vol_copy_date;
|
|
struct yfs_xdr_u64 vol_backup_date;
|
|
} __packed;
|
|
|
|
struct yfs_xdr_YFSStoreVolumeStatus {
|
|
__be32 mask;
|
|
struct yfs_xdr_u64 min_quota;
|
|
struct yfs_xdr_u64 max_quota;
|
|
struct yfs_xdr_u64 file_quota;
|
|
} __packed;
|
|
|
|
enum yfs_lock_type {
|
|
yfs_LockNone = -1,
|
|
yfs_LockRead = 0,
|
|
yfs_LockWrite = 1,
|
|
yfs_LockExtend = 2,
|
|
yfs_LockRelease = 3,
|
|
yfs_LockMandatoryRead = 0x100,
|
|
yfs_LockMandatoryWrite = 0x101,
|
|
yfs_LockMandatoryExtend = 0x102,
|
|
};
|
|
|
|
/* RXYFS Viced Capability Flags */
|
|
#define YFS_VICED_CAPABILITY_ERRORTRANS 0x0001 /* Deprecated v0.195 */
|
|
#define YFS_VICED_CAPABILITY_64BITFILES 0x0002 /* Deprecated v0.195 */
|
|
#define YFS_VICED_CAPABILITY_WRITELOCKACL 0x0004 /* Can lock a file even without lock perm */
|
|
#define YFS_VICED_CAPABILITY_SANEACLS 0x0008 /* Deprecated v0.195 */
|