Patch Detail
get:
Show a patch.
patch:
Update a patch.
put:
Update a patch.
GET /api/patches/806547/?format=api
{ "id": 806547, "url": "http://patchwork.ozlabs.org/api/patches/806547/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/patch/20170828121106.2629-1-christian.brauner@ubuntu.com/", "project": { "id": 41, "url": "http://patchwork.ozlabs.org/api/projects/41/?format=api", "name": "GNU C Library", "link_name": "glibc", "list_id": "libc-alpha.sourceware.org", "list_email": "libc-alpha@sourceware.org", "web_url": "", "scm_url": "", "webscm_url": "", "list_archive_url": "", "list_archive_url_format": "", "commit_url_format": "" }, "msgid": "<20170828121106.2629-1-christian.brauner@ubuntu.com>", "list_archive_url": null, "date": "2017-08-28T12:11:06", "name": "[2/2,v2] openpty: use TIOCGPTPEER to open slave side fd", "commit_ref": null, "pull_url": null, "state": "new", "archived": false, "hash": "206489449a6528571f4ca5bd53fd64763ee64e55", "submitter": { "id": 72235, "url": "http://patchwork.ozlabs.org/api/people/72235/?format=api", "name": "Christian Brauner", "email": "christian.brauner@ubuntu.com" }, "delegate": null, "mbox": "http://patchwork.ozlabs.org/project/glibc/patch/20170828121106.2629-1-christian.brauner@ubuntu.com/mbox/", "series": [ { "id": 148, "url": "http://patchwork.ozlabs.org/api/series/148/?format=api", "web_url": "http://patchwork.ozlabs.org/project/glibc/list/?series=148", "date": "2017-08-28T12:11:06", "name": null, "version": 2, "mbox": "http://patchwork.ozlabs.org/series/148/mbox/" } ], "comments": "http://patchwork.ozlabs.org/api/patches/806547/comments/", "check": "pending", "checks": "http://patchwork.ozlabs.org/api/patches/806547/checks/", "tags": {}, "related": [], "headers": { "Return-Path": "<libc-alpha-return-83773-incoming=patchwork.ozlabs.org@sourceware.org>", "X-Original-To": "incoming@patchwork.ozlabs.org", "Delivered-To": [ "patchwork-incoming@bilbo.ozlabs.org", "mailing list libc-alpha@sourceware.org" ], "Authentication-Results": [ "ozlabs.org;\n\tspf=pass (mailfrom) smtp.mailfrom=sourceware.org\n\t(client-ip=209.132.180.131; helo=sourceware.org;\n\tenvelope-from=libc-alpha-return-83773-incoming=patchwork.ozlabs.org@sourceware.org;\n\treceiver=<UNKNOWN>)", "ozlabs.org; dkim=pass (1024-bit key;\n\tsecure) header.d=sourceware.org header.i=@sourceware.org\n\theader.b=\"wxJRvuGr\"; dkim-atps=neutral", "sourceware.org; auth=none" ], "Received": [ "from sourceware.org (server1.sourceware.org [209.132.180.131])\n\t(using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256\n\tbits)) (No client certificate requested)\n\tby ozlabs.org (Postfix) with ESMTPS id 3xgrGf12Brz9s8w\n\tfor <incoming@patchwork.ozlabs.org>;\n\tMon, 28 Aug 2017 22:11:37 +1000 (AEST)", "(qmail 121215 invoked by alias); 28 Aug 2017 12:11:21 -0000", "(qmail 120951 invoked by uid 89); 28 Aug 2017 12:11:19 -0000" ], "DomainKey-Signature": "a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; q=dns; s=default; b=Q+vyLn2wywm4ePoQm5v48fWWMfVe3z6\n\t1SJFa9CDhHB6rE/HdKhX4ODcPXFKbyDhH811iRM2oWc8hqw+MFyb9MFO7CdRtlUc\n\tlVOO8omnNvs72CDpuk1gryDWT4n0nLndW1otE+tc3bAofYwNIz+hVkWT2LaJqmee\n\taRt4lnmuqeYk=", "DKIM-Signature": "v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id\n\t:list-unsubscribe:list-subscribe:list-archive:list-post\n\t:list-help:sender:from:to:cc:subject:date:message-id:in-reply-to\n\t:references; s=default; bh=eeoDBHdK9izUhkwwEy7Xjjm1nEQ=; b=wxJRv\n\tuGrV3bSUeQOUxHdYR4aUQB+O2XxvCQjt5rptXjmRBYS4U5a8aBRkLfyZx/Qz8Sut\n\tpXHsOOq21CVJzPHhb20qOf0dJATTfMCMyNB0BASIlTwHaoXGJRtc3H840KuUgPNS\n\tHwxQj21hIcyacBLWum7tjQv6fmncONs6fu7VJI=", "Mailing-List": "contact libc-alpha-help@sourceware.org; run by ezmlm", "Precedence": "bulk", "List-Id": "<libc-alpha.sourceware.org>", "List-Unsubscribe": "<mailto:libc-alpha-unsubscribe-incoming=patchwork.ozlabs.org@sourceware.org>", "List-Subscribe": "<mailto:libc-alpha-subscribe@sourceware.org>", "List-Archive": "<http://sourceware.org/ml/libc-alpha/>", "List-Post": "<mailto:libc-alpha@sourceware.org>", "List-Help": "<mailto:libc-alpha-help@sourceware.org>,\n\t<http://sourceware.org/ml/#faqs>", "Sender": "libc-alpha-owner@sourceware.org", "X-Virus-Found": "No", "X-Spam-SWARE-Status": "No, score=-26.6 required=5.0 tests=BAYES_00, GIT_PATCH_0,\n\tGIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3,\n\tKAM_LAZY_DOMAIN_SECURITY,\n\tRCVD_IN_DNSWL_LOW autolearn=ham version=3.3.2 spammy=10416,\n\tHx-languages-length:3219, handed", "X-HELO": "mx2.mailbox.org", "From": "Christian Brauner <christian.brauner@ubuntu.com>", "To": "libc-alpha@sourceware.org, stgraber@stgraber.org, serge@hallyn.com,\n\tfweimer@redhat.com, joseph@codesourcery.com", "Cc": "Christian Brauner <christian.brauner@ubuntu.com>", "Subject": "[PATCH 2/2 v2] openpty: use TIOCGPTPEER to open slave side fd", "Date": "Mon, 28 Aug 2017 14:11:06 +0200", "Message-Id": "<20170828121106.2629-1-christian.brauner@ubuntu.com>", "In-Reply-To": "<3496d984-a55e-d56b-2c25-a23200327dca@redhat.com>", "References": "<3496d984-a55e-d56b-2c25-a23200327dca@redhat.com>" }, "content": "Newer kernels expose the ioctl TIOCGPTPEER [1] call to userspace which allows to\nsafely allocate a file descriptor for a pty slave based solely on the master\nfile descriptor. This allows us to avoid path-based operations and makes this\nfunction a lot safer in the face of devpts mounts in different mount namespaces.\n\n[1]: https://patchwork.kernel.org/patch/9760743/\n\nSigned-off-by: Christian Brauner <christian.brauner@ubuntu.com>\n---\nChangelog 2017-08-28:\n* Instead of #ifdefing the TIOCGPTPEER ioctl flag we now try the ioctl() first\n and if it fails we fallback to path-based allocation of the slave fd. This\n allows us retain backward compatibility with kernels that do not support this\n ioctl call.\n* A note on the following codepath\n\n if (name != NULL)\n {\n if (*buf == '\\0')\n if (pts_name (master, &buf, sizeof (_buf)))\n goto fail;\n\n strcpy (name, buf);\n }\n\n \"buf\" is guaranteed to be allocated in this case. If the pts_name() call above\n failed we would have never reached this code path. If it has been called\n succesfully it will either have handed us a valid buffer or \"buf\" will still\n point to the static char array \"_buf\" which is initialized to 0.\n---\n ChangeLog | 5 +++++\n login/openpty.c | 36 +++++++++++++++++++++++++-----------\n 2 files changed, 30 insertions(+), 11 deletions(-)", "diff": "diff --git a/ChangeLog b/ChangeLog\nindex bc5fb8e27f..30829e4c16 100644\n--- a/ChangeLog\n+++ b/ChangeLog\n@@ -1,3 +1,8 @@\n+2017-08-26 Christian Brauner <christian.brauner@ubuntu.com>\n+\n+\t* login/openpty.c (openpty): If defined, use the TIOCGPTPEER ioctl call\n+\tto allocate the slave pty file descriptor.\n+\n 2017-08-26 Christian Brauner <christian.brauner@ubuntu.com>\n \n \t* login/openpty.c (openpty): Close slave pty file descriptor on error.\ndiff --git a/login/openpty.c b/login/openpty.c\nindex 8fbc66a3ef..43b34d7a9c 100644\n--- a/login/openpty.c\n+++ b/login/openpty.c\n@@ -87,9 +87,9 @@ openpty (int *amaster, int *aslave, char *name,\n \t const struct termios *termp, const struct winsize *winp)\n {\n #ifdef PATH_MAX\n- char _buf[PATH_MAX];\n+ char _buf[PATH_MAX] = {0};\n #else\n- char _buf[512];\n+ char _buf[512] = {0};\n #endif\n char *buf = _buf;\n int master, slave = -1;\n@@ -104,16 +104,24 @@ openpty (int *amaster, int *aslave, char *name,\n if (unlockpt (master))\n goto fail;\n \n- if (pts_name (master, &buf, sizeof (_buf)))\n- goto fail;\n-\n- slave = open (buf, O_RDWR | O_NOCTTY);\n+ /* Try to allocate slave fd solely based on master fd first. */\n+ slave = ioctl (master, TIOCGPTPEER, O_RDWR | O_NOCTTY);\n if (slave == -1)\n {\n- if (buf != _buf)\n-\tfree (buf);\n-\n- goto fail;\n+ /* Fallback to path-based slave fd allocation in case kernel doesn't\n+ * support TIOCGPTPEER.\n+ */\n+ if (pts_name (master, &buf, sizeof (_buf)))\n+ goto fail;\n+\n+ slave = open (buf, O_RDWR | O_NOCTTY);\n+ if (slave == -1)\n+ {\n+ if (buf != _buf)\n+\t free (buf);\n+\n+ goto fail;\n+ }\n }\n \n /* XXX Should we ignore errors here? */\n@@ -127,7 +135,13 @@ openpty (int *amaster, int *aslave, char *name,\n *amaster = master;\n *aslave = slave;\n if (name != NULL)\n- strcpy (name, buf);\n+ {\n+ if (*buf == '\\0')\n+ if (pts_name (master, &buf, sizeof (_buf)))\n+ goto fail;\n+\n+ strcpy (name, buf);\n+ }\n \n if (buf != _buf)\n free (buf);\n", "prefixes": [ "2/2", "v2" ] }