Skip to contentSkip to conversation

auth_gss: fix panic in gss_pipe_downcall() in fips mode

PATCH In review Scott Mayhew 2 participants 3 messages Feb 15, 2016 – Feb 16, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 auth_gss: fix panic in gss_pipe_downcall() in fips mode

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.

---
 net/sunrpc/auth_gss/auth_gss.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/auth_gss/auth_gss.c +3 -0
index 799e65b..c30fc3b 100644
@@ -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);
Signature · 1 line
2.4.3
#1 lore raw

Hi Scott,

Quoted 26 lines · Scott Mayhew

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.

---
 net/sunrpc/auth_gss/auth_gss.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/auth_gss/auth_gss.c +3 -1
index 799e65b..c30fc3b 100644
@@ -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);
--
Quoted 2 lines

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

#2 lore raw
Quoted 28 lines · Trond Myklebust

Hi Scott,

Quoted 25 lines · Scott Mayhew

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.

---
 net/sunrpc/auth_gss/auth_gss.c | 3 +++
 1 file changed, 3 insertions(+)
net/sunrpc/auth_gss/auth_gss.c +3 -0
index 799e65b..c30fc3b 100644
@@ -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);
Quoted 8 lines
Quoted 3 lines

--
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.

Quoted 6 lines

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