Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSS_CLIENT: MC: in case mem-cache file validation fails, #7085

Closed
wants to merge 3 commits into from

Conversation

alexey-tikhonov
Copy link
Member

don't return anything but EINVAL, because _nss_sss_*() functions can have a special handling for other error codes (for ERANGE in particular).

Copy link
Contributor

@thalman thalman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense to me. ACK

@alexey-tikhonov
Copy link
Member Author

I added one more patch.
Practically, it seems I'm force to change my stance wrt #6987 because of
https://github.com/TigerVNC/tigervnc/blob/effd854bfd19654fa67ff3d39514a91a246b8ae6/unix/xserver/hw/vnc/xvnc.c#L369

@alexey-tikhonov
Copy link
Member Author

alexey-tikhonov commented Dec 15, 2023

We probably should also:

  • use something like
    static int make_nonstd_fd_internals(int fd, int limit)
    for mem-cache fd
  • improve make_nonstd_fd_internals() to dup to a fd close to RLIMIT_NOFILE (instead of close to 3)

don't return anything but EINVAL, because `_nss_sss_*()` functions
can have a special handling for other error codes (for ERANGE in
particular).
Copy link
Contributor

@aplopez aplopez left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -767,6 +767,15 @@ static enum sss_status sss_cli_check_socket(int *errnop,
myself_ino = myself_sb.st_ino;
}

/* check if the socket has beed was hijacked */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... has been was ...

No need to fix this if this is the only change you have to do.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

if (sss_cli_sd_get() != -1) {
ret = fstat(sss_cli_sd_get(), &mypid_sb);
if ((ret != 0) || (!S_ISSOCK(mypid_sb.st_mode))
|| (mypid_sb.st_ino != sss_cli_sb->st_ino)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since inodes are local to a given device, when comparing inodes between two files its usually a good idea to compare st_dev too

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed here and in sss_nss_mc_validate()

Copy link
Contributor

@thalman thalman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK for the update

Copy link
Contributor

@sumit-bose sumit-bose left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

thanks for adding the device check as well, ACK.

About using high fd numbers, maybe this can be used if a changes was detected and we have to re-open the file or socket again. This way we can avoid the related overhead for the well-behaving cases.

While speaking about overheads, maybe we should think about really starting to do some measurements if closing the socket/file at the end of a requeist is more expensive than all those checks.

bye,
Sumit

@alexey-tikhonov
Copy link
Member Author

alexey-tikhonov commented Dec 21, 2023

While speaking about overheads, maybe we should think about really starting to do some measurements if closing the socket/file at the end of a requeist is more expensive than all those checks.

I tired this in #6746

It doesn't work for enumeration requests.

@alexey-tikhonov
Copy link
Member Author

Pushed PR: #7085

  • master
    • 2bcfb7f - SSS_CLIENT: check if reponder socket was hijacked
    • 0344c41 - SSS_CLIENT: check if mem-cache fd was hijacked
    • 958a5e2 - SSS_CLIENT: MC: in case mem-cache file validation fails,
  • sssd-2-9
    • abb146e - SSS_CLIENT: check if reponder socket was hijacked
    • a186224 - SSS_CLIENT: check if mem-cache fd was hijacked
    • 160738e - SSS_CLIENT: MC: in case mem-cache file validation fails,

@sumit-bose
Copy link
Contributor

While speaking about overheads, maybe we should think about really starting to do some measurements if closing the socket/file at the end of a requeist is more expensive than all those checks.

I tired this in #6746

It doesn't work for enumeration requests.

Hi,

yes, for enumaration requests we have to find a different way of keeping the state, which is currently tight to the client connection.

bye,
Sumit

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants