From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.2 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 19465C37122 for ; Tue, 22 Jan 2019 00:51:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D21712085A for ; Tue, 22 Jan 2019 00:51:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="XQmTqNDM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726601AbfAVAvg (ORCPT ); Mon, 21 Jan 2019 19:51:36 -0500 Received: from mail-vk1-f193.google.com ([209.85.221.193]:40009 "EHLO mail-vk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726148AbfAVAvg (ORCPT ); Mon, 21 Jan 2019 19:51:36 -0500 Received: by mail-vk1-f193.google.com with SMTP id v70so4987995vkv.7 for ; Mon, 21 Jan 2019 16:51:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=IxTrGZqf1bikahyQhxhLMNzWDIioHKwPEhCnb5vvY/M=; b=XQmTqNDMLZqNE8VFEHc8fjMhWSQ6mVkYXOKpHgNKQd1a480aJnETKLHOGOlsp7mD0v AnJ3CwFKbUD+c/bzNfTV/EspNHHj2nP21PbgK+xNNqheKhg0lvQm0xHszsCFmhFb2twz 08avTHCDg+JMFwp+0xIllDQj3ZvTzFLSyW41E= 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=IxTrGZqf1bikahyQhxhLMNzWDIioHKwPEhCnb5vvY/M=; b=RyeQswvzzPOiHoFpkB+TPa6iRFUMgdkBeCjSimvB4rWfj9EHCkTkk0zW4MCF4nmwC2 Z5/S+aNDldpwDOT8C7yhmP8MlYh16N4f6bhH1coVbmJue5hN2zmQ57vDqWiiGi93uCzH dB3DKsMBxo0rauUC+fXkxdSHPCjiAOMoWqZKkslH0oMfXRjb9O0isJ/6U5kH9ChvDqdX aqTMGRaGwa8a0L09pBGhc1CGjsAAG2kznrQEPN/YCl4uQx/p3kctst7eT/kDNoB7kG0T p2esKhn/4uzJX0OKFffMkGhNaiSuxVGudtLfIqDNN8rwM5svbrlcGqcluMKspiamybrP NUsw== X-Gm-Message-State: AJcUukeVHigk38s1SQl00RN6MKmishajc/Wm86XLZ9GRAs1myjUWB/qZ 5uv3ook4omWa+HznWS99AhreyQVosDI= X-Google-Smtp-Source: ALg8bN5F16G7qp48s6p8CxFBXc/3RF22RDj5IIA6L3NPbnGtx8xeQGxFEnDZGXH52qlrKY96/5lG9A== X-Received: by 2002:a1f:19d6:: with SMTP id 205mr12146619vkz.53.1548118294568; Mon, 21 Jan 2019 16:51:34 -0800 (PST) Received: from mail-vs1-f51.google.com (mail-vs1-f51.google.com. [209.85.217.51]) by smtp.gmail.com with ESMTPSA id o8sm29184764vkf.4.2019.01.21.16.51.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 21 Jan 2019 16:51:33 -0800 (PST) Received: by mail-vs1-f51.google.com with SMTP id x64so13698617vsa.5 for ; Mon, 21 Jan 2019 16:51:33 -0800 (PST) X-Received: by 2002:a67:e199:: with SMTP id e25mr13220885vsl.188.1548118292735; Mon, 21 Jan 2019 16:51:32 -0800 (PST) MIME-Version: 1.0 References: <001a113f711ae2110c055f45acb8@google.com> <20171212220647.GJ185376@gmail.com> <20190121211800.GC2217@ZenIV.linux.org.uk> In-Reply-To: <20190121211800.GC2217@ZenIV.linux.org.uk> From: Kees Cook Date: Tue, 22 Jan 2019 13:51:20 +1300 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] fs: Allow opening only regular files during execve(). To: Al Viro Cc: Tetsuo Handa , Eric Biggers , Dmitry Vyukov , syzbot , "linux-fsdevel@vger.kernel.org" , LKML , syzkaller-bugs Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Tue, Jan 22, 2019 at 10:18 AM Al Viro wrote: > > On Mon, Jan 21, 2019 at 07:14:39PM +0900, Tetsuo Handa wrote: > > On Tue, Dec 12, 2017 at 2:06 PM, Eric Biggers wrote: > > > I'm not sure what the fix will be. Maybe the proc handlers should take a > > > different lock instead of cred_guard_mutex. Or perhaps execve should check that > > > the file is a regular file before it attempts to open it. > > > > We can easily distinguish open() from execve() and open() from others. ;-) > > > + /* The file or a script interpreter has to be a regular file. */ > > + if (unlikely(current->in_execve && !S_ISREG(inode->i_mode))) { > > + error = -EACCES; > > + goto cleanup_file; > > + } > > We are *NOT* going to use current->in_execve to propagate that information. > Come up with a cleaner solution, if you care, but this one is a non-starter. > Too ugly to live. Sorry. What would you suggest for a cleaner indication of being in an execve? -- Kees Cook