Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp788447imj; Fri, 15 Feb 2019 06:51:51 -0800 (PST) X-Google-Smtp-Source: AHgI3IYA/hjz4/CUe1joYn3cSylaoLBMJaOMIRSOoNwESlEfYsdHYtNX7bSGcbObC4ctdCo4hlhj X-Received: by 2002:a63:fc59:: with SMTP id r25mr5849836pgk.302.1550242311346; Fri, 15 Feb 2019 06:51:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550242311; cv=none; d=google.com; s=arc-20160816; b=KbpAc0Vf8jQLlr6eHJiEIK3lb7b4IoS/gg+PdQ3g1oTy9KV20k7EhpuTDd82Mzo6k6 CmHvJnYopyCxBHsvw50yDbbU3NfluaDqFr4Fj0Ip+FnJHsZPkz3fuopScw1Gsux3fpRt y7gyof4plo2makYEfB5Shw/2yfK+J0fzrQRZty+gvXk7MnnKElu9kbvBAQCC6/1Q4UuQ xi7DXvP54GyPIhPkX+jn/QnboxhyuKzIKyc5JZYewKlq1asChVPI2Cu8qUyJwPAphezL bGQdDC951+i5by73A0beftt+X8AI3uxZbxm2TWrtOjC17899xsEBAoQA6z96xJCLpMJ5 o2VA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=QyeHskx0/vQ3UTHmBuASmrGmBn7fmPd/nmtJ95MQs4w=; b=xQn7mAolw+k//eYjexneDtnCnqZAhGIYcRLFxUdS9FFlVef1+Z5D/38cVtWZABY8hU 9hLYk6nTJc40yZnvJk/zHI3XKw0mNvxP+yiFEKB53qG3hHttSbfYhv62JqfYrAJhaE76 m/JAcuNC/pAQ5ijRKD9l43KBiQh/66CWdDmI2HI8mFzFvqjr+McTi6A3y91sHX/JyaBu +vLkai6h1knHkAknxvqQ/EcPH75xHRDwG4mf+Ay7z0AIOH7n5qQS4VTYhbnoOnLBidyd oaeCablJZf4cgifSupP981ZDEUf1dI69S1J02WfYGI6A3/aQ+O17pCFsmbCmPbaTr9FH 9b3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@quantonium-net.20150623.gappssmtp.com header.s=20150623 header.b=qTH2BLnO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f4si5914717plf.370.2019.02.15.06.51.35; Fri, 15 Feb 2019 06:51:51 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@quantonium-net.20150623.gappssmtp.com header.s=20150623 header.b=qTH2BLnO; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731046AbfBOECK (ORCPT + 99 others); Thu, 14 Feb 2019 23:02:10 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33473 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726192AbfBOECK (ORCPT ); Thu, 14 Feb 2019 23:02:10 -0500 Received: by mail-wr1-f65.google.com with SMTP id i12so8874217wrw.0 for ; Thu, 14 Feb 2019 20:02:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=quantonium-net.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=QyeHskx0/vQ3UTHmBuASmrGmBn7fmPd/nmtJ95MQs4w=; b=qTH2BLnOMKO6xW1j9Uc3QVrLT6KjdjR5U7VdPj+mZJAFRRIVcXV8M2g+qRp9JEEzPg s05/tJydzNMUQ+C3MeIgyqvkCqeunyb8qCLPaQqsnLQWAe1L6FJCZxYqavlVOp/21/AJ yRhrVnzj/gAM1Ia6M7XIShUkzioisnNtQw1P+Q1NGaV3YZXtSxQPC8DEjvJctMgSGB26 B/J6YcpeYQF8fKrd8B1xruFjlqfAJUZgycI1RHw35ytpW3JL+Gn1/ajyEMV9lJ+BSwp1 r8JtuFmVV13ZjfOg+ZWDsqKddtWP9OakrrimIBL7XOp1b1g7JyBpaVWk1BXo7bSYnE3p rlng== 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=QyeHskx0/vQ3UTHmBuASmrGmBn7fmPd/nmtJ95MQs4w=; b=FKhN+j6BV+qo7veiL2B/FgyS9EeFmIK0cKVCgqYW4U/lmqzSfZ0DwI/E/7pMFVeW6G LRUE3dkbyspn9/bInMED2M41l1/+bzGYTIw1A4aGqeegOqSwhme8UBiBt3hVmV7LEEYN XBeE3xG4k1GgXSPE/Fi9cRWB5d1h974sI07cs0ResGN1zT609J2cHrJlaFmXDxQDR87z 8QQlRvCAMz4SZGCnXEhFc25xYUv6+7xge0gNrpxTf3QvI3tmdfDWXR6ca/7fOnUBk/wO 0BwYlCgro1dxSNv/2r90spPxqU4Vhl6GDgZOICWvVu9YtEFkc+92cTEy6bfCmlyefUIm 5Tug== X-Gm-Message-State: AHQUAuZgW3SLzYJSOuZw+czDbt6Kz3LoI2fEdBOxYZf5f/dF7yLhKkfr 26xRF61TWpBN0NZYmFX/xnqR0H33iledhD/l1Mw2Vg== X-Received: by 2002:adf:eb07:: with SMTP id s7mr5292160wrn.158.1550203327797; Thu, 14 Feb 2019 20:02:07 -0800 (PST) MIME-Version: 1.0 References: <1536657703-27577-1-git-send-email-asmadeus@codewreck.org> <20180912053642.GA2912@nautica> <20180917.184502.447385458615284933.davem@davemloft.net> <20180918015723.GA26300@nautica> <20181031025657.GA17861@nautica> <20190215010029.GA10899@nautica> <20190215015705.GA17974@nautica> <20190215033102.GA3099@nautica> In-Reply-To: <20190215033102.GA3099@nautica> From: Tom Herbert Date: Thu, 14 Feb 2019 20:01:56 -0800 Message-ID: Subject: Re: [PATCH v2] kcm: remove any offset before parsing messages To: Dominique Martinet Cc: Tom Herbert , David Miller , Doron Roberts-Kedes , Dave Watson , Linux Kernel Network Developers , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 14, 2019 at 7:31 PM Dominique Martinet wrote: > > Tom Herbert wrote on Thu, Feb 14, 2019: > > > This second patch[2] (the current thread) now does an extra clone if > > > there is an offset, but the problem really isn't in the clone but the > > > pull itself that can fail and return NULL when there is memory pressure. > > > For some reason I hadn't been able to reproduce that behaviour with > > > strparser doing the pull, but I assume it would also be possible to hit > > > in extreme situations, I'm not sure... > > > > This option looks the best to me, at least as a way to fix the issue > > without requiring a change to the API. If the pull fails, doesn't that > > just mean that the parser fails? Is there some behavior with this > > patch that is not being handled gracefully? > > Yes, the parser fails with -ENOMEM ; that is not handled gracefully at > all: from a user point of view, the connection just hangs (recvmsg never > returns), without so much as a message in dmesg either. > Dominique, That's by design. Here is the description in kcm.txt: "When a TCP socket is attached to a KCM multiplexor data ready (POLLIN) and write space available (POLLOUT) events are handled by the multiplexor. If there is a state change (disconnection) or other error on a TCP socket, an error is posted on the TCP socket so that a POLLERR event happens and KCM discontinues using the socket. When the application gets the error notification for a TCP socket, it should unattach the socket from KCM and then handle the error condition (the typical response is to close the socket and create a new connection if necessary)." > It took me a while to figure out what failed exactly as I did indeed > expect strparser/kcm to handle that better, but ultimately as things > stand if the parser fails it calls strp_parser_err() with the error > which ends up in strp_abort_strp that should call > sk->sk_error_report(sk) but in kcm case sk is the csk and I guess > failing csk does not make a pending recv on the kcm sock to fail... > > I'm not sure whether propagating the error to the upper socket is the > right thing to do, kcm is meant to be able to work with multiple > underlying sockets so I feel we must be cautious about that, but Right, that's the motivation for the design. > strparser might be able to retry somehow. We could retry on -ENOMEM since it is potentially a transient error, but generally for errors (like connection is simply broken) it seems like it's working as intended. I suppose we could add a socket option to fail the KCM socket when all attached lower sockets have failed, but I not sure that would be a significant benefit for additional complexity. > This is what I said below: > > > [,,,] > > > - the current patch, that I could only get to fail with KASAN, but does > > > complexify kcm a bit; this also does not fix bpf sockmap at all. > > > Would still require to fix the hang, so make strparser retry a few times > > > if strp->cb.parse_msg failed maybe? Or at least get the error back to > > > userspace somehow. The error should be getting to userspace via the TCP socket. Tom > > Thanks, > -- > Dominique