Skip to content

Commit 5d115fa

Browse files
charsyamsmfrench
authored andcommitted
ksmbd: fix CreateOptions sanitization clobbering the whole field
smb2_open() attempts to clear conflicting CreateOptions bits (FILE_SEQUENTIAL_ONLY_LE together with FILE_RANDOM_ACCESS_LE, and FILE_NO_COMPRESSION_LE on a directory open), but uses a plain assignment of the bitwise negation of the target flag: req->CreateOptions = ~(FILE_SEQUENTIAL_ONLY_LE); req->CreateOptions = ~(FILE_NO_COMPRESSION_LE); This replaces the entire field with 0xFFFFFFFB / 0xFFFFFFEF rather than clearing a single bit. With the SEQUENTIAL/RANDOM case, the next check for FILE_OPEN_BY_FILE_ID_LE | CREATE_TREE_CONNECTION | FILE_RESERVE_OPFILTER_LE then trivially matches and a legitimate request is rejected with -EOPNOTSUPP. With the NO_COMPRESSION case, every downstream test (FILE_DELETE_ON_CLOSE, etc.) operates on a corrupted CreateOptions value. Use &= ~FLAG to clear only the intended bit in both places. Signed-off-by: DaeMyung Kang <[email protected]> Acked-by: Namjae Jeon <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 804054d commit 5d115fa

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

fs/smb/server/smb2pdu.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,7 +3057,7 @@ int smb2_open(struct ksmbd_work *work)
30573057
} else {
30583058
if (req->CreateOptions & FILE_SEQUENTIAL_ONLY_LE &&
30593059
req->CreateOptions & FILE_RANDOM_ACCESS_LE)
3060-
req->CreateOptions = ~(FILE_SEQUENTIAL_ONLY_LE);
3060+
req->CreateOptions &= ~FILE_SEQUENTIAL_ONLY_LE;
30613061

30623062
if (req->CreateOptions &
30633063
(FILE_OPEN_BY_FILE_ID_LE | CREATE_TREE_CONNECTION |
@@ -3071,7 +3071,7 @@ int smb2_open(struct ksmbd_work *work)
30713071
rc = -EINVAL;
30723072
goto err_out2;
30733073
} else if (req->CreateOptions & FILE_NO_COMPRESSION_LE) {
3074-
req->CreateOptions = ~(FILE_NO_COMPRESSION_LE);
3074+
req->CreateOptions &= ~FILE_NO_COMPRESSION_LE;
30753075
}
30763076
}
30773077
}

0 commit comments

Comments
 (0)