Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp7295849ybc; Thu, 28 Nov 2019 14:48:59 -0800 (PST) X-Google-Smtp-Source: APXvYqxe/BO1OR7imjwpXS9EGiV24/9tIJf+aTWJWvCMZXTgPnQF5ZYvmdvupqtkH5JLZ9ZuUboZ X-Received: by 2002:a17:906:c2d6:: with SMTP id ch22mr58493814ejb.262.1574981338952; Thu, 28 Nov 2019 14:48:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574981338; cv=none; d=google.com; s=arc-20160816; b=fOR8uzF2l7XmR+VPAJsyDd9VzePlZIE+VZv1f3N6gMedh3W7x792+Kd0XF93YujwGt kJ6fIom98FzKdyhpMUVhWSFiYsB4pAwIo3m6iexmNDDW7f9K5aKmHSBARlFbm53DN/pd fUbL6LJ9CeXce/6H7zvJT6f8qoa42zvQEFhbjHt+og91xGg/yW4TPsBp1d7v9syOxkJU L+96reBzj+3PSIfRmnJsllYV3m9n5+5c0QpVln5zet3/xqqg+VPnk72f5NKhuqVgmBS7 Lp1jGW7tMuDl8ebyFqoWguCUuIr0pBjx6am+r2BxuwkhQurTMvmAzUHUPqsa01dM0m0R Dtsw== 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=CUk7v7UPe6VTRCevALfgnUC9KL2cGJpFHn8mL3idLe0=; b=e+MvXKKDA98fz8wm290bDYzwDTmWNhaxZOG+0emuzRT7Gh97EgB1hZmaTH7NJoRwKu mFGfW68AP1hdzh1dIbA7cK0bX1F7MlCeaolof1QC7m5gcmI7DcoQVWFdI81Fv6d5SWtu YShS/q+QVYu8AEsAfMOKR9cCaoXBixKEcoGOWdyhZWLwGrgBVU7l2kItWXrUb6Bt4N8V HdlxL3je0Ao3SXaX7QZUE1sKYj8YoeJUk5pV2FiY3aD98CS8xAyBWquq7Xmwvxf8oxlD uaANMGGUpQXvWyvhDvVxnFJ/Q1lqhS5tSbwSGGinMMgTjGItjTHMhdMH79khLU9r5ML/ VvcA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="Y8Ea/smQ"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j20si12235815ejm.348.2019.11.28.14.48.34; Thu, 28 Nov 2019 14:48:58 -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=@google.com header.s=20161025 header.b="Y8Ea/smQ"; 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; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726655AbfK1Wrc (ORCPT + 99 others); Thu, 28 Nov 2019 17:47:32 -0500 Received: from mail-ot1-f68.google.com ([209.85.210.68]:43306 "EHLO mail-ot1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726582AbfK1Wrc (ORCPT ); Thu, 28 Nov 2019 17:47:32 -0500 Received: by mail-ot1-f68.google.com with SMTP id l14so23313361oti.10 for ; Thu, 28 Nov 2019 14:47:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=CUk7v7UPe6VTRCevALfgnUC9KL2cGJpFHn8mL3idLe0=; b=Y8Ea/smQHjouC6SBRXFZkjwTn2tarmmechSnFeym66dooOOnkxhT2nHCmkSARtdQUe ZXdW78yhSFGWQa9ZEKD+TSdGevk4bhR+ccadD5qPzyAVHBSeBpKWvJNNtVxHxWYdKSlw tsLHHiQ1/WZPQ7fJQVfpJxtzU5skIztwBNzX5XZeRT1BCWYgL3D14cJyuo171iKI4apV 7E/2u7t3FvJMNVr/zLBD1kmeCWN/E3GUMZmzjsEZ0yKeEv5iUJpSKP1JivJYGprcKcsb cVpqaAEL62COc9FyK1lg2vZAtfyTW3MfKZ4yqB7r/BorGWp6TDqqVlQRslci132N+iyF Zafw== 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=CUk7v7UPe6VTRCevALfgnUC9KL2cGJpFHn8mL3idLe0=; b=IwumMKBE+XuMzloUrImKo3O0euYLOv12OJfyFYxuYP8ODGksOPBI8V5u0Ac2JPeheQ AfOBQFDAXpLKJo5xNhQk9pvqUNqAHo8CRIY45eaSBBQBM5sHSAOy+aoZCv4N+80nj2nQ FQ9YA7N4CXT07afwHtxtW8irZHJteWQ33aHf8tOwk3Yha+uTvDIA+TBIScLGByWPysCS f/KwAKpo4JJ5gUyaGAG1LPTECiHUprrz4UzpmJIfdK6p8GiX2h/nM+Frzf1cu7Ghlgim L2OThsezttkQidC6KFdNGdyqZP4pCH/cRqrZzIm/QlDqiXusio2CzhK/VB4oRsZhsDmK 5q5w== X-Gm-Message-State: APjAAAVOWJVZDRsbXB4ZbSsxn98TCbRk2pTjb9wkt2ifkYjauINtLiMh xpUZb70Qq+EPS9J5uuEtZg96fsUgkeeC1hDmjTjFIw== X-Received: by 2002:a9d:4801:: with SMTP id c1mr8740496otf.32.1574981248999; Thu, 28 Nov 2019 14:47:28 -0800 (PST) MIME-Version: 1.0 References: <254505c9-2b76-ebeb-306c-02aaf1704b88@kernel.dk> <1d3a458a-fa79-5e33-b5ce-b473122f6d1a@kernel.dk> In-Reply-To: From: Jann Horn Date: Thu, 28 Nov 2019 23:46:59 +0100 Message-ID: Subject: Re: [PATCH RFC] signalfd: add support for SFD_TASK To: Rasmus Villemoes Cc: Jens Axboe , io-uring , "linux-kernel@vger.kernel.org" , linux-fsdevel 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, Nov 28, 2019 at 8:18 PM Jann Horn wrote: > On Thu, Nov 28, 2019 at 11:07 AM Jann Horn wrote: > > On Thu, Nov 28, 2019 at 10:02 AM Rasmus Villemoes > > wrote: > > > On 28/11/2019 00.27, Jann Horn wrote: > > > > > > > One more thing, though: We'll have to figure out some way to > > > > invalidate the fd when the target goes through execve(), in particular > > > > if it's a setuid execution. Otherwise we'll be able to just steal > > > > signals that were intended for the other task, that's probably not > > > > good. > > > > > > > > So we should: > > > > a) prevent using ->wait() on an old signalfd once the task has gone > > > > through execve() > > > > b) kick off all existing waiters > > > > c) most importantly, prevent ->read() on an old signalfd once the > > > > task has gone through execve() > > > > > > > > We probably want to avoid using the cred_guard_mutex here, since it is > > > > quite broad and has some deadlocking issues; it might make sense to > > > > put the update of ->self_exec_id in fs/exec.c under something like the > > > > siglock, > > > > > > What prevents one from exec'ing a trivial helper 2^32-1 times before > > > exec'ing into the victim binary? > > > > Uh, yeah... that thing should probably become 64 bits wide, too. > > Actually, that'd still be wrong even with the existing kernel code for > two reasons: > > - if you reparent to a subreaper, the existing exec_id comparison breaks ... actually, I was wrong about this, this case is fine because the ->exit_signal is reset in reparent_leader().