linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] auth_gss: fix panic in gss_pipe_downcall() in fips mode
@ 2016-02-15 19:28 Scott Mayhew
  2016-02-15 19:57 ` Trond Myklebust
  0 siblings, 1 reply; 3+ messages in thread
From: Scott Mayhew @ 2016-02-15 19:28 UTC (permalink / raw)
  To: trond.myklebust; +Cc: linux-nfs

md5 is disabled in fips mode, and attempting to import a gss context
using md5 while in fips mode will result in crypto_alg_mod_lookup()
returning -ENOENT, which will make its way back up to
gss_pipe_downcall(), where the BUG() is triggered.  Handling the -ENOENT
allows for a more graceful failure.

Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
 net/sunrpc/auth_gss/auth_gss.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
index 799e65b..c30fc3b 100644
--- a/net/sunrpc/auth_gss/auth_gss.c
+++ b/net/sunrpc/auth_gss/auth_gss.c
@@ -737,6 +737,9 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
 		case -ENOSYS:
 			gss_msg->msg.errno = -EAGAIN;
 			break;
+		case -ENOENT:
+			gss_msg->msg.errno = -EPROTONOSUPPORT;
+			break;
 		default:
 			printk(KERN_CRIT "%s: bad return from "
 				"gss_fill_context: %zd\n", __func__, err);
-- 
2.4.3


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] auth_gss: fix panic in gss_pipe_downcall() in fips mode
  2016-02-15 19:28 [PATCH] auth_gss: fix panic in gss_pipe_downcall() in fips mode Scott Mayhew
@ 2016-02-15 19:57 ` Trond Myklebust
  2016-02-16 21:20   ` Scott Mayhew
  0 siblings, 1 reply; 3+ messages in thread
From: Trond Myklebust @ 2016-02-15 19:57 UTC (permalink / raw)
  To: Scott Mayhew; +Cc: Linux NFS Mailing List

Hi Scott,

On Mon, Feb 15, 2016 at 2:28 PM, Scott Mayhew <smayhew@redhat.com> wrote:
> md5 is disabled in fips mode, and attempting to import a gss context
> using md5 while in fips mode will result in crypto_alg_mod_lookup()
> returning -ENOENT, which will make its way back up to
> gss_pipe_downcall(), where the BUG() is triggered.  Handling the -ENOENT
> allows for a more graceful failure.
>
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> ---
>  net/sunrpc/auth_gss/auth_gss.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
> index 799e65b..c30fc3b 100644
> --- a/net/sunrpc/auth_gss/auth_gss.c
> +++ b/net/sunrpc/auth_gss/auth_gss.c
> @@ -737,6 +737,9 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
>                 case -ENOSYS:
>                         gss_msg->msg.errno = -EAGAIN;
>                         break;
> +               case -ENOENT:
> +                       gss_msg->msg.errno = -EPROTONOSUPPORT;
> +                       break;
>                 default:
>                         printk(KERN_CRIT "%s: bad return from "
>                                 "gss_fill_context: %zd\n", __func__, err);
> --
> 2.4.3
>

Well debugged, but I unfortunately do have to ask if this patch is
sufficient? In addition to -ENOENT, and -ENOMEM, it looks to me as if
crypto_alg_mod_lookup() can also fail with -EINTR, -ETIMEDOUT, and
-EAGAIN. Don't we also want to handle those?

In fact, peering into the rats nest that is
gss_import_sec_context_kerberos(), it looks as if that is just a tiny
subset of all the errors that we might run into. Perhaps the right
thing to do here is to get rid of the BUG() (but keep the above
printk) and just return a generic error?

Cheers
  Trond

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] auth_gss: fix panic in gss_pipe_downcall() in fips mode
  2016-02-15 19:57 ` Trond Myklebust
@ 2016-02-16 21:20   ` Scott Mayhew
  0 siblings, 0 replies; 3+ messages in thread
From: Scott Mayhew @ 2016-02-16 21:20 UTC (permalink / raw)
  To: Trond Myklebust; +Cc: Linux NFS Mailing List

[-- Attachment #1: Type: text/plain, Size: 2117 bytes --]

On Mon, 15 Feb 2016, Trond Myklebust wrote:

> Hi Scott,
> 
> On Mon, Feb 15, 2016 at 2:28 PM, Scott Mayhew <smayhew@redhat.com> wrote:
> > md5 is disabled in fips mode, and attempting to import a gss context
> > using md5 while in fips mode will result in crypto_alg_mod_lookup()
> > returning -ENOENT, which will make its way back up to
> > gss_pipe_downcall(), where the BUG() is triggered.  Handling the -ENOENT
> > allows for a more graceful failure.
> >
> > Signed-off-by: Scott Mayhew <smayhew@redhat.com>
> > ---
> >  net/sunrpc/auth_gss/auth_gss.c | 3 +++
> >  1 file changed, 3 insertions(+)
> >
> > diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c
> > index 799e65b..c30fc3b 100644
> > --- a/net/sunrpc/auth_gss/auth_gss.c
> > +++ b/net/sunrpc/auth_gss/auth_gss.c
> > @@ -737,6 +737,9 @@ gss_pipe_downcall(struct file *filp, const char __user *src, size_t mlen)
> >                 case -ENOSYS:
> >                         gss_msg->msg.errno = -EAGAIN;
> >                         break;
> > +               case -ENOENT:
> > +                       gss_msg->msg.errno = -EPROTONOSUPPORT;
> > +                       break;
> >                 default:
> >                         printk(KERN_CRIT "%s: bad return from "
> >                                 "gss_fill_context: %zd\n", __func__, err);
> > --
> > 2.4.3
> >
> 
> Well debugged, but I unfortunately do have to ask if this patch is
> sufficient? In addition to -ENOENT, and -ENOMEM, it looks to me as if
> crypto_alg_mod_lookup() can also fail with -EINTR, -ETIMEDOUT, and
> -EAGAIN. Don't we also want to handle those?

You're right, I was focusing on the panic that I could easily reproduce.
I'm still not sure how I could trigger those other conditions.

> 
> In fact, peering into the rats nest that is
> gss_import_sec_context_kerberos(), it looks as if that is just a tiny
> subset of all the errors that we might run into. Perhaps the right
> thing to do here is to get rid of the BUG() (but keep the above
> printk) and just return a generic error?

That sounds fine to me -- updated patch attached.

-Scott

[-- Attachment #2: 0001-auth_gss-remove-the-BUG-from-gss_pipe_downcall.patch --]
[-- Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-02-16 21:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-15 19:28 [PATCH] auth_gss: fix panic in gss_pipe_downcall() in fips mode Scott Mayhew
2016-02-15 19:57 ` Trond Myklebust
2016-02-16 21:20   ` Scott Mayhew

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 NNTP newsgroup(s).