summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/net/scm.h1
-rw-r--r--net/compat.c56
-rw-r--r--net/core/scm.c27
3 files changed, 37 insertions, 47 deletions
diff --git a/include/net/scm.h b/include/net/scm.h
index 1ce365f4c256..581a94d6c613 100644
--- a/include/net/scm.h
+++ b/include/net/scm.h
@@ -37,6 +37,7 @@ struct scm_cookie {
#endif
};
+int __scm_install_fd(struct file *file, int __user *ufd, unsigned int o_flags);
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm);
void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm);
int __scm_send(struct socket *sock, struct msghdr *msg, struct scm_cookie *scm);
diff --git a/net/compat.c b/net/compat.c
index 2937b816107d..27d477fdcaa0 100644
--- a/net/compat.c
+++ b/net/compat.c
@@ -281,40 +281,31 @@ int put_cmsg_compat(struct msghdr *kmsg, int level, int type, int len, void *dat
return 0;
}
-void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
+static int scm_max_fds_compat(struct msghdr *msg)
{
- struct compat_cmsghdr __user *cm = (struct compat_cmsghdr __user *) kmsg->msg_control;
- int fdmax = (kmsg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
- int fdnum = scm->fp->count;
- struct file **fp = scm->fp->fp;
- int __user *cmfptr;
- int err = 0, i;
+ if (msg->msg_controllen <= sizeof(struct compat_cmsghdr))
+ return 0;
+ return (msg->msg_controllen - sizeof(struct compat_cmsghdr)) / sizeof(int);
+}
- if (fdnum < fdmax)
- fdmax = fdnum;
+void scm_detach_fds_compat(struct msghdr *msg, struct scm_cookie *scm)
+{
+ struct compat_cmsghdr __user *cm =
+ (struct compat_cmsghdr __user *)msg->msg_control;
+ unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
+ int fdmax = min_t(int, scm_max_fds_compat(msg), scm->fp->count);
+ int __user *cmsg_data = CMSG_USER_DATA(cm);
+ int err = 0, i;
- for (i = 0, cmfptr = (int __user *) CMSG_COMPAT_DATA(cm); i < fdmax; i++, cmfptr++) {
- int new_fd;
- err = security_file_receive(fp[i]);
+ for (i = 0; i < fdmax; i++) {
+ err = __scm_install_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
if (err)
break;
- err = get_unused_fd_flags(MSG_CMSG_CLOEXEC & kmsg->msg_flags
- ? O_CLOEXEC : 0);
- if (err < 0)
- break;
- new_fd = err;
- err = put_user(new_fd, cmfptr);
- if (err) {
- put_unused_fd(new_fd);
- break;
- }
- /* Bump the usage count and install the file. */
- __receive_sock(fp[i]);
- fd_install(new_fd, get_file(fp[i]));
}
if (i > 0) {
int cmlen = CMSG_COMPAT_LEN(i * sizeof(int));
+
err = put_user(SOL_SOCKET, &cm->cmsg_level);
if (!err)
err = put_user(SCM_RIGHTS, &cm->cmsg_type);
@@ -322,16 +313,19 @@ void scm_detach_fds_compat(struct msghdr *kmsg, struct scm_cookie *scm)
err = put_user(cmlen, &cm->cmsg_len);
if (!err) {
cmlen = CMSG_COMPAT_SPACE(i * sizeof(int));
- kmsg->msg_control += cmlen;
- kmsg->msg_controllen -= cmlen;
+ if (msg->msg_controllen < cmlen)
+ cmlen = msg->msg_controllen;
+ msg->msg_control += cmlen;
+ msg->msg_controllen -= cmlen;
}
}
- if (i < fdnum)
- kmsg->msg_flags |= MSG_CTRUNC;
+
+ if (i < scm->fp->count || (scm->fp->count && fdmax <= 0))
+ msg->msg_flags |= MSG_CTRUNC;
/*
- * All of the files that fit in the message have had their
- * usage counts incremented, so we just free the list.
+ * All of the files that fit in the message have had their usage counts
+ * incremented, so we just free the list.
*/
__scm_destroy(scm);
}
diff --git a/net/core/scm.c b/net/core/scm.c
index 875df1c2989d..44f03213dcab 100644
--- a/net/core/scm.c
+++ b/net/core/scm.c
@@ -280,9 +280,8 @@ void put_cmsg_scm_timestamping(struct msghdr *msg, struct scm_timestamping_inter
}
EXPORT_SYMBOL(put_cmsg_scm_timestamping);
-static int __scm_install_fd(struct file *file, int __user *ufd, int o_flags)
+int __scm_install_fd(struct file *file, int __user *ufd, unsigned int o_flags)
{
- struct socket *sock;
int new_fd;
int error;
@@ -300,12 +299,8 @@ static int __scm_install_fd(struct file *file, int __user *ufd, int o_flags)
return error;
}
- /* Bump the usage count and install the file. */
- sock = sock_from_file(file, &error);
- if (sock) {
- sock_update_netprioidx(&sock->sk->sk_cgrp_data);
- sock_update_classid(&sock->sk->sk_cgrp_data);
- }
+ /* Bump the sock usage counts, if any. */
+ __receive_sock(file);
fd_install(new_fd, get_file(file));
return 0;
}
@@ -319,29 +314,29 @@ static int scm_max_fds(struct msghdr *msg)
void scm_detach_fds(struct msghdr *msg, struct scm_cookie *scm)
{
- struct cmsghdr __user *cm
- = (__force struct cmsghdr __user*)msg->msg_control;
- int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
+ struct cmsghdr __user *cm =
+ (__force struct cmsghdr __user *)msg->msg_control;
+ unsigned int o_flags = (msg->msg_flags & MSG_CMSG_CLOEXEC) ? O_CLOEXEC : 0;
int fdmax = min_t(int, scm_max_fds(msg), scm->fp->count);
int __user *cmsg_data = CMSG_USER_DATA(cm);
int err = 0, i;
+ /* no use for FD passing from kernel space callers */
+ if (WARN_ON_ONCE(!msg->msg_control_is_user))
+ return;
+
if (msg->msg_flags & MSG_CMSG_COMPAT) {
scm_detach_fds_compat(msg, scm);
return;
}
- /* no use for FD passing from kernel space callers */
- if (WARN_ON_ONCE(!msg->msg_control_is_user))
- return;
-
for (i = 0; i < fdmax; i++) {
err = __scm_install_fd(scm->fp->fp[i], cmsg_data + i, o_flags);
if (err)
break;
}
- if (i > 0) {
+ if (i > 0) {
int cmlen = CMSG_LEN(i * sizeof(int));
err = put_user(SOL_SOCKET, &cm->cmsg_level);
option> main, development code repositoryroot
summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2022-07-21 11:33:02 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-07-21 17:10:09 +0200
commit25da92004038c03c0feedf373e8038e7ee3e0c37 (patch)
tree654babe8087b83ca18bb8bd49f9fe821b3b23d45 /vcl
parent9dff8edf97f454f24a40acbed4a9297816f91da6 (diff)
Make JunitTest_toolkit_unoapi_1 succeed again on macOS
...after afc828b9833b7a612369e95606ba56d41ef2c369 "VCL expect correct frame size for native menubars" caused it to fail with [...] > checking: [toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent] is iface: [com.sun.star.accessibility.XAccessibleComponent] testcode: [ifc.accessibility._XAccessibleComponent] > LOG> Execute: containsPoint() > LOG> Upper bound of box containsPoint no component points - FAILED > LOG> Lower bound of box containsPoint no component points - FAILED > LOG> Left bound of box containsPoint no component points - FAILED > LOG> Right bound of box containsPoint no component points - FAILED > LOG> Outer upper and lower bounds contain no component points - OK > LOG> Outer left and right bounds contain no component points - OK > Method containsPoint() finished with state FAILED > LOG> containsPoint(): COMPLETED.FAILED [...] > LOG> Execute: getBounds() > LOG> Bounds = (0,0),(0,0) > Method getBounds() finished with state FAILED > LOG> getBounds(): COMPLETED.FAILED [...] > LOG> Execute: getSize() > LOG> starting required method: getBounds() > LOG> ! Required method getBounds() failed > LOG> getSize(): COMPLETED.FAILED [...] > ***** State for toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent ****** > [toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent::containsPoint()] is testcode: [containsPoint()] - COMPLETED.FAILED > [toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent::getBounds()] is testcode: [getBounds()] - COMPLETED.FAILED > [toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent::getSize()] is testcode: [getSize()] - COMPLETED.FAILED > Whole interface: COMPLETED.FAILED > ************************************************************************************************** [...] > ***** State for toolkit.AccessibleMenu ****** > [toolkit.AccessibleMenu::com::sun::star::accessibility::XAccessibleComponent] is testcode: [ifc.accessibility._XAccessibleComponent] - COMPLETED.FAILED > Whole component: COMPLETED.FAILED > ********************************************* [...] I have no idea whether that test legitimately started to fail, or is itself bogus, and (if the former) whether adding back the call to ImplCalcSize in MenuBar::ImplCreate is the best way to fix this. Change-Id: I8b575c66c57a698c59ccab01698df5355d4553bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136996 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/menu.cxx5
1 files changed, 5 insertions, 0 deletions
diff --git a/vcl/source/window/menu.cxx b/vcl/source/window/menu.cxx
index 811d4ea360fb..cb110281ee66 100644
--- a/vcl/source/window/menu.cxx
+++ b/vcl/source/window/menu.cxx
@@ -2453,6 +2453,11 @@ VclPtr<vcl::Window> MenuBar::ImplCreate(vcl::Window* pParent, vcl::Window* pWind
pMenu->pStartedFrom = nullptr;
pMenu->pWindow = pMenuBarWindow;
pMenuBarWindow->SetMenu(pMenu);
+ if (pMenuBarWindow) {
+ // This is needed at least on macOS to make the JunitTest_toolkit_unoapi_1
+ // toolkit.AccessibleMenu test pass:
+ pMenu->ImplCalcSize(pMenuBarWindow);
+ }
return pMenuBarWindow;
}