From owner-freebsd-hackers@freebsd.org Mon Apr 29 13:59:19 2019 Return-Path: Delivered-To: freebsd-hackers@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 1DA3E158ECC9 for ; Mon, 29 Apr 2019 13:59:19 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 52EFE81F77 for ; Mon, 29 Apr 2019 13:59:18 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-qt1-x82a.google.com with SMTP id y49so6261181qta.7 for ; Mon, 29 Apr 2019 06:59:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cXwlTQN15puD2Pa0F3N7kQk9nJ67KWObCr8Tpp44eGA=; b=w24sxDd8y3u6ugLEPg2IC0xbLyOg2fZH7LsB9zrm7MRIB8MA1czoqSxhiY+E2vieit 81slAqtrKafxq0RzCBSKF/RZ7U+T7/tx/5wf26qhm/isRaoHMqAEKlE8T2H+swwGMwtF J3APbcWpHXrBH8R98KQE14fmjC5GkEliJGILX49k9oRgfBYg0Xqcmgj7b8smiE37jXDl 7qWH1p5VDeqqpt0ao4KI7GFjHxwi8kSi/f57my5YIxeWeok3fggn8Y1qPwx5CHA2lCTG 79iop9In1RN2IL39Ok8GP6Cc1LQ2h2pGHKF8Z9NmmBj5hvn9tLvXPnrsQT02cCMk86al jWRg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cXwlTQN15puD2Pa0F3N7kQk9nJ67KWObCr8Tpp44eGA=; b=i0C6WblDgvym+AdoIjEBPNSkcLt1qQU+2C489fqppt2kV7kbvgDISRPmh+xOdgEA26 pirZIxyDl6yL0DwJq329nqZGpl6DLJ0OTlmStgNK7BUlNqcASMQXU1fU0GExJCZc4dRP Q1786InSOOeu5TJdRYSBw/H9A3p+CRlBsCQzyqoUXyAxa9rflP/FZbf55vmGKlIpYKTY ry99gvqjqt3exssZ/L5kdMx5KqJBCv8Rzlry1JFC2UzSUDukVPNnnSOoV/0epu5L/6WF NoxJeQRPaznLxkDKlDCsvWd7bwGvRpXgK7M1jFrxYNO3Bi98Cw1qYX/wrv7lxumJgKYD eslA== X-Gm-Message-State: APjAAAXpsBJsZbrk/LrMOukrEovTq/T7Ft/Sd3k4DS85IjhsvOjjAy6N cqh1ZNtYttWLS7jvUwCaVC5Ef4No9t9a/Rk7Ro2L4w== X-Google-Smtp-Source: APXvYqzh9JsPNNdunEOPcEBLwu3d/BcnzbWLXlJi+1sw8wyqsg8Uzvv8X0HtEeQnZhdJ5AXmqH+DGO34C4xVi440THE= X-Received: by 2002:a0c:980b:: with SMTP id c11mr7533487qvd.115.1556546357808; Mon, 29 Apr 2019 06:59:17 -0700 (PDT) MIME-Version: 1.0 References: <23438.1556267575@critter.freebsd.dk> <6CF6472E-1100-475D-987C-071E916D64E8@yahoo.com> In-Reply-To: <6CF6472E-1100-475D-987C-071E916D64E8@yahoo.com> From: Warner Losh Date: Mon, 29 Apr 2019 07:59:06 -0600 Message-ID: Subject: Re: buf(9) woes: when does bcopy do nothing at all? To: Mark Millard Cc: Poul-Henning Kamp , FreeBSD Hackers , Alan Somers X-Rspamd-Queue-Id: 52EFE81F77 X-Spamd-Bar: ---- Authentication-Results: mx1.freebsd.org; dkim=pass header.d=bsdimp-com.20150623.gappssmtp.com header.s=20150623 header.b=w24sxDd8 X-Spamd-Result: default: False [-4.92 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; R_DKIM_ALLOW(-0.20)[bsdimp-com.20150623.gappssmtp.com:s=20150623]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; IP_SCORE(-2.95)[ip: (-9.26), ipnet: 2607:f8b0::/32(-3.17), asn: 15169(-2.24), country: US(-0.06)]; MIME_GOOD(-0.10)[multipart/alternative,text/plain]; PREVIOUSLY_DELIVERED(0.00)[freebsd-hackers@freebsd.org]; DMARC_NA(0.00)[bsdimp.com]; NEURAL_HAM_LONG(-1.00)[-1.000,0]; TO_MATCH_ENVRCPT_SOME(0.00)[]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[bsdimp-com.20150623.gappssmtp.com:+]; MX_GOOD(-0.01)[cached: ALT1.aspmx.l.google.com]; RCVD_IN_DNSWL_NONE(0.00)[a.2.8.0.0.0.0.0.0.0.0.0.0.0.0.0.0.2.0.0.4.6.8.4.0.b.8.f.7.0.6.2.list.dnswl.org : 127.0.5.0]; NEURAL_HAM_SHORT(-0.96)[-0.965,0]; R_SPF_NA(0.00)[]; FORGED_SENDER(0.30)[imp@bsdimp.com,wlosh@bsdimp.com]; FREEMAIL_TO(0.00)[yahoo.com]; SUBJECT_ENDS_QUESTION(1.00)[]; MIME_TRACE(0.00)[0:+,1:+]; ASN(0.00)[asn:15169, ipnet:2607:f8b0::/32, country:US]; FROM_NEQ_ENVFROM(0.00)[imp@bsdimp.com,wlosh@bsdimp.com]; RCVD_TLS_LAST(0.00)[]; RCVD_COUNT_TWO(0.00)[2] Content-Type: text/plain; charset="UTF-8" X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Apr 2019 13:59:19 -0000 On Fri, Apr 26, 2019 at 12:44 PM Mark Millard via freebsd-hackers < freebsd-hackers@freebsd.org> wrote: > On 2019-Apr-26, at 01:32, Poul-Henning Kamp wrote: > > > -------- > > In message < > CAOtMX2gdw+eQQU_-DC+EgimbCyw6ynbX1haGLUmn1dApk4rMZw@mail.gmail.com>, Alan > Somers writes: > > > >> How is it possible that bcopy() doesn't affect its output array at all? > > > > That conclusion does not follow from your example: > > > >> bcopy(cp, iov->iov_base, cnt); > >> r = memcmp(cp, iov->iov_base, cnt); > >> if (r) > >> printf("uiomove: miscompare\n"); > > > > If [cp:cp+cnt] and [iov_base:iov_base+cnt] overlap the bcopy result > > is undefined. > > > > Try memmove instead ? > > I only see a bcopy man page bcopy(3) but it says: > > DESCRIPTION > The bcopy() function copies len bytes from string src to string dst. > The > two strings may overlap. If len is zero, no bytes are copied. > > Is a kernel bcopy likely to be any different? > kernel bcopy works with overlapping strings. It's always done this on x86, and different archs behaved different, so we fixed that so the all handle it properly. memcpy is still an issue here, potentially, but memmove isn't. But it was also reported things weren't overlapping, etc. so that's not the issue. Warner