public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@redhat.com>
To: Siddhesh Poyarekar <siddhesh@gotplt.org>,
	Arjun Shankar <arjun@redhat.com>,
	libc-alpha@sourceware.org
Subject: Re: [PATCH v4] socket: Check lengths before advancing pointer in CMSG_NXTHDR
Date: Fri, 29 Jul 2022 12:43:01 -0400	[thread overview]
Message-ID: <4631785f-d873-bdf7-c315-b673f15c55ff@redhat.com> (raw)
In-Reply-To: <a2352da1-09ee-00f8-ac57-45c3a5a1f30f@gotplt.org>

On 7/29/22 12:40, Siddhesh Poyarekar wrote:
> On 2022-07-29 09:26, Arjun Shankar wrote:
>> The inline and library functions that the CMSG_NXTHDR macro may expand
>> to increment the pointer to the header before checking the stride of
>> the increment against available space.  Since C only allows incrementing
>> pointers to one past the end of an array, the increment must be done
>> after a length check.  This commit fixes that and includes a regression
>> test for CMSG_FIRSTHDR and CMSG_NXTHDR.
>>
>> The Linux, Hurd, and generic headers are all changed.
>>
>> Tested on Linux on armv7hl, i686, x86_64, aarch64, ppc64le, and s390x.
>>
>> [BZ #28846]
>> ---
>> v3: https://sourceware.org/pipermail/libc-alpha/2022-July/140854.html
>>
>> Notes on v4:
>>
>> * Addressed review comments from Siddhesh:
>>
>> 1. (sizeof (struct cmsghdr) + __CMSG_PADDING (cmsg_len)):
>>     defined as size_needed.
>>
>> 2.
>>> OK, but I wonder if there's utility in making the padding a generic
>>> macro, e.g.
>>
>>> #define ALIGN_PADDING(n, a) ((a - (n & (a - 1))) & (a - 1))
>>
>> This sounds useful, and actually it would be great to move *all* of the
>> duplicate code between these versions into a separate file and include it
>> in these variants.  I'll try to do a follow-up with this soon. I'm going to
>> note it down in my TODO.
>>
>> 3.
>>> __msg_control_ptr doesn't really need the __ since it's a local variable.
>>
>> I thought so too.  But Florian pointed out that it would interfere with
>> things like users #define'ing msg_control_ptr before including socket.h.
>> ---
>>   bits/socket.h                         | 40 ++++++++++--
>>   socket/Makefile                       |  1 +
>>   socket/tst-cmsghdr-skeleton.c         | 92 +++++++++++++++++++++++++++
>>   socket/tst-cmsghdr.c                  | 56 ++++++++++++++++
>>   sysdeps/mach/hurd/bits/socket.h       | 40 ++++++++++--
>>   sysdeps/unix/sysv/linux/bits/socket.h | 40 ++++++++++--
>>   sysdeps/unix/sysv/linux/cmsg_nxthdr.c | 36 ++++++++---
>>   7 files changed, 276 insertions(+), 29 deletions(-)
>>   create mode 100644 socket/tst-cmsghdr-skeleton.c
>>   create mode 100644 socket/tst-cmsghdr.c
> 
> LGTM.
> 
> Reviewed-by: Siddhesh Poyarekar <siddhesh@sourceware.org>

Just a reminder that the branch is frozen for glibc 2.36 release.

This is good for 2.37 when it opens.

-- 
Cheers,
Carlos.


      reply	other threads:[~2022-07-29 16:43 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-29 13:26 Arjun Shankar
2022-07-29 16:40 ` Siddhesh Poyarekar
2022-07-29 16:43   ` Carlos O'Donell [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4631785f-d873-bdf7-c315-b673f15c55ff@redhat.com \
    --to=carlos@redhat.com \
    --cc=arjun@redhat.com \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@gotplt.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).